From 39ec746c46ceb11d77d4f0f65be943905484289c Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Thu, 11 Jan 2024 12:15:19 -0800 Subject: [PATCH] [Books] Returning from Lock Screen shows a flash of missing content https://bugs.webkit.org/show_bug.cgi?id=267300 Reviewed by Simon Fraser. If we've included an ImageBufferSet with an empty dirty region in the prepare for display set, then we always need to return a valid buffer handle. This happens when we think the front buffer is volatile (as happens when the screen is locked), and we want to confirm that the contents are still there. If they are, no drawing is needed, but we still need to update the buffer handle. * Source/WebKit/GPUProcess/graphics/RemoteImageBufferSet.cpp: (WebKit::RemoteImageBufferSet::ensureBufferForDisplay): * Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h: * Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.mm: (WebKit::RemoteLayerBackingStoreCollection::prepareBackingStoresForDisplay): * Source/WebKit/Shared/RemoteLayerTree/RemoteLayerWithInProcessRenderingBackingStore.h: * Source/WebKit/Shared/RemoteLayerTree/RemoteLayerWithRemoteRenderingBackingStore.h: * Source/WebKit/Shared/RemoteLayerTree/RemoteLayerWithRemoteRenderingBackingStore.mm: (WebKit::RemoteLayerWithRemoteRenderingBackingStore::prepareToDisplay): Canonical link: https://commits.webkit.org/272932@main --- .../graphics/RemoteImageBufferSet.cpp | 22 ++++++++++--------- .../RemoteLayerTree/RemoteLayerBackingStore.h | 1 + .../RemoteLayerBackingStoreCollection.mm | 7 +++--- ...eLayerWithInProcessRenderingBackingStore.h | 2 +- ...moteLayerWithRemoteRenderingBackingStore.h | 1 + ...oteLayerWithRemoteRenderingBackingStore.mm | 5 +++++ 6 files changed, 23 insertions(+), 15 deletions(-) diff --git a/Source/WebKit/GPUProcess/graphics/RemoteImageBufferSet.cpp b/Source/WebKit/GPUProcess/graphics/RemoteImageBufferSet.cpp index e2df6637ad01..d46db5359b8a 100644 --- a/Source/WebKit/GPUProcess/graphics/RemoteImageBufferSet.cpp +++ b/Source/WebKit/GPUProcess/graphics/RemoteImageBufferSet.cpp @@ -151,13 +151,15 @@ void RemoteImageBufferSet::ensureBufferForDisplay(ImageBufferSetPrepareBufferFor outputData.displayRequirement = needsFullDisplay ? SwapBuffersDisplayRequirement::NeedsFullDisplay : SwapBuffersDisplayRequirement::NeedsNormalDisplay; std::swap(m_frontBuffer, m_backBuffer); + + if (m_frontBuffer) { + auto previousState = m_frontBuffer->setNonVolatile(); + if (previousState == SetNonVolatileResult::Empty) + m_previouslyPaintedRect = std::nullopt; + } } - if (m_frontBuffer) { - auto previousState = m_frontBuffer->setNonVolatile(); - if (previousState == SetNonVolatileResult::Empty) - m_previouslyPaintedRect = std::nullopt; - } else { + if (!m_frontBuffer) { m_frontBuffer = m_backend->allocateImageBuffer(m_logicalSize, m_renderingMode, WebCore::RenderingPurpose::LayerBacking, m_resolutionScale, m_colorSpace, m_pixelFormat, RenderingResourceIdentifier::generate()); m_frontBufferIsCleared = true; } @@ -165,12 +167,12 @@ void RemoteImageBufferSet::ensureBufferForDisplay(ImageBufferSetPrepareBufferFor LOG_WITH_STREAM(RemoteLayerBuffers, stream << "GPU Process: ensureFrontBufferForDisplay - swapped to [" << m_frontBuffer << ", " << m_backBuffer << ", " << m_secondaryBackBuffer << "]"); - if (outputData.displayRequirement != SwapBuffersDisplayRequirement::NeedsNoDisplay) { + if (outputData.displayRequirement != SwapBuffersDisplayRequirement::NeedsNoDisplay) m_backend->createDisplayListRecorder(m_frontBuffer, m_displayListIdentifier); - if (m_frontBuffer) { - auto* sharing = m_frontBuffer->toBackendSharing(); - outputData.backendHandle = downcast(*sharing).createBackendHandle(); - } + + if (m_frontBuffer) { + auto* sharing = m_frontBuffer->toBackendSharing(); + outputData.backendHandle = downcast(*sharing).createBackendHandle(); } outputData.bufferCacheIdentifiers = BufferIdentifierSet { bufferIdentifier(m_frontBuffer), bufferIdentifier(m_backBuffer), bufferIdentifier(m_secondaryBackBuffer) }; diff --git a/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h b/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h index 97ae3bf40208..08f811898b4a 100644 --- a/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h +++ b/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStore.h @@ -112,6 +112,7 @@ class RemoteLayerBackingStore : public CanMakeWeakPtr { bool performDelegatedLayerDisplay(); void paintContents(); + virtual void prepareToDisplay() = 0; virtual void createContextAndPaintContents() = 0; virtual Vector> createFlushers() = 0; diff --git a/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.mm b/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.mm index 61f209cf2f21..bf4b036e3c59 100644 --- a/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.mm +++ b/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerBackingStoreCollection.mm @@ -78,8 +78,6 @@ if (!remoteBackingStore->hasFrontBuffer() || !remoteBackingStore->supportsPartialRepaint()) remoteBackingStore->setNeedsDisplay(); - remoteBackingStore->clearBackingStore(); - prepareBuffersData.append({ bufferSet, remoteBackingStore->dirtyRegion(), @@ -89,8 +87,9 @@ }); backingStoreList.append(*remoteBackingStore); - } else - downcast(backingStore).prepareToDisplay(); + } + + backingStore.prepareToDisplay(); } if (prepareBuffersData.size()) { diff --git a/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerWithInProcessRenderingBackingStore.h b/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerWithInProcessRenderingBackingStore.h index 4c158e0c9f79..130356cca539 100644 --- a/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerWithInProcessRenderingBackingStore.h +++ b/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerWithInProcessRenderingBackingStore.h @@ -35,7 +35,7 @@ class RemoteLayerWithInProcessRenderingBackingStore : public RemoteLayerBackingS bool isRemoteLayerWithInProcessRenderingBackingStore() const final { return true; } - void prepareToDisplay(); + void prepareToDisplay() final; void createContextAndPaintContents() final; Vector> createFlushers() final; diff --git a/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerWithRemoteRenderingBackingStore.h b/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerWithRemoteRenderingBackingStore.h index d3142e4985d2..902852225b80 100644 --- a/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerWithRemoteRenderingBackingStore.h +++ b/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerWithRemoteRenderingBackingStore.h @@ -38,6 +38,7 @@ class RemoteLayerWithRemoteRenderingBackingStore : public RemoteLayerBackingStor bool isRemoteLayerWithRemoteRenderingBackingStore() const final { return true; } + void prepareToDisplay() final; void clearBackingStore() final; void createContextAndPaintContents() final; diff --git a/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerWithRemoteRenderingBackingStore.mm b/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerWithRemoteRenderingBackingStore.mm index bd8bc5cf93a5..2ce03dcfecf1 100644 --- a/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerWithRemoteRenderingBackingStore.mm +++ b/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerWithRemoteRenderingBackingStore.mm @@ -62,6 +62,11 @@ return m_bufferSet->requestedVolatility().contains(BufferInSetType::Front); } +void RemoteLayerWithRemoteRenderingBackingStore::prepareToDisplay() +{ + m_contentsBufferHandle = std::nullopt; +} + void RemoteLayerWithRemoteRenderingBackingStore::clearBackingStore() { m_contentsBufferHandle = std::nullopt;