Bug 1880503 - Ensure compositor reinitialization respects intended paused/resumed state. r=geckoview-reviewers,m_kato

When the Android frontend attempts to pause or resume the compositor
there is a chance this may fail. When this happens, the compositor
will automatically be reinitialized. However, it will currently be
reinitialized in the previous state, not the state the frontend
intended. For example, if the compositor fails to resume then it will
be reinitialized but remain in a paused state, displaying a blank
screen to the user.

To avoid this, we update the value of mCompositorPaused prior to
attempting to pause or resume the compositor. This means when
NotifyCompositorCreated eventually gets called, it knows the correct
state in which to initialize the compositor.

Differential Revision: https://phabricator.services.mozilla.com/D202165
This commit is contained in:
Jamie Nicol 2024-05-14 12:58:35 +00:00
parent 1d7467fe1e
commit 1f35ae62aa

View file

@ -1265,6 +1265,9 @@ class LayerViewSupport final
void SyncPauseCompositor() {
MOZ_ASSERT(AndroidBridge::IsJavaUiThread());
// Set this true prior to attempting to pause the compositor, so that if
// pausing fails the subsequent recovery knows to initialize the compositor
// in a paused state.
mCompositorPaused = true;
if (mUiCompositorControllerChild) {
@ -1299,8 +1302,12 @@ class LayerViewSupport final
void SyncResumeCompositor() {
MOZ_ASSERT(AndroidBridge::IsJavaUiThread());
// Set this false prior to attempting to resume the compositor, so that if
// resumption fails the subsequent recovery knows to initialize the
// compositor in a resumed state.
mCompositorPaused = false;
if (mUiCompositorControllerChild) {
mCompositorPaused = false;
bool resumed = mUiCompositorControllerChild->Resume();
if (!resumed) {
gfxCriticalNote
@ -1316,6 +1323,11 @@ class LayerViewSupport final
jni::Object::Param aSurfaceControl) {
MOZ_ASSERT(AndroidBridge::IsJavaUiThread());
// Set this false prior to attempting to resume the compositor, so that if
// resumption fails the subsequent recovery knows to initialize the
// compositor in a resumed state.
mCompositorPaused = false;
mX = aX;
mY = aY;
mWidth = aWidth;
@ -1362,8 +1374,6 @@ class LayerViewSupport final
mRequestedNewSurface = false;
mCompositorPaused = false;
class OnResumedEvent : public nsAppShell::Event {
GeckoSession::Compositor::GlobalRef mCompositor;