Skip to content
Permalink
Browse files
Regression(r268097): WKWebView.URL is nil in the processDidTerminate …
…delegate

https://bugs.webkit.org/show_bug.cgi?id=222809

Reviewed by Michael Catanzaro.

Source/WebKit:

There was a PageLoadState::Transaction in resetStateAfterProcessTermination() that
was previously making sure we would not clear the WebView's URL before calling the
processDidTerminate client delegate. Now that we call the client delegate in a
separate function (WebPageProxy::dispatchProcessDidTerminate), we need to make move
the PageLoadState::Transaction to the caller in
WebProcessProxy::processDidTerminateOrFailedToLaunch(), so that its scope covers
both resetStateAfterProcessTermination() & dispatchProcessDidTerminate() calls.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::resetStateAfterProcessTermination):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::processDidTerminateOrFailedToLaunch):

Tools:

Add API test coverage.

* TestWebKitAPI/Tests/WebKitCocoa/WebContentProcessDidTerminate.mm:
(TEST):

Canonical link: https://commits.webkit.org/234941@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@273997 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
cdumez committed Mar 5, 2021
1 parent b8e238c commit 0f082815374fd5378dbd30c87e811fe7a8f037cc
Showing 5 changed files with 61 additions and 4 deletions.
@@ -1,3 +1,23 @@
2021-03-05 Chris Dumez <cdumez@apple.com>

Regression(r268097): WKWebView.URL is nil in the processDidTerminate delegate
https://bugs.webkit.org/show_bug.cgi?id=222809

Reviewed by Michael Catanzaro.

There was a PageLoadState::Transaction in resetStateAfterProcessTermination() that
was previously making sure we would not clear the WebView's URL before calling the
processDidTerminate client delegate. Now that we call the client delegate in a
separate function (WebPageProxy::dispatchProcessDidTerminate), we need to make move
the PageLoadState::Transaction to the caller in
WebProcessProxy::processDidTerminateOrFailedToLaunch(), so that its scope covers
both resetStateAfterProcessTermination() & dispatchProcessDidTerminate() calls.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::resetStateAfterProcessTermination):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::processDidTerminateOrFailedToLaunch):

2021-03-05 Chris Dumez <cdumez@apple.com>

Fix potential thread-safety issue in WebsiteDataStore::fetchDataAndApply()
@@ -7337,9 +7337,6 @@ void WebPageProxy::resetStateAfterProcessTermination(ProcessTerminationReason re
}
#endif

// There is a nested transaction in resetStateAfterProcessExited() that we don't want to commit before the client call.
PageLoadState::Transaction transaction = m_pageLoadState.transaction();

resetStateAfterProcessExited(reason);
stopAllURLSchemeTasks(m_process.ptr());
#if ENABLE(UI_PROCESS_PDF_HUD)
@@ -890,8 +890,12 @@ void WebProcessProxy::processDidTerminateOrFailedToLaunch(ProcessTerminationReas
m_routingArbitrator->processDidTerminate();
#endif

for (auto& page : pages)
// There is a nested transaction in WebPageProxy::resetStateAfterProcessExited() that we don't want to commit before the client call below (dispatchProcessDidTerminate).
Vector<PageLoadState::Transaction> pageLoadStateTransactions;
for (auto& page : pages) {
pageLoadStateTransactions.append(page->pageLoadState().transaction());
page->resetStateAfterProcessTermination(reason);
}

for (auto& provisionalPage : provisionalPages) {
if (provisionalPage)
@@ -1,3 +1,15 @@
2021-03-05 Chris Dumez <cdumez@apple.com>

Regression(r268097): WKWebView.URL is nil in the processDidTerminate delegate
https://bugs.webkit.org/show_bug.cgi?id=222809

Reviewed by Michael Catanzaro.

Add API test coverage.

* TestWebKitAPI/Tests/WebKitCocoa/WebContentProcessDidTerminate.mm:
(TEST):

2021-03-05 Cameron McCormack <heycam@apple.com>

Don't open a new window in MiniBrowser if already opening a file from the command line
@@ -27,6 +27,8 @@

#import "PlatformUtilities.h"
#import "Test.h"
#import "TestNavigationDelegate.h"
#import "TestWKWebView.h"
#import <WebKit/WKNavigationDelegatePrivate.h>
#import <WebKit/WKNavigationPrivate.h>
#import <WebKit/WKProcessPoolPrivate.h>
@@ -352,3 +354,25 @@ - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigat
for (auto& webView : webViews)
EXPECT_EQ(pidAfter, [webView _webProcessIdentifier]);
}

TEST(WKNavigation, WebViewURLInProcessDidTerminate)
{
auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100) configuration:configuration.get()]);

[webView synchronouslyLoadTestPageNamed:@"simple"];
NSString *viewURL = [webView URL].absoluteString;
EXPECT_TRUE(!!viewURL);

auto navigationDelegate = adoptNS([[TestNavigationDelegate alloc] init]);
[webView setNavigationDelegate:navigationDelegate.get()];

__block bool done = false;
navigationDelegate.get().webContentProcessDidTerminate = ^(WKWebView *view) {
EXPECT_EQ(view, webView.get());
EXPECT_WK_STREQ(view.URL.absoluteString, viewURL);
done = true;
};
kill([webView _webProcessIdentifier], 9);
TestWebKitAPI::Util::run(&done);
}

0 comments on commit 0f08281

Please sign in to comment.