diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp index 17f2a6ee821..5c5639759ff 100644 --- a/widget/gtk/nsWindow.cpp +++ b/widget/gtk/nsWindow.cpp @@ -6542,6 +6542,11 @@ nsWindow::GetLayerManager(PLayerTransactionChild* aShadowManager, LayerManagerPersistence aPersistence, bool* aAllowRetaining) { + if (mIsDestroyed) { + // Prevent external code from triggering the re-creation of the LayerManager/Compositor + // during shutdown. Just return what we currently have, which is most likely null. + return mLayerManager; + } if (!mLayerManager && eTransparencyTransparent == GetTransparencyMode()) { mLayerManager = CreateBasicLayerManager(); } diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index b788cbc6f12..cf40f46c6c6 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -1146,6 +1146,10 @@ LayerManager* nsBaseWidget::GetLayerManager(PLayerTransactionChild* aShadowManag bool* aAllowRetaining) { if (!mLayerManager) { + if (!mShutdownObserver) { + // We are shutting down, do not try to re-create a LayerManager + return nullptr; + } // Try to use an async compositor first, if possible if (ShouldUseOffMainThreadCompositing()) { // e10s uses the parameter to pass in the shadow manager from the TabChild