I have this app (Only one activity) that use some android UI and some native C++ lib to do OpenGl drawing and calculation.
It seems like the activity creates some “binder thread” on it’s own, and I’m pretty sure it causes some corruption amongs my native calls.
What are the binder threads ?
Can they be removed or merge into one ?
Finally found some good infos on the subject.
Binder threads can’t be removed or merge, but you can redirect function calls into the main thread pretty easily by using
HandlerandRunnableobjects.But, you can’t use that inside your Native code. So it’s possible that some of your native code create unexpected fault. For that you can synchronize your code inside JNI to minimize weird behavior. (details)
You can also, redirect some portion of your code to be executed inside the UI thread (which I don’t recommend if you want performance on the UI)
If you use a
GLSurfaceViewlike I do, you can also redirect code into the GL threadIt’s important to notice that android will always create a separate thread for the UI, so calling native code from your UI code, and from somewhere else could obviously cause unexpected behavior.
Also, using
GLSurfaceViewwill equally generate its own thread for rendering, so the same kind of interraction with native code is to avoid. But, with those few hints, you should be able to synchronize those threads and make it work flawlessly 😉