diff --git a/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java b/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java index 649305129..ff5b14ee9 100644 --- a/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java +++ b/app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java @@ -712,21 +712,23 @@ public boolean dispatchKeyEvent(KeyEvent event) { return super.dispatchKeyEvent(event); } + final Object mWaitLock = new Object(); + final Runnable mExitImmersive = new Runnable() { @Override public void run() { exitImmersiveNative(); - synchronized(this) { - this.notifyAll(); + synchronized(mWaitLock) { + mWaitLock.notifyAll(); } } }; private void exitImmersiveSync() { - synchronized (mExitImmersive) { + synchronized (mWaitLock) { queueRunnable(mExitImmersive); try { - mExitImmersive.wait(); + mWaitLock.wait(); } catch (InterruptedException e) { Log.e(LOGTAG, "Waiting for exit immersive onPause interrupted"); } @@ -916,16 +918,18 @@ void registerExternalContext(long aContext) { GeckoVRManager.setExternalContext(aContext); } + final Object mCompositorLock = new Object(); + class PauseCompositorRunnable implements Runnable { public boolean done; @Override public void run() { - synchronized (VRBrowserActivity.this) { + synchronized (mCompositorLock) { Log.d(LOGTAG, "About to pause Compositor"); mWindows.pauseCompositor(); Log.d(LOGTAG, "Compositor Paused"); done = true; - VRBrowserActivity.this.notify(); + mCompositorLock.notify(); } } } @@ -942,11 +946,11 @@ void pauseGeckoViewCompositor() { GleanMetricsService.startImmersive(); PauseCompositorRunnable runnable = new PauseCompositorRunnable(); - synchronized (this) { + synchronized (mCompositorLock) { runOnUiThread(runnable); while (!runnable.done) { try { - this.wait(); + mCompositorLock.wait(); } catch (InterruptedException e) { Log.e(LOGTAG, "Waiting for compositor pause interrupted"); }