Title: [264408] trunk/Source/WebKit
- Revision
- 264408
- Author
- [email protected]
- Date
- 2020-07-15 11:23:22 -0700 (Wed, 15 Jul 2020)
Log Message
[WK2] Make establishing a connection between the WebProcess and the Network process more robust
https://bugs.webkit.org/show_bug.cgi?id=214307
<rdar://problem/64592340>
Reviewed by Alex Christensen.
Make establishing a connection between the WebProcess and the Network process more robust.
When the network process is crashy, it is not uncommon for the WebProcess to fail to establish
a connection to the network process. Previously, we would try twice and then give up by calling
CRASH(). I have tweaked the logic so that we now try 10 times and wait 100 ms between each
attempt to make a best effort at establishing the connection. I also updated the logic to exit
cleanly instead of crashing if the IPC connection to the UIProcess becomes invalid (i.e. the
UIProcess has severed the connection because this WebProcess is no longer needed).
* WebProcess/WebProcess.cpp:
(WebKit::getNetworkProcessConnection):
(WebKit::WebProcess::ensureNetworkProcessConnection):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (264407 => 264408)
--- trunk/Source/WebKit/ChangeLog 2020-07-15 18:17:44 UTC (rev 264407)
+++ trunk/Source/WebKit/ChangeLog 2020-07-15 18:23:22 UTC (rev 264408)
@@ -1,3 +1,23 @@
+2020-07-15 Chris Dumez <[email protected]>
+
+ [WK2] Make establishing a connection between the WebProcess and the Network process more robust
+ https://bugs.webkit.org/show_bug.cgi?id=214307
+ <rdar://problem/64592340>
+
+ Reviewed by Alex Christensen.
+
+ Make establishing a connection between the WebProcess and the Network process more robust.
+ When the network process is crashy, it is not uncommon for the WebProcess to fail to establish
+ a connection to the network process. Previously, we would try twice and then give up by calling
+ CRASH(). I have tweaked the logic so that we now try 10 times and wait 100 ms between each
+ attempt to make a best effort at establishing the connection. I also updated the logic to exit
+ cleanly instead of crashing if the IPC connection to the UIProcess becomes invalid (i.e. the
+ UIProcess has severed the connection because this WebProcess is no longer needed).
+
+ * WebProcess/WebProcess.cpp:
+ (WebKit::getNetworkProcessConnection):
+ (WebKit::WebProcess::ensureNetworkProcessConnection):
+
2020-07-15 Rob Buis <[email protected]>
Building AccessibilitySupportSPI with the macOS Big Sur public SDK fails
Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (264407 => 264408)
--- trunk/Source/WebKit/WebProcess/WebProcess.cpp 2020-07-15 18:17:44 UTC (rev 264407)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp 2020-07-15 18:23:22 UTC (rev 264408)
@@ -1100,23 +1100,28 @@
static NetworkProcessConnectionInfo getNetworkProcessConnection(IPC::Connection& connection)
{
NetworkProcessConnectionInfo connectionInfo;
- if (!connection.sendSync(Messages::WebProcessProxy::GetNetworkProcessConnection(), Messages::WebProcessProxy::GetNetworkProcessConnection::Reply(connectionInfo), 0)) {
- // If we failed the first time, retry once. The attachment may have become invalid
- // before it was received by the web process if the network process crashed.
- if (!connection.sendSync(Messages::WebProcessProxy::GetNetworkProcessConnection(), Messages::WebProcessProxy::GetNetworkProcessConnection::Reply(connectionInfo), 0)) {
-#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.
+ auto requestConnection = [&] {
+ if (!connection.isValid()) {
+ // Connection to UIProcess has been severed, exit cleanly.
exit(0);
-#else
+ }
+ if (!connection.sendSync(Messages::WebProcessProxy::GetNetworkProcessConnection(), Messages::WebProcessProxy::GetNetworkProcessConnection::Reply(connectionInfo), 0))
+ return false;
+ return IPC::Connection::identifierIsValid(connectionInfo.identifier());
+ };
+
+ static constexpr unsigned maxFailedAttempts = 10;
+ unsigned failedAttempts = 0;
+ while (!requestConnection()) {
+ if (++failedAttempts >= maxFailedAttempts)
CRASH();
-#endif
- }
+
+ RELEASE_LOG_ERROR(Process, "getNetworkProcessConnection: Failed to get connection to network process, will retry...");
+
+ // If we failed, retry after a delay. The attachment may have become invalid
+ // before it was received by the web process if the network process crashed.
+ sleep(100_ms);
}
-
return connectionInfo;
}
@@ -1129,14 +1134,6 @@
if (!m_networkProcessConnection) {
auto connectionInfo = 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(connectionInfo.identifier()))
- connectionInfo = getNetworkProcessConnection(*parentProcessConnection());
-
- if (!IPC::Connection::identifierIsValid(connectionInfo.identifier()))
- CRASH();
-
m_networkProcessConnection = NetworkProcessConnection::create(connectionInfo.releaseIdentifier(), connectionInfo.cookieAcceptPolicy);
#if HAVE(AUDIT_TOKEN)
m_networkProcessConnection->setNetworkProcessAuditToken(WTFMove(connectionInfo.auditToken));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes