Open nt4f04uNd opened 1 year ago
Here are few things:
It's a layer over FFI with no explicit threading added in. That means the calls happen from same thread. Use Isolate
APIs to explicitly run in a different isolate.
If you're asking about Android UI thread (Which is different from flutter UI thread), it's hard until dart-lang/native#758 lands. Since you can't pass callbacks for now, you should wrap your logic in Java code calling runOnUiThread
, and expose it as a regular function. Hope the examples give sufficient idea of this.
If you're calling JNI method from an isolate on dart standalone target, make sure to call Jni.setDylibsDir
from that isolate. That's because each isolate loads the JNI support library separately.
All references are JNI global references, which means you should be able to use them across async calls etc..
Nothing else comes to mind.
Of course we should document it, and add an example to each of these. Especially calling something from different isolate.
Hello, thanks for this awesome tool - this is something that I have been dreaming of :-)
It would be useful to have documentation on this: which thread is a call to JNI executed, and if there is, other stuff that one should be aware of before calling to JNI.