Bug 1510058 - Work around mWidget becoming null during DidComposite, and add a diagnostic assert that will hopefully root out the culprit. r=jrmuizel

Differential Revision: https://phabricator.services.mozilla.com/D13309

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Markus Stange 2018-11-29 17:48:43 +00:00
Родитель f0bf48464f
Коммит 2e2c28e9f6
2 изменённых файлов: 15 добавлений и 3 удалений

Просмотреть файл

@ -58,6 +58,7 @@ ClientLayerManager::ClientLayerManager(nsIWidget* aWidget)
, mCompositorMightResample(false)
, mNeedsComposite(false)
, mQueuedAsyncPaints(false)
, mNotifyingWidgetListener(false)
, mPaintSequenceNumber(0)
, mForwarder(new ShadowLayerForwarder(this))
{
@ -85,6 +86,9 @@ ClientLayerManager::~ClientLayerManager()
void
ClientLayerManager::Destroy()
{
MOZ_DIAGNOSTIC_ASSERT(!mNotifyingWidgetListener,
"Try to avoid destroying widgets and layer managers during DidCompositeWindow, if you can");
// It's important to call ClearCachedResource before Destroy because the
// former will early-return if the later has already run.
ClearCachedResources();
@ -495,12 +499,19 @@ ClientLayerManager::DidComposite(TransactionId aTransactionId,
if (aTransactionId.IsValid()) {
nsIWidgetListener *listener = mWidget->GetWidgetListener();
if (listener) {
mNotifyingWidgetListener = true;
listener->DidCompositeWindow(aTransactionId, aCompositeStart, aCompositeEnd);
mNotifyingWidgetListener = false;
}
// DidCompositeWindow might have called Destroy on us and nulled out mWidget,
// see bug 1510058.
// Re-check it here.
if (mWidget) {
listener = mWidget->GetAttachedWidgetListener();
if (listener) {
listener->DidCompositeWindow(aTransactionId, aCompositeStart, aCompositeEnd);
}
}
if (mTransactionIdAllocator) {
mTransactionIdAllocator->NotifyTransactionCompleted(aTransactionId);
}

Просмотреть файл

@ -327,6 +327,7 @@ private:
bool mCompositorMightResample;
bool mNeedsComposite;
bool mQueuedAsyncPaints;
bool mNotifyingWidgetListener;
// An incrementing sequence number for paints.
// Incremented in BeginTransaction(), but not for repeat transactions.