Skip to content

Commit

Permalink
[Books] Returning from Lock Screen shows a flash of missing content
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=267300
<rdar://119957147>

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
  • Loading branch information
mattwoodrow committed Jan 11, 2024
1 parent d07ed3d commit 39ec746
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 15 deletions.
22 changes: 12 additions & 10 deletions Source/WebKit/GPUProcess/graphics/RemoteImageBufferSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,26 +151,28 @@ 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;
}

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<ImageBufferBackendHandleSharing>(*sharing).createBackendHandle();
}

if (m_frontBuffer) {
auto* sharing = m_frontBuffer->toBackendSharing();
outputData.backendHandle = downcast<ImageBufferBackendHandleSharing>(*sharing).createBackendHandle();
}

outputData.bufferCacheIdentifiers = BufferIdentifierSet { bufferIdentifier(m_frontBuffer), bufferIdentifier(m_backBuffer), bufferIdentifier(m_secondaryBackBuffer) };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class RemoteLayerBackingStore : public CanMakeWeakPtr<RemoteLayerBackingStore> {
bool performDelegatedLayerDisplay();

void paintContents();
virtual void prepareToDisplay() = 0;
virtual void createContextAndPaintContents() = 0;

virtual Vector<std::unique_ptr<WebCore::ThreadSafeImageBufferFlusher>> createFlushers() = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@
if (!remoteBackingStore->hasFrontBuffer() || !remoteBackingStore->supportsPartialRepaint())
remoteBackingStore->setNeedsDisplay();

remoteBackingStore->clearBackingStore();

prepareBuffersData.append({
bufferSet,
remoteBackingStore->dirtyRegion(),
Expand All @@ -89,8 +87,9 @@
});

backingStoreList.append(*remoteBackingStore);
} else
downcast<RemoteLayerWithInProcessRenderingBackingStore>(backingStore).prepareToDisplay();
}

backingStore.prepareToDisplay();
}

if (prepareBuffersData.size()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class RemoteLayerWithInProcessRenderingBackingStore : public RemoteLayerBackingS

bool isRemoteLayerWithInProcessRenderingBackingStore() const final { return true; }

void prepareToDisplay();
void prepareToDisplay() final;
void createContextAndPaintContents() final;
Vector<std::unique_ptr<WebCore::ThreadSafeImageBufferFlusher>> createFlushers() final;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class RemoteLayerWithRemoteRenderingBackingStore : public RemoteLayerBackingStor

bool isRemoteLayerWithRemoteRenderingBackingStore() const final { return true; }

void prepareToDisplay() final;
void clearBackingStore() final;
void createContextAndPaintContents() final;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 39ec746

Please sign in to comment.