Title: [293562] trunk/Source/WebKit/UIProcess
Revision
293562
Author
cdu...@apple.com
Date
2022-04-27 21:09:34 -0700 (Wed, 27 Apr 2022)

Log Message

GPUProcess doesn't get notified of imminent process suspension
https://bugs.webkit.org/show_bug.cgi?id=239815

Reviewed by Tim Horton.

By defaults, ProcessThrottler in the UIProcess use a ProcessAndUIAssertion instance internally,
instead of a simple ProcessAssertion. This makes sure that a process assertion is taken on
behalf of the UIProcess as well, not just the child process. This also makes sure that when
the UIProcess has been in the background for too long and its assertion gets invalidated, we
release all ProcessAndUIAssertion instances as well.

The WebProcess and NetworkProcess were correctly using a ProcessAndUIAssertion. However, the
GPUProcess was passing `false` when constructing the ProcessThrottler, causing it to use a
simple ProcessAssertion. As a result, the GPUProcess would not get notified on imminent
suspension when the app has been running in the background for too long.

This patch aligns the behavior of the GPUProcess with the one of the NetworkProcess since
both processes are very similar.

* Source/WebKit/UIProcess/GPU/GPUProcessProxy.cpp:
(WebKit::GPUProcessProxy::GPUProcessProxy):
* Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::NetworkProcessProxy):
(WebKit::anyProcessPoolShouldTakeUIBackgroundAssertion): Deleted.
* Source/WebKit/UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::anyProcessPoolNeedsUIBackgroundAssertion):
* Source/WebKit/UIProcess/WebProcessPool.h:

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

Modified Paths

Diff

Modified: trunk/Source/WebKit/UIProcess/GPU/GPUProcessProxy.cpp (293561 => 293562)


--- trunk/Source/WebKit/UIProcess/GPU/GPUProcessProxy.cpp	2022-04-28 04:03:12 UTC (rev 293561)
+++ trunk/Source/WebKit/UIProcess/GPU/GPUProcessProxy.cpp	2022-04-28 04:09:34 UTC (rev 293562)
@@ -130,7 +130,7 @@
 
 GPUProcessProxy::GPUProcessProxy()
     : AuxiliaryProcessProxy()
-    , m_throttler(*this, false)
+    , m_throttler(*this, WebProcessPool::anyProcessPoolNeedsUIBackgroundAssertion())
 #if ENABLE(MEDIA_STREAM)
     , m_useMockCaptureDevices(MockRealtimeMediaSourceCenter::mockRealtimeMediaSourceCenterEnabled())
 #endif

Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (293561 => 293562)


--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2022-04-28 04:03:12 UTC (rev 293561)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2022-04-28 04:09:34 UTC (rev 293562)
@@ -230,15 +230,6 @@
     return false;
 }
 
-static bool anyProcessPoolShouldTakeUIBackgroundAssertion()
-{
-    for (auto& processPool : WebProcessPool::allProcessPools()) {
-        if (processPool->shouldTakeUIBackgroundAssertion())
-            return true;
-    }
-    return false;
-}
-
 NetworkProcessProxy::NetworkProcessProxy()
     : AuxiliaryProcessProxy(anyProcessPoolAlwaysRunsAtBackgroundPriority(), networkProcessResponsivenessTimeout)
 #if ENABLE(LEGACY_CUSTOM_PROTOCOL_MANAGER)
@@ -247,7 +238,7 @@
 #else
     , m_customProtocolManagerClient(makeUniqueRef<API::CustomProtocolManagerClient>())
 #endif
-    , m_throttler(*this, anyProcessPoolShouldTakeUIBackgroundAssertion())
+    , m_throttler(*this, WebProcessPool::anyProcessPoolNeedsUIBackgroundAssertion())
     , m_cookieManager(makeUniqueRef<WebCookieManagerProxy>(*this))
 {
     connect();

Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (293561 => 293562)


--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2022-04-28 04:03:12 UTC (rev 293561)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2022-04-28 04:09:34 UTC (rev 293562)
@@ -2166,6 +2166,15 @@
         processPool->terminateServiceWorkers();
 }
 
+bool WebProcessPool::anyProcessPoolNeedsUIBackgroundAssertion()
+{
+    for (auto& processPool : WebProcessPool::allProcessPools()) {
+        if (processPool->shouldTakeUIBackgroundAssertion())
+            return true;
+    }
+    return false;
+}
+
 #if ENABLE(SERVICE_WORKER)
 size_t WebProcessPool::serviceWorkerProxiesCount() const
 {

Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.h (293561 => 293562)


--- trunk/Source/WebKit/UIProcess/WebProcessPool.h	2022-04-28 04:03:12 UTC (rev 293561)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.h	2022-04-28 04:09:34 UTC (rev 293562)
@@ -435,6 +435,7 @@
 
     bool alwaysRunsAtBackgroundPriority() const { return m_alwaysRunsAtBackgroundPriority; }
     bool shouldTakeUIBackgroundAssertion() const { return m_shouldTakeUIBackgroundAssertion; }
+    static bool anyProcessPoolNeedsUIBackgroundAssertion();
 
 #if ENABLE(GAMEPAD)
     void gamepadConnected(const UIGamepad&, WebCore::EventMakesGamepadsVisible);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to