Bug 1633453 - Clear display item cache when the display list send fails or WR backend changes r=jrmuizel

Differential Revision: https://phabricator.services.mozilla.com/D72692
This commit is contained in:
Miko Mynttinen
2020-04-29 02:26:08 +00:00
parent 31fcc37da3
commit ab9a0ed1a1
5 changed files with 24 additions and 12 deletions

View File

@@ -72,7 +72,7 @@ void DisplayItemCache::UpdateState() {
// Clear the cache if the current state is invalid. // Clear the cache if the current state is invalid.
if (mInvalid) { if (mInvalid) {
ClearCache(); Clear();
} else { } else {
FreeUnusedSlots(); FreeUnusedSlots();
} }
@@ -80,7 +80,7 @@ void DisplayItemCache::UpdateState() {
mInvalid = false; mInvalid = false;
} }
void DisplayItemCache::ClearCache() { void DisplayItemCache::Clear() {
memset(mSlots.Elements(), 0, mSlots.Length() * sizeof(Slot)); memset(mSlots.Elements(), 0, mSlots.Length() * sizeof(Slot));
mFreeSlots.ClearAndRetainStorage(); mFreeSlots.ClearAndRetainStorage();
@@ -132,7 +132,7 @@ void DisplayItemCache::SetCapacity(const size_t aInitialSize,
mSlots.SetCapacity(aMaximumSize); mSlots.SetCapacity(aMaximumSize);
mSlots.SetLength(aInitialSize); mSlots.SetLength(aInitialSize);
mFreeSlots.SetCapacity(aMaximumSize); mFreeSlots.SetCapacity(aMaximumSize);
ClearCache(); Clear();
} }
Maybe<uint16_t> DisplayItemCache::AssignSlot(nsPaintedDisplayItem* aItem) { Maybe<uint16_t> DisplayItemCache::AssignSlot(nsPaintedDisplayItem* aItem) {

View File

@@ -65,6 +65,11 @@ class DisplayItemCache final {
public: public:
DisplayItemCache(); DisplayItemCache();
/**
* Clears the cache.
*/
void Clear();
/** /**
* Sets the initial and max cache size to given |aInitialSize| and |aMaxSize|. * Sets the initial and max cache size to given |aInitialSize| and |aMaxSize|.
*/ */
@@ -142,7 +147,6 @@ class DisplayItemCache final {
bool mUsed; bool mUsed;
}; };
void ClearCache();
void FreeUnusedSlots(); void FreeUnusedSlots();
Maybe<uint16_t> GetNextFreeSlot(); Maybe<uint16_t> GetNextFreeSlot();
bool GrowIfPossible(); bool GrowIfPossible();

View File

@@ -104,7 +104,7 @@ void WebRenderBridgeChild::UpdateResources(
std::move(largeShmems), aRenderRoot); std::move(largeShmems), aRenderRoot);
} }
void WebRenderBridgeChild::EndTransaction( bool WebRenderBridgeChild::EndTransaction(
nsTArray<RenderRootDisplayListData>& aRenderRoots, nsTArray<RenderRootDisplayListData>& aRenderRoots,
TransactionId aTransactionId, bool aContainsSVGGroup, TransactionId aTransactionId, bool aContainsSVGGroup,
const mozilla::VsyncId& aVsyncId, const mozilla::TimeStamp& aVsyncStartTime, const mozilla::VsyncId& aVsyncId, const mozilla::TimeStamp& aVsyncStartTime,
@@ -127,7 +127,7 @@ void WebRenderBridgeChild::EndTransaction(
} }
mSentDisplayList = true; mSentDisplayList = true;
this->SendSetDisplayList( bool ret = this->SendSetDisplayList(
std::move(aRenderRoots), mDestroyedActors, GetFwdTransactionId(), std::move(aRenderRoots), mDestroyedActors, GetFwdTransactionId(),
aTransactionId, aContainsSVGGroup, aVsyncId, aVsyncStartTime, aTransactionId, aContainsSVGGroup, aVsyncId, aVsyncStartTime,
aRefreshStartTime, aTxnStartTime, aTxnURL, fwdTime, payloads); aRefreshStartTime, aTxnStartTime, aTxnURL, fwdTime, payloads);
@@ -138,6 +138,8 @@ void WebRenderBridgeChild::EndTransaction(
ProcessWebRenderParentCommands(); ProcessWebRenderParentCommands();
mDestroyedActors.Clear(); mDestroyedActors.Clear();
mIsInTransaction = false; mIsInTransaction = false;
return ret;
} }
void WebRenderBridgeChild::EndEmptyTransaction( void WebRenderBridgeChild::EndEmptyTransaction(

View File

@@ -73,7 +73,7 @@ class WebRenderBridgeChild final : public PWebRenderBridgeChild,
void UpdateResources(wr::IpcResourceUpdateQueue& aResources, void UpdateResources(wr::IpcResourceUpdateQueue& aResources,
wr::RenderRoot aRenderRoot); wr::RenderRoot aRenderRoot);
void BeginTransaction(); void BeginTransaction();
void EndTransaction(nsTArray<RenderRootDisplayListData>& aRenderRoots, bool EndTransaction(nsTArray<RenderRootDisplayListData>& aRenderRoots,
TransactionId aTransactionId, bool aContainsSVGroup, TransactionId aTransactionId, bool aContainsSVGroup,
const mozilla::VsyncId& aVsyncId, const mozilla::VsyncId& aVsyncId,
const mozilla::TimeStamp& aVsyncStartTime, const mozilla::TimeStamp& aVsyncStartTime,

View File

@@ -433,11 +433,16 @@ void WebRenderLayerManager::EndTransactionWithoutLayer(
renderRootDL->mScrollData.emplace(std::move(mScrollData)); renderRootDL->mScrollData.emplace(std::move(mScrollData));
} }
WrBridge()->EndTransaction(renderRootDLs, mLatestTransactionId, bool ret = WrBridge()->EndTransaction(
containsSVGGroup, renderRootDLs, mLatestTransactionId, containsSVGGroup,
mTransactionIdAllocator->GetVsyncId(), mTransactionIdAllocator->GetVsyncId(),
mTransactionIdAllocator->GetVsyncStart(), mTransactionIdAllocator->GetVsyncStart(), refreshStart,
refreshStart, mTransactionStart, mURL); mTransactionStart, mURL);
if (!ret) {
// Failed to send display list, reset display item cache state.
mDisplayItemCache.Clear();
}
WrBridge()->SendSetFocusTarget(mFocusTarget); WrBridge()->SendSetFocusTarget(mFocusTarget);
mFocusTarget = FocusTarget(); mFocusTarget = FocusTarget();
} }
@@ -615,6 +620,7 @@ void WebRenderLayerManager::WrUpdated() {
ClearAsyncAnimations(); ClearAsyncAnimations();
mWebRenderCommandBuilder.ClearCachedResources(); mWebRenderCommandBuilder.ClearCachedResources();
DiscardLocalImages(); DiscardLocalImages();
mDisplayItemCache.Clear();
if (mWidget) { if (mWidget) {
if (dom::BrowserChild* browserChild = mWidget->GetOwningBrowserChild()) { if (dom::BrowserChild* browserChild = mWidget->GetOwningBrowserChild()) {