Title: [295735] trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp
Revision
295735
Author
mmaxfi...@apple.com
Date
2022-06-22 10:13:56 -0700 (Wed, 22 Jun 2022)

Log Message

[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 https://github.com/WebKit/WebKit/pull/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

Modified Paths

Diff

Modified: trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp (295734 => 295735)


--- trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp	2022-06-22 17:11:51 UTC (rev 295734)
+++ trunk/Source/WebKit/WebProcess/GPU/graphics/RemoteRenderingBackendProxy.cpp	2022-06-22 17:13:56 UTC (rev 295735)
@@ -396,6 +396,8 @@
 
 void RemoteRenderingBackendProxy::finalizeRenderingUpdate()
 {
+    if (!m_gpuProcessConnection)
+        return;
     sendToStream(Messages::RemoteRenderingBackend::FinalizeRenderingUpdate(m_renderingUpdateID));
     m_remoteResourceCacheProxy.finalizeRenderingUpdate();
     m_renderingUpdateID.increment();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to