@@ -69,6 +69,10 @@ refer to the [`permissions_plugin` demo][permissions-demo] and the
6969[ ` android_toast_demo ` ] [ toast-demo ] in the official Flutter native interop
7070demos repository.
7171
72+ For a production package on pub.dev that uses JNIgen to wrap the Android
73+ Cronet HTTP library, check out [ ` package:cronet_http ` ] [ cronet-http-pub ]
74+ ([ source on GitHub] [ cronet-http-src ] ).
75+
7276## Constraints and limitations
7377
7478Keep these general considerations and limitations in mind when working with
@@ -85,27 +89,32 @@ Watch out for two common scenarios:
8589 This can lead to deadlocks if a blocked Java thread waits for a blocked
8690 Dart thread.
8791
92+ To learn more, consult the [ JNIgen threading guide] [ jnigen-threading-doc ] .
93+
8894### Lifecycle of Java objects
8995
9096JNI wrappers use Java global references.
9197There is a hard limit of 50,000 active references.
9298Call ` .release() ` or use ` .using() ` blocks to prevent memory leaks.
9399Use ` WeakReference ` to break reference cycles between Dart and Java GCs
94- when implementing interfaces.
100+ when implementing interfaces, as shown in the
101+ [ JNI object lifecycle guide] [ jnigen-lifecycle-doc ] .
95102
96103### JVM runtime type checks
97104
98105JNI wrappers are Dart extension types that compile down to ` JObject `
99106at runtime, so Dart's native ` is ` and ` as ` keywords don't check the Java
100107runtime type.
101- Use ` x.isA(Foo.type) ` and ` x.as(Foo.type) ` instead.
108+ Use ` x.isA(Foo.type) ` and ` x.as(Foo.type) ` instead, as shown in the
109+ [ Java runtime types guide] [ jnigen-runtime-types-doc ] .
102110
103111### General debugging
104112
105113Tracking down JNI memory allocation bugs like ` DoubleReleaseError `
106114and ` UseAfterReleaseError ` can be difficult.
107115Set ` Jni.captureStackTraceOnRelease = true ` to log stack traces
108- and help trace leaks.
116+ and help trace leaks, as explained in the
117+ [ JNIgen debugging guide] [ jnigen-debugging-doc ] .
109118
110119## Resources
111120
@@ -118,7 +127,13 @@ refer to the following resources:
118127
119128[ jnigen-pub ] : {{site.pub-pkg}}/jnigen
120129[ jni-pub ] : {{site.pub-pkg}}/jni
130+ [ cronet-http-pub ] : {{site.pub-pkg}}/cronet_http
131+ [ cronet-http-src ] : https://github.com/dart-lang/http/tree/master/pkgs/cronet_http
121132[ jnigen-examples ] : https://github.com/dart-lang/native/tree/main/pkgs/jnigen/example
122133[ permissions-demo ] : {{site.repo.demos}}/tree/main/native_interop_demos/permissions_plugin
123134[ toast-demo ] : {{site.repo.demos}}/tree/main/native_interop_demos/android_toast_demo
124135[ run-on-platform-thread ] : {{site.api}}/flutter/dart-ui/runOnPlatformThread.html
136+ [ jnigen-threading-doc ] : https://github.com/dart-lang/native/blob/main/pkgs/jnigen/doc/threading.md
137+ [ jnigen-lifecycle-doc ] : https://github.com/dart-lang/native/blob/main/pkgs/jnigen/doc/lifecycle.md
138+ [ jnigen-runtime-types-doc ] : https://github.com/dart-lang/native/blob/main/pkgs/jnigen/doc/java_runtime_types.md
139+ [ jnigen-debugging-doc ] : https://github.com/dart-lang/native/blob/main/pkgs/jnigen/doc/debugging.md
0 commit comments