Skip to content
Permalink
Browse files
[GPUP] Avoid race in GPUP teardown
https://bugs.webkit.org/show_bug.cgi?id=241770

Reviewed by Simon Fraser.

When there's a low memory warning, the GPU process runs GPUProcess::tryExitIfUnused(), which sends a message
to the UI process to kill the GPU process. The Web process notices this, and runs
RemoteRenderingBackendProxy::disconnectGPUProcess(), which doesn't destroy the RemoteRenderingBackendProxy,
but does set it's internal m_gpuProcessConnection to nullptr.

However, we may be in the middle of a rendering update in the web process. If there's a rendering update
pending, WebPage::finalizeRenderingUpdate() runs, which calls finalizeRenderingUpdate() on the
RemoteRenderingBackendProxy if it exists, which then immediately tries to send a stream message to the GPU
process. Sending a message to the GPU process of course runs ensureGPUProcessConnection() to lazily create
the GPU process.

Therefore, if the low memory warning happens in the middle of a rendering update, the GPU process is killed,
but then it is immediately respawned, just to do 0 work and live forever. This is contrary to the point of
killing the GPU process under memory pressure.

This patch changes the logic of RemoteRenderingBackendProxy::finalizeRenderingUpdate() to avoid restarting
the GPU Process if the connection to it is destroyed. Philosophically, it doesn't make much sense for the
_finalization_ routine of a rendering update to start up the whole GPU process. If we're in the middle of an
animation or something, the GPU process probably won't get killed (because it isn't idle), but even if it does,
the next frame of the animation will start up the GPU process again. This patch just modifies the behavior of
the finalization routine.

I hit this when working on #1464. With this patch applied, the failure
rate of GPUProcess.ExitsUnderMemoryPressureCanvasCase goes from 60% to 0%.

Test: GPUProcess.ExitsUnderMemoryPressureCanvasCase

* Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp:
(WebKit::RemoteRenderingBackendProxy::finalizeRenderingUpdate):

Canonical link: https://commits.webkit.org/251740@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@295735 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
litherum committed Jun 22, 2022
1 parent 5c114d9 commit 9aee8cb5b776bd2915cdf948d87cb38feae3ff28
Showing 1 changed file with 2 additions and 0 deletions.
@@ -396,6 +396,8 @@ void RemoteRenderingBackendProxy::didMarkLayersAsVolatile(MarkSurfacesAsVolatile

void RemoteRenderingBackendProxy::finalizeRenderingUpdate()
{
if (!m_gpuProcessConnection)
return;
sendToStream(Messages::RemoteRenderingBackend::FinalizeRenderingUpdate(m_renderingUpdateID));
m_remoteResourceCacheProxy.finalizeRenderingUpdate();
m_renderingUpdateID.increment();

0 comments on commit 9aee8cb

Please sign in to comment.