Load hangs if the WebProcess fails to launch
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 May 2018 19:59:05 +0000 (19:59 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 3 May 2018 19:59:05 +0000 (19:59 +0000)
commit9d236e5c98fbca6fbc097a06fdbd1a6f5e6ba88d
treed760957f317b76085082048c1a7df8591ef4a6a1
parentc8e3f4c55899e043844c1398d7e0c105e887ccc9
Load hangs if the WebProcess fails to launch
https://bugs.webkit.org/show_bug.cgi?id=185225
<rdar://problem/38249058>

Reviewed by Geoff Garen.

Source/WebKit:

When a process fails to launch, ChildProcessProxy::didFinishLaunching() gets called with an
invalid connection identifier. While NetworkProcessProxy::didFinishLaunching() properly deals with
this situation, WebProcessProxy::didFinishLaunching() does not. As a result, we do not attempt to
relaunch the process, we do not notify the client and WebPageProxy::m_isValid stays true.

This patch thus updates WebProcessProxy::didFinishLaunching() to check if the connection identifier
is valid and treats it as a crash. As a result, the WebPageProxies properly reset their state and
the client gets notified of the crash so that it can attempt to reload.

* UIProcess/API/Cocoa/WKProcessPool.mm:
(-[WKProcessPool _makeNextWebProcessLaunchFailForTesting]):
* UIProcess/API/Cocoa/WKProcessPoolPrivate.h:
* UIProcess/Launcher/ProcessLauncher.h:
* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
(WebKit::ProcessLauncher::launchProcess):
Add SPI to make the next WebProcess launch fail, for the purpose of API testing.

* UIProcess/WebProcessPool.h:
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::getLaunchOptions):
(WebKit::WebProcessProxy::didClose):
(WebKit::WebProcessProxy::processDidTerminateOrFailedToLaunch):
(WebKit::WebProcessProxy::didFinishLaunching):
* UIProcess/WebProcessProxy.h:

Tools:

Add API test coverage.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/WebContentProcessDidTerminate.mm: Added.
(-[CrashOnStartNavigationDelegate _webView:webContentProcessDidTerminateWithReason:]):
(-[CrashOnStartNavigationDelegate webView:didFinishNavigation:]):
(-[CrashRecoveryScriptMessageHandler userContentController:didReceiveScriptMessage:]):
(TEST):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231321 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm
Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h
Source/WebKit/UIProcess/Launcher/ProcessLauncher.h
Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm
Source/WebKit/UIProcess/WebProcessPool.h
Source/WebKit/UIProcess/WebProcessProxy.cpp
Source/WebKit/UIProcess/WebProcessProxy.h
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKitCocoa/WebContentProcessDidTerminate.mm [new file with mode: 0644]