Title: [273997] trunk
Revision
273997
Author
[email protected]
Date
2021-03-05 12:53:47 -0800 (Fri, 05 Mar 2021)

Log Message

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

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (273996 => 273997)


--- trunk/Source/WebKit/ChangeLog	2021-03-05 20:49:27 UTC (rev 273996)
+++ trunk/Source/WebKit/ChangeLog	2021-03-05 20:53:47 UTC (rev 273997)
@@ -1,5 +1,25 @@
 2021-03-05  Chris Dumez  <[email protected]>
 
+        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  <[email protected]>
+
         Fix potential thread-safety issue in WebsiteDataStore::fetchDataAndApply()
         https://bugs.webkit.org/show_bug.cgi?id=222807
 

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (273996 => 273997)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-03-05 20:49:27 UTC (rev 273996)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-03-05 20:53:47 UTC (rev 273997)
@@ -7337,9 +7337,6 @@
     }
 #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)

Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp (273996 => 273997)


--- trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp	2021-03-05 20:49:27 UTC (rev 273996)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp	2021-03-05 20:53:47 UTC (rev 273997)
@@ -890,8 +890,12 @@
     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)

Modified: trunk/Tools/ChangeLog (273996 => 273997)


--- trunk/Tools/ChangeLog	2021-03-05 20:49:27 UTC (rev 273996)
+++ trunk/Tools/ChangeLog	2021-03-05 20:53:47 UTC (rev 273997)
@@ -1,3 +1,15 @@
+2021-03-05  Chris Dumez  <[email protected]>
+
+        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  <[email protected]>
 
         Don't open a new window in MiniBrowser if already opening a file from the command line

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebContentProcessDidTerminate.mm (273996 => 273997)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebContentProcessDidTerminate.mm	2021-03-05 20:49:27 UTC (rev 273996)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebContentProcessDidTerminate.mm	2021-03-05 20:53:47 UTC (rev 273997)
@@ -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 @@
     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);
+}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to