diff --git a/app/src/noapi/java/org/mozilla/vrbrowser/PlatformActivity.java b/app/src/noapi/java/org/mozilla/vrbrowser/PlatformActivity.java index 5b311c06f..bf8d06b46 100644 --- a/app/src/noapi/java/org/mozilla/vrbrowser/PlatformActivity.java +++ b/app/src/noapi/java/org/mozilla/vrbrowser/PlatformActivity.java @@ -38,17 +38,19 @@ public static boolean filterPermission(final String aPermission) { private int mFrameCount; private long mLastFrameTime = System.currentTimeMillis(); + final Object mRenderLock = new Object(); + private final Runnable activityDestroyedRunnable = () -> { - synchronized (this) { + synchronized (mRenderLock) { activityDestroyed(); - notifyAll(); + mRenderLock.notifyAll(); } }; private final Runnable activityPausedRunnable = () -> { - synchronized (this) { + synchronized (mRenderLock) { activityPaused(); - notifyAll(); + mRenderLock.notifyAll(); } }; @@ -145,10 +147,10 @@ public boolean onGenericMotionEvent(MotionEvent aEvent) { @Override protected void onPause() { Log.d(LOGTAG, "PlatformActivity onPause"); - synchronized (activityPausedRunnable) { + synchronized (mRenderLock) { queueRunnable(activityPausedRunnable); try { - activityPausedRunnable.wait(); + mRenderLock.wait(); } catch(InterruptedException e) { Log.e(LOGTAG, "activityPausedRunnable interrupted: " + e.toString()); }