Closed SteveGreatApe closed 6 years ago
Thanks for letting us know. Since this is a change I made, I will look into fixing your problem.
@SteveGreatApe Are you creating and setting new main scenes?
Also do you derive from GVRScene? Do you use removeAllSceneObjects? Do you use any of the loadXyz methods of the AssetLoader that take a scene parameter?
It looks very much like the root scene object is nullptr but nevertheless, could you please also run with this patch that outputs extra traces? Thanks. diff.txt
Do you use removeAllSceneObjects?
That's the one, removed the call now and I'm up and running again with the latest build.
And here's the result of the logging you requested, no null pointer showing
2018-08-15 09:22:33.392 16533-17138/com.greatape.avrgallery I/gvrf: scene_object.cpp this: 0xd81e3d40
2018-08-15 09:22:33.392 16533-17138/com.greatape.avrgallery I/gvrf: scene_object.cpp component: 0xd5bb6b00
2018-08-15 09:22:33.392 16533-17138/com.greatape.avrgallery I/gvrf: scene_object.cpp child: 0xd81e3e80
2018-08-15 09:22:33.392 16533-17138/com.greatape.avrgallery I/gvrf: scene_object.cpp this: 0xd81e3e80
2018-08-15 09:22:33.392 16533-17138/com.greatape.avrgallery I/gvrf: scene_object.cpp component: 0xd5bb6c40
2018-08-15 09:22:33.392 16533-17138/com.greatape.avrgallery I/gvrf: scene_object.cpp component: 0xd5bb6ba0
2018-08-15 09:22:33.392 16533-17138/com.greatape.avrgallery I/gvrf: scene_object.cpp child: 0xd81e3fc0
2018-08-15 09:22:33.392 16533-17138/com.greatape.avrgallery I/gvrf: scene_object.cpp this: 0xd81e3fc0
2018-08-15 09:22:33.392 16533-17138/com.greatape.avrgallery I/gvrf: scene_object.cpp component: 0xd5bb6ce0
2018-08-15 09:22:33.392 16533-17138/com.greatape.avrgallery I/gvrf: scene_object.cpp child: 0xd81e4100
2018-08-15 09:22:33.392 16533-17138/com.greatape.avrgallery I/gvrf: scene_object.cpp this: 0xd81e4100
2018-08-15 09:22:33.392 16533-17138/com.greatape.avrgallery I/gvrf: scene_object.cpp component: 0xd5bb6d80
2018-08-15 09:22:33.392 16533-17138/com.greatape.avrgallery I/gvrf: scene_object.cpp component: 0xc4cf6e80
2018-08-15 09:22:33.392 16533-17138/com.greatape.avrgallery I/gvrf: scene_object.cpp child: 0xd81e4240
2018-08-15 09:22:33.392 16533-17138/com.greatape.avrgallery I/gvrf: scene_object.cpp this: 0xd81e4240
2018-08-15 09:22:33.392 16533-17138/com.greatape.avrgallery I/gvrf: scene_object.cpp component: 0xd5bb6e20
2018-08-15 09:22:33.392 16533-17138/com.greatape.avrgallery I/gvrf: scene_object.cpp component: 0xc4cf6f00
2018-08-15 09:22:33.392 16533-17138/com.greatape.avrgallery I/gvrf: scene_object.cpp child: 0xd81e4380
2018-08-15 09:22:33.392 16533-17138/com.greatape.avrgallery I/gvrf: scene_object.cpp this: 0xd81e4380
2018-08-15 09:22:33.392 16533-17138/com.greatape.avrgallery I/gvrf: scene_object.cpp component: 0xd5bb6ec0
2018-08-15 09:22:33.392 16533-17138/com.greatape.avrgallery I/gvrf: scene_object.cpp component: 0xc4cf6f80
2018-08-15 09:22:34.864 16533-17138/com.greatape.avrgallery I/gvrf: scene_object.cpp this: 0xd81e4600
2018-08-15 09:22:34.864 16533-17138/com.greatape.avrgallery I/gvrf: scene_object.cpp component: 0xc4ddfbe0
2018-08-15 09:22:34.864 16533-17138/com.greatape.avrgallery I/gvrf: scene_object.cpp component: 0xd8196880
2018-08-15 09:22:42.792 16533-17138/com.greatape.avrgallery I/gvrf: scene_object.cpp this: 0xd81e2a80
2018-08-15 09:22:42.792 16533-17138/com.greatape.avrgallery I/gvrf: scene_object.cpp component: 0x345ad82c
2018-08-15 09:22:42.794 16533-17138/com.greatape.avrgallery A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0xc in tid 17138 (GLThread 18140)
I also tried setting a breakpoint on GVRViewManager.setMainSceneImpl to see where it was getting called from. It was on the second call to this function it crashed, you can see from the timestamps above there was an earlier batch of log events before the final couple before the crash.
The stack dump for this second call is:
setMainSceneImpl:145, GVRViewManager (org.gearvrf)
setMainScene:133, GVRViewManager (org.gearvrf)
finished:425, GVRViewManager$2$1$1$1 (org.gearvrf)
onDrawFrame:376, GVRAnimation (org.gearvrf.animation)
onDrawFrame:149, GVRAnimationEngine$DrawFrame (org.gearvrf.animation)
doMemoryManagementAndPerFrameCallbacks:280, GVRViewManager (org.gearvrf)
access$700:47, GVRViewManager (org.gearvrf)
beforeDrawEyes:400, GVRViewManager$2 (org.gearvrf)
beforeDrawEyes:512, GVRViewManager (org.gearvrf)
beforeDrawEyes:163, OvrViewManager (org.gearvrf)
drawEyes:-1, OvrViewManager (org.gearvrf)
onDrawFrame:254, OvrViewManager (org.gearvrf)
onDrawFrame:383, OvrVrapiActivityHandler$6 (org.gearvrf)
guardedRun:1571, GLSurfaceView$GLThread (android.opengl)
run:1270, GLSurfaceView$GLThread (android.opengl)
Thanks. I can clearly see a bug in removeAllSceneObjects.
@SteveGreatApe Tentative fix https://github.com/Samsung/GearVRf/pull/1966. Still don't know how exactly it happens. Also added few more traces that may be helpful if the fix doesn't work.
This has caused another problem, I'm getting a null pointer for the GVRCameraRig transform.
A/zygote: java_vm_ext.cc:504] JNI DETECTED ERROR IN APPLICATION: JNI CallVoidMethodV called with pending exception java.lang.NullPointerException: Attempt to invoke virtual method 'org.joml.Matrix4f org.gearvrf.GVRTransform.getModelMatrix4f()' on a null object reference
A/zygote: java_vm_ext.cc:504] at void org.gearvrf.io.GVRGearCursorController.handleControllerEvent(org.gearvrf.io.GVRGearCursorController$ControllerEvent) (GVRGearCursorController.java:530)
A/zygote: java_vm_ext.cc:504] at void org.gearvrf.io.GVRGearCursorController.pollController() (GVRGearCursorController.java:429)
A/zygote: java_vm_ext.cc:504] at void org.gearvrf.io.GVRInputManager.updateGearControllers() (GVRInputManager.java:415)
A/zygote: java_vm_ext.cc:504] at void org.gearvrf.GVRViewManager.beforeDrawEyes() (GVRViewManager.java:516)
A/zygote: java_vm_ext.cc:504] at void org.gearvrf.OvrViewManager.beforeDrawEyes() (OvrViewManager.java:163)
A/zygote: java_vm_ext.cc:504] at void org.gearvrf.OvrViewManager.drawEyes(long) (OvrViewManager.java:-2)
A/zygote: java_vm_ext.cc:504] at void org.gearvrf.OvrViewManager.onDrawFrame() (OvrViewManager.java:254)
A/zygote: java_vm_ext.cc:504] at void org.gearvrf.OvrVrapiActivityHandler$6.onDrawFrame(javax.microedition.khronos.opengles.GL10) (OvrVrapiActivityHandler.java:383)
A/zygote: java_vm_ext.cc:504] at void android.opengl.GLSurfaceView$GLThread.guardedRun() (GLSurfaceView.java:1571)
A/zygote: java_vm_ext.cc:504] at void android.opengl.GLSurfaceView$GLThread.run() (GLSurfaceView.java:1270)
Made an update. If it doesn't help, would you consider creating a test app that at least mimics the flow you have?
The update didn't help, it's not a rare timing issue as it happens all the time, to reproduce it try this:
--- a/gvr-particles/app/src/main/java/org/gearvrf/particles/SampleMain.java
+++ b/gvr-particles/app/src/main/java/org/gearvrf/particles/SampleMain.java
@@ -41,6 +41,7 @@ public class SampleMain extends GVRMain {
GVRScene scene = gvrContext.getMainScene();
+ scene.removeAllSceneObjects();
scene.getMainCameraRig().getTransform().setPosition(0,0,0);
What phone do you use? Thanks.
Ok, NPE fixed. PR updated.
Afraid still not fixed yet, first time I ran it it fired up fine with no problem, but then when I called removeAllSceneObjects() again at a later time it crashed with the following error. I also managed to hit that same error but putting a break point on the initial call to removeAllSceneObjects() and stepping through the code instead of letting it just run.
I'd guess that means there's some sort of race condition where if GVRGearCursorController is initialised before calling removeAllSceneObjects() it triggers the problem.
java_vm_ext.cc:504] JNI DETECTED ERROR IN APPLICATION: JNI CallVoidMethodV called with pending exception java.lang.NullPointerException: Attempt to invoke virtual method 'org.gearvrf.GVRTransform org.gearvrf.GVRTransform.setModelMatrix(org.joml.Matrix4f)' on a null object reference
java_vm_ext.cc:504] at void org.gearvrf.io.GVRGearCursorController.handleControllerEvent(org.gearvrf.io.GVRGearCursorController$ControllerEvent) (GVRGearCursorController.java:544)
java_vm_ext.cc:504] at void org.gearvrf.io.GVRGearCursorController.pollController() (GVRGearCursorController.java:429)
java_vm_ext.cc:504] at void org.gearvrf.io.GVRInputManager.updateGearControllers() (GVRInputManager.java:415)
java_vm_ext.cc:504] at void org.gearvrf.GVRViewManager.beforeDrawEyes() (GVRViewManager.java:516)
java_vm_ext.cc:504] at void org.gearvrf.OvrViewManager.beforeDrawEyes() (OvrViewManager.java:163)
java_vm_ext.cc:504] at void org.gearvrf.OvrViewManager.drawEyes(long) (OvrViewManager.java:-2)
java_vm_ext.cc:504] at void org.gearvrf.OvrViewManager.onDrawFrame() (OvrViewManager.java:254)
java_vm_ext.cc:504] at void org.gearvrf.OvrVrapiActivityHandler$6.onDrawFrame(javax.microedition.khronos.opengles.GL10) (OvrVrapiActivityHandler.java:383)
java_vm_ext.cc:504] at void android.opengl.GLSurfaceView$GLThread.guardedRun() (GLSurfaceView.java:1571)
java_vm_ext.cc:504] at void android.opengl.GLSurfaceView$GLThread.run() (GLSurfaceView.java:1270)
java_vm_ext.cc:504]
java_vm_ext.cc:504] in call to CallVoidMethodV
java_vm_ext.cc:504] from void org.gearvrf.OvrViewManager.drawEyes(long)
@SteveGreatApe Reproduced by running a loop of many iterations that concurrently does that:
GVRScene scene = gvrContext.getMainScene();
scene.removeAllSceneObjects();
scene.getMainCameraRig().getTransform().setPosition(0,0,0);
In the latest update fixed a race condition in GVRGearCursorController; also prevented the controller-related updates from happening too early.
Afraid still got problems, it's starting up reliably now where I'm calling removeAllSceneObjects() on initialisation before I've actually added anything.
But when I later use it to remove everything before rebuilding the scene again I'm still getting an exception here:
JNI DETECTED ERROR IN APPLICATION: JNI CallVoidMethodV called with pending exception java.lang.NullPointerException: Attempt to invoke virtual method 'org.gearvrf.GVRTransform org.gearvrf.GVRTransform.setModelMatrix(org.joml.Matrix4f)' on a null object reference
at void org.gearvrf.io.GVRGearCursorController.handleControllerEvent(org.gearvrf.io.GVRGearCursorController$ControllerEvent) (GVRGearCursorController.java:544)
at void org.gearvrf.io.GVRGearCursorController.pollController() (GVRGearCursorController.java:428)
at void org.gearvrf.io.GVRInputManager.updateGearControllers() (GVRInputManager.java:415)
at void org.gearvrf.GVRViewManager$3.beforeDrawEyes() (GVRViewManager.java:471)
at void org.gearvrf.GVRViewManager.beforeDrawEyes() (GVRViewManager.java:517)
at void org.gearvrf.OvrViewManager.beforeDrawEyes() (OvrViewManager.java:163)
at void org.gearvrf.OvrViewManager.drawEyes(long) (OvrViewManager.java:-2)
at void org.gearvrf.OvrViewManager.onDrawFrame() (OvrViewManager.java:254)
at void org.gearvrf.OvrVrapiActivityHandler$6.onDrawFrame(javax.microedition.khronos.opengles.GL10) (OvrVrapiActivityHandler.java:383)
at void android.opengl.GLSurfaceView$GLThread.guardedRun() (GLSurfaceView.java:1571)
at void android.opengl.GLSurfaceView$GLThread.run() (GLSurfaceView.java:1270)
Ok, sorry about that. At least we are getting somewhere bit by bit. Thanks for your help.
Have an update. There was a detachAllComponents call in removeAllSceneObjects that was a concern even at the time it was added. I do not see a good reason for it to be there. Removed. I am pretty sure the last NPE you showed was caused by it.
That's looking better, all working fine so far.
Fix has been merged. Planning to close the issue in a day or two if you don't mind.
I synced to the latest code and started hitting this crash on startup, 90% of the time I'm getting the crash, the other 10% it starts up enough to draw the view, but then the view is frozen.
Reverting back to just before this commit got things working again for me, https://github.com/Samsung/GearVRf/commit/6206cb0a2614b0bd31f6cdbb1df1e57c7623bafe