GVRVideoSceneObject causes a crash when the phone goes to sleep after removing a GVRVideoSceneObject from the scene.
The video is playing using a MediaPlayer instance inside a GVRVideoSceneObject, when I've finished with my video I've called MediaPlayer release(). I also remove from the scene the GVRVideoSceneObject I was using to play it along with other scene objects it was attached to.
Then when I take the headset off and let the device go to sleep I get this crash log:
java.lang.RuntimeException: Unable to pause activity {com.greatape.avrgallery/com.greatape.avrgallery.MainActivity}: java.lang.IllegalStateException
at android.app.ActivityThread.performPauseActivityIfNeeded(ActivityThread.java:4137)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4103)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4066)
at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:4024)
at android.app.ActivityThread.-wrap18(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1647)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6692)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
Caused by: java.lang.IllegalStateException
at android.media.MediaPlayer._pause(Native Method)
at android.media.MediaPlayer.pause(MediaPlayer.java:1512)
at org.gearvrf.scene_objects.GVRVideoSceneObject$4.pause(GVRVideoSceneObject.java:520)
at org.gearvrf.scene_objects.GVRVideoSceneObject$1.onPause(GVRVideoSceneObject.java:58)
at java.lang.reflect.Method.invoke(Native Method)
at org.gearvrf.GVREventManager.invokeMethod(GVREventManager.java:307)
at org.gearvrf.GVREventManager.sendEventWithMaskParamArray(GVREventManager.java:147)
at org.gearvrf.GVREventManager.sendEventWithMask(GVREventManager.java:113)
at org.gearvrf.GVRActivity.onPause(GVRActivity.java:192)
at android.app.Activity.performPause(Activity.java:7103)
at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1330)
at android.app.ActivityThread.performPauseActivityIfNeeded(ActivityThread.java:4126)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4103)
at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4066)
at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:4024)
at android.app.ActivityThread.-wrap18(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1647)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6692)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
I/Process: Sending signal. PID: 15566 SIG: 9
This looks like it's because in GVRVideoSceneObject mActivityEventsListener is added as a listener with the following code:
public GVRVideoSceneObject(final GVRContext gvrContext, GVRMesh mesh,
final GVRVideoSceneObjectPlayer mediaPlayer, final GVRExternalTexture texture,
int videoType) {
super(gvrContext, mesh);
GVRShaderId materialType;
gvrVideoSceneObjectPlayer = mediaPlayer;
gvrContext.getActivity().getEventReceiver().addListener(mActivityEventsListener);
But doesn't appear to be removed as a listener anywhere, so presumably will stay listening forever as well causing a memory leak even if it doesn't crash.
GVRVideoSceneObject causes a crash when the phone goes to sleep after removing a GVRVideoSceneObject from the scene.
The video is playing using a MediaPlayer instance inside a GVRVideoSceneObject, when I've finished with my video I've called MediaPlayer release(). I also remove from the scene the GVRVideoSceneObject I was using to play it along with other scene objects it was attached to.
Then when I take the headset off and let the device go to sleep I get this crash log:
This looks like it's because in GVRVideoSceneObject mActivityEventsListener is added as a listener with the following code:
But doesn't appear to be removed as a listener anywhere, so presumably will stay listening forever as well causing a memory leak even if it doesn't crash.