Title: [237554] trunk
Revision
237554
Author
[email protected]
Date
2018-10-29 08:48:28 -0700 (Mon, 29 Oct 2018)

Log Message

[PSON] When Safari restores session state after launching, going back and forward does not swap processes
https://bugs.webkit.org/show_bug.cgi?id=190975
<rdar://problem/45059256>

Reviewed by Antti Koivisto.

Source/WebKit:

When deciding to process-swap or not on a history navigation, we normally check the BackForwardListItems'
process identifiers do check if they come from different WebProcesses or not. However, the check was invalid
in the case where the BackForwardListItems were restored by the client. After a session restore, the
items' process identifier is the UIProcess one. Therefore, we need to disable the BackForwardListItems'
process identifiers check if if the process identifier is the one of the UIProcess.

* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::processForNavigationInternal):

Tools:

Add API test coverage.

* TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (237553 => 237554)


--- trunk/Source/WebKit/ChangeLog	2018-10-29 15:46:14 UTC (rev 237553)
+++ trunk/Source/WebKit/ChangeLog	2018-10-29 15:48:28 UTC (rev 237554)
@@ -1,3 +1,20 @@
+2018-10-29  Chris Dumez  <[email protected]>
+
+        [PSON] When Safari restores session state after launching, going back and forward does not swap processes
+        https://bugs.webkit.org/show_bug.cgi?id=190975
+        <rdar://problem/45059256>
+
+        Reviewed by Antti Koivisto.
+
+        When deciding to process-swap or not on a history navigation, we normally check the BackForwardListItems'
+        process identifiers do check if they come from different WebProcesses or not. However, the check was invalid
+        in the case where the BackForwardListItems were restored by the client. After a session restore, the
+        items' process identifier is the UIProcess one. Therefore, we need to disable the BackForwardListItems'
+        process identifiers check if if the process identifier is the one of the UIProcess.
+
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::processForNavigationInternal):
+
 2018-10-29  Youenn Fablet  <[email protected]>
 
         [WebRTC] Enable VP8 by default

Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (237553 => 237554)


--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2018-10-29 15:46:14 UTC (rev 237553)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2018-10-29 15:48:28 UTC (rev 237554)
@@ -2143,7 +2143,10 @@
         // If the target back/forward item and the current back/forward item originated
         // in the same WebProcess then we should reuse the current WebProcess.
         if (auto* fromItem = navigation.fromItem()) {
-            if (fromItem->itemID().processIdentifier == backForwardListItem->itemID().processIdentifier) {
+            auto uiProcessIdentifier = Process::identifier();
+            // In case of session restore, the item's process identifier is the UIProcess' identifier, in which case we do not want to do this check
+            // or we'd never swap after a session restore.
+            if (fromItem->itemID().processIdentifier == backForwardListItem->itemID().processIdentifier && backForwardListItem->itemID().processIdentifier != uiProcessIdentifier) {
                 reason = "Source and target back/forward item originated in the same process"_s;
                 return page.process();
             }

Modified: trunk/Tools/ChangeLog (237553 => 237554)


--- trunk/Tools/ChangeLog	2018-10-29 15:46:14 UTC (rev 237553)
+++ trunk/Tools/ChangeLog	2018-10-29 15:48:28 UTC (rev 237554)
@@ -1,3 +1,15 @@
+2018-10-29  Chris Dumez  <[email protected]>
+
+        [PSON] When Safari restores session state after launching, going back and forward does not swap processes
+        https://bugs.webkit.org/show_bug.cgi?id=190975
+        <rdar://problem/45059256>
+
+        Reviewed by Antti Koivisto.
+
+        Add API test coverage.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
+
 2018-10-29  Zalan Bujtas  <[email protected]>
 
         [LFC][IFC] Compute estimated margin top for inline formatting root's ancestors

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm (237553 => 237554)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm	2018-10-29 15:46:14 UTC (rev 237553)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm	2018-10-29 15:48:28 UTC (rev 237554)
@@ -710,6 +710,61 @@
     EXPECT_FALSE(pid2 == pid3);
 }
 
+TEST(ProcessSwap, BackNavigationAfterSessionRestore)
+{
+    auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]);
+    processPoolConfiguration.get().processSwapsOnNavigation = YES;
+    auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
+
+    auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
+    [webViewConfiguration setProcessPool:processPool.get()];
+    auto handler = adoptNS([[PSONScheme alloc] init]);
+    [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"PSON"];
+
+    auto webView1 = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
+    auto delegate = adoptNS([[PSONNavigationDelegate alloc] init]);
+    [webView1 setNavigationDelegate:delegate.get()];
+
+    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main.html"]];
+    [webView1 loadRequest:request];
+
+    TestWebKitAPI::Util::run(&done);
+    done = false;
+
+    auto pid1 = [webView1 _webProcessIdentifier];
+
+    request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.apple.com/main.html"]];
+    [webView1 loadRequest:request];
+
+    TestWebKitAPI::Util::run(&done);
+    done = false;
+
+    auto pid2 = [webView1 _webProcessIdentifier];
+    EXPECT_NE(pid1, pid2);
+
+    RetainPtr<_WKSessionState> sessionState = [webView1 _sessionState];
+    webView1 = nullptr;
+
+    auto webView2 = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
+    delegate = adoptNS([[PSONNavigationDelegate alloc] init]);
+    [webView2 setNavigationDelegate:delegate.get()];
+
+    [webView2 _restoreSessionState:sessionState.get() andNavigate:YES];
+    TestWebKitAPI::Util::run(&done);
+    done = false;
+
+    EXPECT_WK_STREQ(@"pson://www.apple.com/main.html", [[webView2 URL] absoluteString]);
+    auto pid3 = [webView2 _webProcessIdentifier];
+
+    [webView2 goBack];
+    TestWebKitAPI::Util::run(&done);
+    done = false;
+
+    EXPECT_WK_STREQ(@"pson://www.webkit.org/main.html", [[webView2 URL] absoluteString]);
+    auto pid4 = [webView2 _webProcessIdentifier];
+    EXPECT_NE(pid3, pid4);
+}
+
 #if PLATFORM(MAC)
 
 TEST(ProcessSwap, CrossSiteWindowOpenNoOpener)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to