Skip to content

Commit

Permalink
Delay the DidComposite call in ClientLayerManager's destructor. (bug …
Browse files Browse the repository at this point in the history
…1305829, r=mattwoodrow)
  • Loading branch information
David Anderson committed Nov 22, 2016
1 parent 94f694f commit 22b001c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
17 changes: 13 additions & 4 deletions gfx/layers/client/ClientLayerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,6 @@ ClientLayerManager::ClientLayerManager(nsIWidget* aWidget)

ClientLayerManager::~ClientLayerManager()
{
if (mTransactionIdAllocator) {
TimeStamp now = TimeStamp::Now();
DidComposite(mLatestTransactionId, now, now);
}
mMemoryPressureObserver->Destroy();
ClearCachedResources();
// Stop receiveing AsyncParentMessage at Forwarder.
Expand All @@ -137,6 +133,19 @@ ClientLayerManager::Destroy()
// former will early-return if the later has already run.
ClearCachedResources();
LayerManager::Destroy();

if (mTransactionIdAllocator) {
// Make sure to notify the refresh driver just in case it's waiting on a
// pending transaction. Do this at the top of the event loop so we don't
// cause a paint to occur during compositor shutdown.
RefPtr<TransactionIdAllocator> allocator = mTransactionIdAllocator;
uint64_t id = mLatestTransactionId;

RefPtr<Runnable> task = NS_NewRunnableFunction([allocator, id] () -> void {
allocator->NotifyTransactionCompleted(id);
});
NS_DispatchToMainThread(task.forget());
}
}

int32_t
Expand Down
19 changes: 19 additions & 0 deletions widget/nsBaseWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ WidgetShutdownObserver::Unregister()
void
nsBaseWidget::Shutdown()
{
RevokeTransactionIdAllocator();
DestroyCompositor();
FreeShutdownObserver();
#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
Expand Down Expand Up @@ -295,6 +296,23 @@ void nsBaseWidget::DestroyCompositor()
}
}

// This prevents the layer manager from starting a new transaction during
// shutdown.
void
nsBaseWidget::RevokeTransactionIdAllocator()
{
if (!mLayerManager) {
return;
}

ClientLayerManager* clm = mLayerManager->AsClientLayerManager();
if (!clm) {
return;
}

clm->SetTransactionIdAllocator(nullptr);
}

void nsBaseWidget::ReleaseContentController()
{
if (mRootContentController) {
Expand Down Expand Up @@ -377,6 +395,7 @@ nsBaseWidget::~nsBaseWidget()
}

FreeShutdownObserver();
RevokeTransactionIdAllocator();
DestroyLayerManager();

#ifdef NOISY_WIDGET_LEAKS
Expand Down
1 change: 1 addition & 0 deletions widget/nsBaseWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference
virtual void DestroyCompositor();
void DestroyLayerManager();
void ReleaseContentController();
void RevokeTransactionIdAllocator();

void FreeShutdownObserver();

Expand Down

0 comments on commit 22b001c

Please sign in to comment.