Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Ensure fullscreen and immersive VR video is exited on pause (#3182)
Browse files Browse the repository at this point in the history
Fixes #3154

Previously if the content process was killed or crashed while the
application was paused, the windows would still be in fullscreen
and/or immersive VR video mode while the recreated GeckoSession
would not. This partially fixes the issue by ensuring fullscreen
and VR immersive video is exited on pause so the windows do not
get into a bad state if the crash/kills while the application is
backgrounded.
  • Loading branch information
bluemarvin authored Apr 17, 2020
1 parent ca8257d commit e9e0682
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
17 changes: 17 additions & 0 deletions app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -417,13 +417,30 @@ protected void onStop() {
GleanMetricsService.sessionStop();
}

public void flushBackHandlers() {
int backCount = mBackHandlers.size();
while (backCount > 0) {
mBackHandlers.getLast().run();
int newBackCount = mBackHandlers.size();
if (newBackCount == backCount) {
Log.e(LOGTAG, "Back counter is not decreasing,");
break;
}
backCount = newBackCount;
}
}

@Override
protected void onPause() {
if (mIsPresentingImmersive) {
// This needs to be sync to ensure that WebVR is correctly paused.
// Also prevents a deadlock in onDestroy when the BrowserWidget is released.
exitImmersiveSync();
}
// If we are in fullscreen or immersive VR video, we need to consume their back handlers
// before pausing to prevent the windows from getting stuck in fullscreen mode.
flushBackHandlers();

mAudioEngine.pauseEngine();

mWindows.onPause();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1192,9 +1192,14 @@ public void onContextMenu(@NonNull GeckoSession session, int screenX, int screen

@Override
public void onCrash(@NonNull GeckoSession session) {
Log.e(LOGTAG,"Child crashed. Creating new session");
Log.e(LOGTAG,"Child crashed. Recreating session");
recreateSession();
}

@Override
public void onKill(@NonNull GeckoSession session) {
Log.e(LOGTAG,"Child killed. Recreating session");
recreateSession();
loadUri(getHomeUri());
}

@Override
Expand Down

0 comments on commit e9e0682

Please sign in to comment.