diff --git a/gfx/layers/wr/DisplayItemCache.cpp b/gfx/layers/wr/DisplayItemCache.cpp index f855d5858a49..67803b02df52 100644 --- a/gfx/layers/wr/DisplayItemCache.cpp +++ b/gfx/layers/wr/DisplayItemCache.cpp @@ -72,7 +72,7 @@ void DisplayItemCache::UpdateState() { // Clear the cache if the current state is invalid. if (mInvalid) { - ClearCache(); + Clear(); } else { FreeUnusedSlots(); } @@ -80,7 +80,7 @@ void DisplayItemCache::UpdateState() { mInvalid = false; } -void DisplayItemCache::ClearCache() { +void DisplayItemCache::Clear() { memset(mSlots.Elements(), 0, mSlots.Length() * sizeof(Slot)); mFreeSlots.ClearAndRetainStorage(); @@ -132,7 +132,7 @@ void DisplayItemCache::SetCapacity(const size_t aInitialSize, mSlots.SetCapacity(aMaximumSize); mSlots.SetLength(aInitialSize); mFreeSlots.SetCapacity(aMaximumSize); - ClearCache(); + Clear(); } Maybe DisplayItemCache::AssignSlot(nsPaintedDisplayItem* aItem) { diff --git a/gfx/layers/wr/DisplayItemCache.h b/gfx/layers/wr/DisplayItemCache.h index f7f12f70b366..7dc5eef0fb4d 100644 --- a/gfx/layers/wr/DisplayItemCache.h +++ b/gfx/layers/wr/DisplayItemCache.h @@ -65,6 +65,11 @@ class DisplayItemCache final { public: DisplayItemCache(); + /** + * Clears the cache. + */ + void Clear(); + /** * Sets the initial and max cache size to given |aInitialSize| and |aMaxSize|. */ @@ -142,7 +147,6 @@ class DisplayItemCache final { bool mUsed; }; - void ClearCache(); void FreeUnusedSlots(); Maybe GetNextFreeSlot(); bool GrowIfPossible(); diff --git a/gfx/layers/wr/WebRenderBridgeChild.cpp b/gfx/layers/wr/WebRenderBridgeChild.cpp index a5ed4e4378b1..0343353e2679 100644 --- a/gfx/layers/wr/WebRenderBridgeChild.cpp +++ b/gfx/layers/wr/WebRenderBridgeChild.cpp @@ -104,7 +104,7 @@ void WebRenderBridgeChild::UpdateResources( std::move(largeShmems), aRenderRoot); } -void WebRenderBridgeChild::EndTransaction( +bool WebRenderBridgeChild::EndTransaction( nsTArray& aRenderRoots, TransactionId aTransactionId, bool aContainsSVGGroup, const mozilla::VsyncId& aVsyncId, const mozilla::TimeStamp& aVsyncStartTime, @@ -127,7 +127,7 @@ void WebRenderBridgeChild::EndTransaction( } mSentDisplayList = true; - this->SendSetDisplayList( + bool ret = this->SendSetDisplayList( std::move(aRenderRoots), mDestroyedActors, GetFwdTransactionId(), aTransactionId, aContainsSVGGroup, aVsyncId, aVsyncStartTime, aRefreshStartTime, aTxnStartTime, aTxnURL, fwdTime, payloads); @@ -138,6 +138,8 @@ void WebRenderBridgeChild::EndTransaction( ProcessWebRenderParentCommands(); mDestroyedActors.Clear(); mIsInTransaction = false; + + return ret; } void WebRenderBridgeChild::EndEmptyTransaction( diff --git a/gfx/layers/wr/WebRenderBridgeChild.h b/gfx/layers/wr/WebRenderBridgeChild.h index 8a8f464c69a1..d4b5e8516781 100644 --- a/gfx/layers/wr/WebRenderBridgeChild.h +++ b/gfx/layers/wr/WebRenderBridgeChild.h @@ -73,7 +73,7 @@ class WebRenderBridgeChild final : public PWebRenderBridgeChild, void UpdateResources(wr::IpcResourceUpdateQueue& aResources, wr::RenderRoot aRenderRoot); void BeginTransaction(); - void EndTransaction(nsTArray& aRenderRoots, + bool EndTransaction(nsTArray& aRenderRoots, TransactionId aTransactionId, bool aContainsSVGroup, const mozilla::VsyncId& aVsyncId, const mozilla::TimeStamp& aVsyncStartTime, diff --git a/gfx/layers/wr/WebRenderLayerManager.cpp b/gfx/layers/wr/WebRenderLayerManager.cpp index dce4151f310d..68d3f7122645 100644 --- a/gfx/layers/wr/WebRenderLayerManager.cpp +++ b/gfx/layers/wr/WebRenderLayerManager.cpp @@ -433,11 +433,16 @@ void WebRenderLayerManager::EndTransactionWithoutLayer( renderRootDL->mScrollData.emplace(std::move(mScrollData)); } - WrBridge()->EndTransaction(renderRootDLs, mLatestTransactionId, - containsSVGGroup, - mTransactionIdAllocator->GetVsyncId(), - mTransactionIdAllocator->GetVsyncStart(), - refreshStart, mTransactionStart, mURL); + bool ret = WrBridge()->EndTransaction( + renderRootDLs, mLatestTransactionId, containsSVGGroup, + mTransactionIdAllocator->GetVsyncId(), + mTransactionIdAllocator->GetVsyncStart(), refreshStart, + mTransactionStart, mURL); + if (!ret) { + // Failed to send display list, reset display item cache state. + mDisplayItemCache.Clear(); + } + WrBridge()->SendSetFocusTarget(mFocusTarget); mFocusTarget = FocusTarget(); } @@ -615,6 +620,7 @@ void WebRenderLayerManager::WrUpdated() { ClearAsyncAnimations(); mWebRenderCommandBuilder.ClearCachedResources(); DiscardLocalImages(); + mDisplayItemCache.Clear(); if (mWidget) { if (dom::BrowserChild* browserChild = mWidget->GetOwningBrowserChild()) {