Skip to content

Commit a755f46

Browse files
committed
[WebKitTestRunner] Forward WebContent termination reason
https://bugs.webkit.org/show_bug.cgi?id=225818 <rdar://problem/78027164> Reviewed by Chris Dumez. * WebKitTestRunner/TestController.cpp: (WTR::TestController::createOtherPage): Use didTerminate callback instead of didCrash callback. (WTR::TestController::createWebViewWithOptions): Ditto. (WTR::TestController::webProcessDidTerminate): (WTR::TestController::processDidCrash): Renamed webProcessDidTerminate. * WebKitTestRunner/TestController.h: Replace processDidCrash with webProcessDidTerminate. * WebKitTestRunner/win/TestControllerWin.cpp: (WTR::TestController::platformRunUntil): Canonical link: https://commits.webkit.org/237761@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277533 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent fccd559 commit a755f46

4 files changed

Lines changed: 50 additions & 10 deletions

File tree

Tools/ChangeLog

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
2021-05-14 Jonathan Bedard <[email protected]>
2+
3+
[WebKitTestRunner] Forward WebContent termination reason
4+
https://bugs.webkit.org/show_bug.cgi?id=225818
5+
<rdar://problem/78027164>
6+
7+
Reviewed by Chris Dumez.
8+
9+
* WebKitTestRunner/TestController.cpp:
10+
(WTR::TestController::createOtherPage): Use didTerminate callback instead of didCrash callback.
11+
(WTR::TestController::createWebViewWithOptions): Ditto.
12+
(WTR::TestController::webProcessDidTerminate):
13+
(WTR::TestController::processDidCrash): Renamed webProcessDidTerminate.
14+
* WebKitTestRunner/TestController.h: Replace processDidCrash with webProcessDidTerminate.
15+
* WebKitTestRunner/win/TestControllerWin.cpp:
16+
(WTR::TestController::platformRunUntil):
17+
118
2021-05-14 Jonathan Bedard <[email protected]>
219

320
[run-webkit-tests] Handle missing simulator state plist

Tools/WebKitTestRunner/TestController.cpp

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -468,13 +468,13 @@ WKPageRef TestController::createOtherPage(PlatformWebView* parentView, WKPageCon
468468
nullptr, // renderingProgressDidChange
469469
canAuthenticateAgainstProtectionSpace,
470470
didReceiveAuthenticationChallenge,
471-
processDidCrash,
471+
nullptr, // webProcessDidCrash
472472
copyWebCryptoMasterKey,
473473
didBeginNavigationGesture,
474474
willEndNavigationGesture,
475475
didEndNavigationGesture,
476476
didRemoveNavigationGestureSnapshot,
477-
nullptr, // webProcessDidTerminate
477+
webProcessDidTerminate, // webProcessDidTerminate
478478
nullptr, // contentRuleListNotification
479479
copySignedPublicKeyAndChallengeString,
480480
navigationActionDidBecomeDownload,
@@ -810,13 +810,13 @@ void TestController::createWebViewWithOptions(const TestOptions& options)
810810
nullptr, // renderingProgressDidChange
811811
canAuthenticateAgainstProtectionSpace,
812812
didReceiveAuthenticationChallenge,
813-
processDidCrash,
813+
nullptr,
814814
copyWebCryptoMasterKey,
815815
didBeginNavigationGesture,
816816
willEndNavigationGesture,
817817
didEndNavigationGesture,
818818
didRemoveNavigationGestureSnapshot,
819-
nullptr, // webProcessDidTerminate
819+
webProcessDidTerminate, // webProcessDidTerminate
820820
nullptr, // contentRuleListNotification
821821
copySignedPublicKeyAndChallengeString,
822822
navigationActionDidBecomeDownload,
@@ -1862,9 +1862,9 @@ void TestController::didReceiveAuthenticationChallenge(WKPageRef page, WKAuthent
18621862
static_cast<TestController*>(const_cast<void*>(clientInfo))->didReceiveAuthenticationChallenge(page, /*frame,*/ authenticationChallenge);
18631863
}
18641864

1865-
void TestController::processDidCrash(WKPageRef page, const void* clientInfo)
1865+
void TestController::webProcessDidTerminate(WKPageRef page, WKProcessTerminationReason reason, const void* clientInfo)
18661866
{
1867-
static_cast<TestController*>(const_cast<void*>(clientInfo))->processDidCrash();
1867+
static_cast<TestController*>(const_cast<void*>(clientInfo))->webProcessDidTerminate(reason);
18681868
}
18691869

18701870
void TestController::didBeginNavigationGesture(WKPageRef page, const void *clientInfo)
@@ -2154,12 +2154,35 @@ void TestController::downloadDidReceiveAuthenticationChallenge(WKDownloadRef, WK
21542154
static_cast<TestController*>(const_cast<void*>(clientInfo))->didReceiveAuthenticationChallenge(nullptr, authenticationChallenge);
21552155
}
21562156

2157-
void TestController::processDidCrash()
2157+
void TestController::webProcessDidTerminate(WKProcessTerminationReason reason)
21582158
{
21592159
// This function can be called multiple times when crash logs are being saved on Windows, so
21602160
// ensure we only print the crashed message once.
21612161
if (!m_didPrintWebProcessCrashedMessage) {
21622162
pid_t pid = WKPageGetProcessIdentifier(m_mainWebView->page());
2163+
fprintf(stderr, "%s terminated (pid %ld) ", webProcessName(), static_cast<long>(pid));
2164+
switch (reason) {
2165+
case kWKProcessTerminationReasonExceededMemoryLimit:
2166+
fprintf(stderr, "because the memory limit was exceeded\n");
2167+
break;
2168+
case kWKProcessTerminationReasonExceededCPULimit:
2169+
fprintf(stderr, "because the cpu limit was exceeded\n");
2170+
break;
2171+
case kWKProcessTerminationReasonRequestedByClient:
2172+
fprintf(stderr, "because the client requested\n");
2173+
break;
2174+
case kWKProcessTerminationReasonCrash:
2175+
fprintf(stderr, "because the process crashed\n");
2176+
break;
2177+
default:
2178+
fprintf(stderr, "for an unknown reason\n");
2179+
}
2180+
2181+
if (reason == kWKProcessTerminationReasonRequestedByClient) {
2182+
fflush(stderr);
2183+
return;
2184+
}
2185+
21632186
fprintf(stderr, "#CRASHED - %s (pid %ld)\n", webProcessName(), static_cast<long>(pid));
21642187
fflush(stderr);
21652188
m_didPrintWebProcessCrashedMessage = true;

Tools/WebKitTestRunner/TestController.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,8 +469,8 @@ class TestController {
469469
bool downloadDidReceiveServerRedirectToURL(WKDownloadRef, WKURLRequestRef);
470470
static void downloadDidReceiveAuthenticationChallenge(WKDownloadRef, WKAuthenticationChallengeRef, const void *clientInfo);
471471

472-
static void processDidCrash(WKPageRef, const void* clientInfo);
473-
void processDidCrash();
472+
static void webProcessDidTerminate(WKPageRef, WKProcessTerminationReason, const void* clientInfo);
473+
void webProcessDidTerminate(WKProcessTerminationReason);
474474

475475
static void didBeginNavigationGesture(WKPageRef, const void*);
476476
static void willEndNavigationGesture(WKPageRef, WKBackForwardListItemRef, const void*);

Tools/WebKitTestRunner/win/TestControllerWin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ void TestController::platformRunUntil(bool& condition, WTF::Seconds timeout)
155155
// First, let the test harness know this happened so it won't think we've hung. But
156156
// make sure we don't exit just yet!
157157
m_shouldExitWhenWebProcessCrashes = false;
158-
processDidCrash();
158+
webProcessDidTerminate(kWKProcessTerminationReasonCrash);
159159
m_shouldExitWhenWebProcessCrashes = true;
160160

161161
// Then spin a run loop until it finishes crashing to give time for a crash log to be saved. If

0 commit comments

Comments
 (0)