Title: [233939] trunk/Source/WebKit
Revision
233939
Author
[email protected]
Date
2018-07-18 16:13:36 -0700 (Wed, 18 Jul 2018)

Log Message

WebContent crash in WebProcess::ensureNetworkProcessConnection
https://bugs.webkit.org/show_bug.cgi?id=187791
<rdar://problem/41995022>

Reviewed by Ryosuke Niwa.

If the WebProcessProxy::GetNetworkProcessConnection synchronous IPC between the WebProcess
and the UIProcess succeeded but we received an invalid connection identifier, then try
once more. This may indicate the network process has crashed, in which case it will be
relaunched.

* WebProcess/WebProcess.cpp:
(WebKit::getNetworkProcessConnection):
(WebKit::WebProcess::ensureNetworkProcessConnection):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (233938 => 233939)


--- trunk/Source/WebKit/ChangeLog	2018-07-18 22:41:48 UTC (rev 233938)
+++ trunk/Source/WebKit/ChangeLog	2018-07-18 23:13:36 UTC (rev 233939)
@@ -1,3 +1,20 @@
+2018-07-18  Chris Dumez  <[email protected]>
+
+        WebContent crash in WebProcess::ensureNetworkProcessConnection
+        https://bugs.webkit.org/show_bug.cgi?id=187791
+        <rdar://problem/41995022>
+
+        Reviewed by Ryosuke Niwa.
+
+        If the WebProcessProxy::GetNetworkProcessConnection synchronous IPC between the WebProcess
+        and the UIProcess succeeded but we received an invalid connection identifier, then try
+        once more. This may indicate the network process has crashed, in which case it will be
+        relaunched.
+
+        * WebProcess/WebProcess.cpp:
+        (WebKit::getNetworkProcessConnection):
+        (WebKit::WebProcess::ensureNetworkProcessConnection):
+
 2018-07-18  Per Arne Vollan  <[email protected]>
 
         The WebContent process does not suspend when MiniBrowser is minimized.

Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (233938 => 233939)


--- trunk/Source/WebKit/WebProcess/WebProcess.cpp	2018-07-18 22:41:48 UTC (rev 233938)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp	2018-07-18 23:13:36 UTC (rev 233939)
@@ -1097,38 +1097,50 @@
     injectedBundle->setBundleParameters(value);
 }
 
-NetworkProcessConnection& WebProcess::ensureNetworkProcessConnection()
+static IPC::Connection::Identifier getNetworkProcessConnection(IPC::Connection& connection)
 {
-    RELEASE_ASSERT(RunLoop::isMain());
-
-    // If we've lost our connection to the network process (e.g. it crashed) try to re-establish it.
-    if (!m_networkProcessConnection) {
-        IPC::Attachment encodedConnectionIdentifier;
-
-        if (!parentProcessConnection()->sendSync(Messages::WebProcessProxy::GetNetworkProcessConnection(), Messages::WebProcessProxy::GetNetworkProcessConnection::Reply(encodedConnectionIdentifier), 0, Seconds::infinity(), IPC::SendSyncOption::DoNotProcessIncomingMessagesWhenWaitingForSyncReply)) {
+    IPC::Attachment encodedConnectionIdentifier;
+    if (!connection.sendSync(Messages::WebProcessProxy::GetNetworkProcessConnection(), Messages::WebProcessProxy::GetNetworkProcessConnection::Reply(encodedConnectionIdentifier), 0, Seconds::infinity(), IPC::SendSyncOption::DoNotProcessIncomingMessagesWhenWaitingForSyncReply)) {
 #if PLATFORM(GTK) || PLATFORM(WPE)
-            // GTK+ and WPE ports don't exit on send sync message failure.
-            // In this particular case, the network process can be terminated by the UI process while the
-            // Web process is still initializing, so we always want to exit instead of crashing. This can
-            // happen when the WebView is created and then destroyed quickly.
-            // See https://bugs.webkit.org/show_bug.cgi?id=183348.
-            exit(0);
+        // GTK+ and WPE ports don't exit on send sync message failure.
+        // In this particular case, the network process can be terminated by the UI process while the
+        // Web process is still initializing, so we always want to exit instead of crashing. This can
+        // happen when the WebView is created and then destroyed quickly.
+        // See https://bugs.webkit.org/show_bug.cgi?id=183348.
+        exit(0);
 #else
-            CRASH();
+        CRASH();
 #endif
-        }
+    }
 
 #if USE(UNIX_DOMAIN_SOCKETS)
-        IPC::Connection::Identifier connectionIdentifier = encodedConnectionIdentifier.releaseFileDescriptor();
+    return encodedConnectionIdentifier.releaseFileDescriptor();
 #elif OS(DARWIN)
-        IPC::Connection::Identifier connectionIdentifier(encodedConnectionIdentifier.port());
+    return encodedConnectionIdentifier.port();
 #elif OS(WINDOWS)
-        IPC::Connection::Identifier connectionIdentifier(encodedConnectionIdentifier.handle());
+    return encodedConnectionIdentifier.handle();
 #else
-        ASSERT_NOT_REACHED();
+    ASSERT_NOT_REACHED();
+    return IPC::Connection::Identifier();
 #endif
+}
+
+NetworkProcessConnection& WebProcess::ensureNetworkProcessConnection()
+{
+    RELEASE_ASSERT(RunLoop::isMain());
+
+    // If we've lost our connection to the network process (e.g. it crashed) try to re-establish it.
+    if (!m_networkProcessConnection) {
+        IPC::Connection::Identifier connectionIdentifier = getNetworkProcessConnection(*parentProcessConnection());
+
+        // Retry once if the IPC to get the connectionIdentifier succeeded but the connectionIdentifier we received
+        // is invalid. This may indicate that the network process has crashed.
         if (!IPC::Connection::identifierIsValid(connectionIdentifier))
+            connectionIdentifier = getNetworkProcessConnection(*parentProcessConnection());
+
+        if (!IPC::Connection::identifierIsValid(connectionIdentifier))
             CRASH();
+
         m_networkProcessConnection = NetworkProcessConnection::create(connectionIdentifier);
     }
     
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to