Skip to content

Commit

Permalink
Cherry-pick d2f3169. rdar://problem/108642579
Browse files Browse the repository at this point in the history
    RemoteImageBufferProxyFlushState::waitForDidFlushOnSecondaryThread blocks on a task running on the main thread.
    https://bugs.webkit.org/show_bug.cgi?id=256073
    <rdar://108642579>

    Reviewed by Simon Fraser.

    We attempt to wait for flushes of RemoteImageBufferProxy on a background thread, but the 'didFlush' IPC message is received on the main thread.

    This can mean it gets delayed (and we don't know the flush is completed) if the main thread is otherwise busy. This delays first-paint on CPLT.

    This change passes a Semphore across to the GPUP instead of the flush identifier, and we signal it when the flush is completed rather than sending a return 'didFlush' message.
    The WebProcess waits on each flush Semaphore in a background WorkQueue, and then processes the equivalent of 'didFlush' asynchronously and notifies the condition variable to wake any waiting threads.

    waitForDidFlushWithTimeout is removed, and all waiters now use the waitForDidFlushOnSecondaryThread code path (renamed) since all waiters are now 'secondary' WRT the flushing WorkQueue.

    Synchronous flushes now use a proper synchronous IPC message, rather than relying on async + wait.

    Adds a 0-delay asynchronous callOnMainThread hop when triggering the rendering update from RemoteLaterTreeDisplayRefreshMonitor::requestRefreshCallback.
    It appears that when doing the first requestRefreshCallback after idle, we currently just trigger a rendering update immediately, rather than waiting for displayDidRefresh. This differs
    from the non-GPUP code.
    This 0-delay step makes our behaviour more similar to the old code, but adding a proper displayDidRefresh wait would be preferable in the longer term.

    * Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.cpp:
    (WebKit::RemoteDisplayListRecorder::flushContext):
    (WebKit::RemoteDisplayListRecorder::flushContextSync):
    * Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.h:
    * Source/WebKit/GPUProcess/graphics/RemoteDisplayListRecorder.messages.in:
    * Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.cpp:
    (WebKit::RemoteRenderingBackend::didFlush): Deleted.
    * Source/WebKit/GPUProcess/graphics/RemoteRenderingBackend.h:
    * Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.cpp:
    (WebKit::RemoteDisplayListRecorderProxy::sendSync):
    (WebKit::RemoteDisplayListRecorderProxy::flushContext):
    (WebKit::RemoteDisplayListRecorderProxy::flushContextSync):
    * Source/WebKit/WebProcess/GPU/graphics/RemoteDisplayListRecorderProxy.h:
    * Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.cpp:
    (WebKit::RemoteImageBufferProxy::flushDrawingContext):
    (WebKit::RemoteImageBufferProxy::flushDrawingContextAsync):
    (WebKit::RemoteImageBufferProxyFlushState::waitForDidFlush):
    (WebKit::RemoteImageBufferProxy::waitForDidFlushWithTimeout): Deleted.
    (WebKit::RemoteImageBufferProxyFlushState::waitForDidFlushOnSecondaryThread): Deleted.
    * Source/WebKit/WebProcess/GPU/graphics/RemoteImageBufferProxy.h:
    * Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp:
    (WebKit::RemoteRenderingBackendProxy::RemoteRenderingBackendProxy):
    (WebKit::RemoteRenderingBackendProxy::disconnectGPUProcess):
    (WebKit::RemoteRenderingBackendProxy::addPendingFlush):
    (WebKit::RemoteRenderingBackendProxy::waitForDidFlush): Deleted.
    (WebKit::RemoteRenderingBackendProxy::didFlush): Deleted.
    * Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.h:
    * Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.messages.in:
    * Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDisplayRefreshMonitor.mm:
    (WebKit::RemoteLayerTreeDisplayRefreshMonitor::requestRefreshCallback):

    Canonical link: https://commits.webkit.org/263993@main

Identifier: 263769.57@safari-7616.1.14.11-branch
  • Loading branch information
mattwoodrow authored and Dan Robson committed May 22, 2023
1 parent 59318f8 commit 74158dd
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@
return true;

LOG_WITH_STREAM(DisplayLink, stream << "[Web] RemoteLayerTreeDisplayRefreshMonitor::requestRefreshCallback - triggering update");
static_cast<DrawingArea&>(*m_drawingArea.get()).triggerRenderingUpdate();
callOnMainRunLoop([self = Ref { *this }, this] () {
if (m_drawingArea)
static_cast<DrawingArea&>(*m_drawingArea.get()).triggerRenderingUpdate();
});

setIsScheduled(true);
return true;
Expand Down

0 comments on commit 74158dd

Please sign in to comment.