I followed the example to move the ImageTarget sample to a native activity. (see https://developer.vuforia.com/library/articles/Solution/Update-Native-Android-Samples-to-Use-Native-Activities)
I noticed that in step 14 in the onGLInitialized function the native thread is attached to the JavaVM before calling the Java function (as expected). Afterwards, the thread however is not detached from the JavaVm again. So I added that instruction. The outcome is that I no longer see the camera picture, only the tracker target object is rendered on a black background. When I keep the native thread attached, the camera picture shows just fine.
As a next step I also tried to move some more initialization into the native thread, especially initializing and loading trackers. When I call the AttachCurrentThread before loading the database, things work fine. When the native thread is however not attached at time of loading the tracker data the operation fails. I would not have expected this as loading tracker data is not UI related.
These observations lead me to the following two questions:
1) Are there some QCAR functions which must only be called from C++ code if the execution thread is attached to the JavaVM?
2) On my Nexus7 refresh rates seem rather a bit slow when keeping the thread attached to the JavaVm. When the thread is not attached to the VM the tracker object moves much smoother. I cannot tell whether the performance increase comes from not rendering camera picture or from not attaching to VM. Is there a set of best practices to get best performance when using native code?