Title: [281199] trunk/Source/WebKit
Revision
281199
Author
sihui_...@apple.com
Date
2021-08-18 10:45:29 -0700 (Wed, 18 Aug 2021)

Log Message

Do not terminate relaunched network process when getting network process connection
https://bugs.webkit.org/show_bug.cgi?id=229236

Reviewed by Chris Dumez.

When UI process fails to get network process connection for the first time, it will retry on next runloop
iteration. On the retry, it terminates existing network process and relaunch a network process, because the
failure may indicate something is wrong in the network process. If existing network process is different from
the one on first try, the existing process can be functional and we should not terminate it.

* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::getNetworkProcessConnection):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (281198 => 281199)


--- trunk/Source/WebKit/ChangeLog	2021-08-18 17:42:30 UTC (rev 281198)
+++ trunk/Source/WebKit/ChangeLog	2021-08-18 17:45:29 UTC (rev 281199)
@@ -1,3 +1,18 @@
+2021-08-18  Sihui Liu  <sihui_...@apple.com>
+
+        Do not terminate relaunched network process when getting network process connection
+        https://bugs.webkit.org/show_bug.cgi?id=229236
+
+        Reviewed by Chris Dumez.
+
+        When UI process fails to get network process connection for the first time, it will retry on next runloop 
+        iteration. On the retry, it terminates existing network process and relaunch a network process, because the 
+        failure may indicate something is wrong in the network process. If existing network process is different from 
+        the one on first try, the existing process can be functional and we should not terminate it.
+
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::getNetworkProcessConnection):
+
 2021-08-18  Michael Catanzaro  <mcatanz...@gnome.org>
 
         REGRESSION(r280382): [GTK] 2.33.3 does not build with gtk-doc enabled, installs broken pkg-config files

Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (281198 => 281199)


--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2021-08-18 17:42:30 UTC (rev 281198)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp	2021-08-18 17:45:29 UTC (rev 281199)
@@ -1731,7 +1731,7 @@
     auto& networkProcessProxy = networkProcess();
     networkProcessProxy.getNetworkProcessConnection(webProcessProxy, [weakThis = makeWeakPtr(*this), networkProcessProxy = makeWeakPtr(networkProcessProxy), webProcessProxy = makeWeakPtr(webProcessProxy), reply = WTFMove(reply), shouldRetryOnFailure] (auto& connectionInfo) mutable {
         if (UNLIKELY(!IPC::Connection::identifierIsValid(connectionInfo.identifier()))) {
-            auto logError = [networkProcessProxy = WTFMove(networkProcessProxy), webProcessProxy]() {
+            auto logError = [networkProcessProxy, webProcessProxy]() {
 #if OS(DARWIN)
                 if (!os_variant_allows_internal_security_policies("com.apple.WebKit"))
                     return;
@@ -1756,9 +1756,11 @@
             }
 
             // Retry on the next RunLoop iteration because we may be inside the WebsiteDataStore destructor.
-            RunLoop::main().dispatch([weakThis = WTFMove(weakThis), webProcessProxy = WTFMove(webProcessProxy), reply = WTFMove(reply), logError = WTFMove(logError)] () mutable {
+            RunLoop::main().dispatch([weakThis = WTFMove(weakThis), networkProcessProxy = WTFMove(networkProcessProxy), webProcessProxy = WTFMove(webProcessProxy), reply = WTFMove(reply), logError = WTFMove(logError)] () mutable {
                 if (RefPtr<WebsiteDataStore> strongThis = weakThis.get(); strongThis && webProcessProxy) {
-                    strongThis->terminateNetworkProcess();
+                    // Terminate if it is the same network process.
+                    if (networkProcessProxy && strongThis->m_networkProcess == networkProcessProxy.get())
+                        strongThis->terminateNetworkProcess();
                     RELEASE_LOG_ERROR(Process, "getNetworkProcessConnection: Failed to get connection to network process, will retry ...");
                     strongThis->getNetworkProcessConnection(*webProcessProxy, WTFMove(reply), ShouldRetryOnFailure::No);
                 } else {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to