From 01b1e6af97a447cfd561c4a89c49bf2e475d08e2 Mon Sep 17 00:00:00 2001 From: Nicolas Silva Date: Tue, 15 Sep 2015 17:58:06 +0200 Subject: [PATCH] Bug 1156182 - Prevent widgets from creating a LayerManager during shutdown. r=sotaro --- widget/gtk/nsWindow.cpp | 5 +++++ widget/nsBaseWidget.cpp | 4 ++++ 2 files changed, 9 insertions(+) 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