Title: [233975] branches/safari-606-branch/Source/WebKit
Revision
233975
Author
[email protected]
Date
2018-07-18 19:01:18 -0700 (Wed, 18 Jul 2018)

Log Message

Cherry-pick r233939. rdar://problem/42359636

    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):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@233939 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-606-branch/Source/WebKit/ChangeLog (233974 => 233975)


--- branches/safari-606-branch/Source/WebKit/ChangeLog	2018-07-19 02:01:15 UTC (rev 233974)
+++ branches/safari-606-branch/Source/WebKit/ChangeLog	2018-07-19 02:01:18 UTC (rev 233975)
@@ -1,5 +1,43 @@
 2018-07-18  Babak Shafiei  <[email protected]>
 
+        Cherry-pick r233939. rdar://problem/42359636
+
+    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):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@233939 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    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  Babak Shafiei  <[email protected]>
+
         Cherry-pick r233932. rdar://problem/42353789
 
     The WebContent process does not suspend when MiniBrowser is minimized.

Modified: branches/safari-606-branch/Source/WebKit/WebProcess/WebProcess.cpp (233974 => 233975)


--- branches/safari-606-branch/Source/WebKit/WebProcess/WebProcess.cpp	2018-07-19 02:01:15 UTC (rev 233974)
+++ branches/safari-606-branch/Source/WebKit/WebProcess/WebProcess.cpp	2018-07-19 02:01:18 UTC (rev 233975)
@@ -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