Title: [242020] branches/safari-607-branch

Diff

Modified: branches/safari-607-branch/Source/WebKit/ChangeLog (242019 => 242020)


--- branches/safari-607-branch/Source/WebKit/ChangeLog	2019-02-25 04:41:53 UTC (rev 242019)
+++ branches/safari-607-branch/Source/WebKit/ChangeLog	2019-02-25 04:46:52 UTC (rev 242020)
@@ -1,3 +1,48 @@
+2019-02-24  Babak Shafiei  <[email protected]>
+
+        Apply patch. rdar://problem/48317433
+
+    2019-02-24  Chris Dumez  <[email protected]>
+
+            REGRESSION(PSON): Google login page refreshes repeatedly in Reeder 3 app
+            <rdar://problem/47471222>
+
+            Reviewed by Alex Christensen.
+
+            When we process swap, we first call removeWebPage() on the previous process and then
+            call addExistingWebPage() on the new one. removeWebPage() would call
+            WebProcessPool::pageEndUsingWebsiteDataStore() and then addExistingWebPage() would
+            call WebProcessPool::pageBeginUsingWebsiteDataStore(). This was leading to loosing
+            session cookies because the call to WebProcessPool::pageEndUsingWebsiteDataStore()
+            would send an IPC to the Network process to destroy the session. The later call to
+            pageBeginUsingWebsiteDataStore() would re-construct the session but it would be too
+            late, previous cookies would be gone.
+
+            To address the issue, r238828 updated removeWebPage() / addExistingWebPage() so that
+            they no longer call pageBeginUsingWebsiteDataStore() / pageEndUsingWebsiteDataStore()
+            in case of a process swap. This partly fixed the issue. However, I failed to notice
+            that pageBeginUsingWebsiteDataStore() / pageEndUsingWebsiteDataStore() also send IPC
+            to the WebProcess to construct / destroy the session. We still want this IPC to
+            happen in case of a process-swap or the new process will not know about the session.
+
+            To address this issue, I moved the WebProcess IPC sending from
+            WebProcessPool::pageEndUsingWebsiteDataStore() / pageEndUsingWebsiteDataStore() to
+            WebProcessProxy::removeWebPage() / addExistingWebPage() so that it happens no matter
+            what. It is also clearer for the WebProcessProxy to send the IPC by itself.
+
+            This patch is only needed on the branch since Alex refactored the code in r239737
+            so that the WebSiteDataStore-related IPC to the WebProcess is no longer needed on
+            trunk.
+
+            * UIProcess/WebProcessPool.cpp:
+            (WebKit::WebProcessPool::pageBeginUsingWebsiteDataStore):
+            (WebKit::WebProcessPool::pageEndUsingWebsiteDataStore):
+            * UIProcess/WebProcessPool.h:
+            * UIProcess/WebProcessProxy.cpp:
+            (WebKit::WebProcessProxy::addExistingWebPage):
+            (WebKit::WebProcessProxy::removeWebPage):
+            (WebKit::WebProcessProxy::hasPageUsingSession const):
+
 2019-02-21  Alan Coon  <[email protected]>
 
         Cherry-pick r241919. rdar://problem/48267027

Modified: branches/safari-607-branch/Source/WebKit/UIProcess/WebProcessPool.cpp (242019 => 242020)


--- branches/safari-607-branch/Source/WebKit/UIProcess/WebProcessPool.cpp	2019-02-25 04:41:53 UTC (rev 242019)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/WebProcessPool.cpp	2019-02-25 04:46:52 UTC (rev 242020)
@@ -1213,12 +1213,10 @@
         ASSERT(page.websiteDataStore().parameters().networkSessionParameters.sessionID == sessionID);
         if (m_networkProcess)
             m_networkProcess->addSession(makeRef(page.websiteDataStore()));
-        page.process().send(Messages::WebProcess::AddWebsiteDataStore(WebsiteDataStoreParameters::privateSessionParameters(sessionID)), 0);
         page.websiteDataStore().clearPendingCookies();
     } else if (sessionID != PAL::SessionID::defaultSessionID()) {
         if (m_networkProcess)
             m_networkProcess->addSession(makeRef(page.websiteDataStore()));
-        page.process().send(Messages::WebProcess::AddWebsiteDataStore(page.websiteDataStore().parameters()), 0);
         page.websiteDataStore().clearPendingCookies();
     }
 
@@ -1249,7 +1247,6 @@
         // The last user of this non-default PAL::SessionID is gone, so clean it up in the child processes.
         if (networkProcess())
             networkProcess()->removeSession(sessionID);
-        page.process().send(Messages::WebProcess::DestroySession(sessionID), 0);
     }
 }
 

Modified: branches/safari-607-branch/Source/WebKit/UIProcess/WebProcessProxy.cpp (242019 => 242020)


--- branches/safari-607-branch/Source/WebKit/UIProcess/WebProcessProxy.cpp	2019-02-25 04:41:53 UTC (rev 242019)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/WebProcessProxy.cpp	2019-02-25 04:46:52 UTC (rev 242020)
@@ -465,6 +465,12 @@
     if (beginsUsingDataStore == BeginsUsingDataStore::Yes)
         m_processPool->pageBeginUsingWebsiteDataStore(webPage);
 
+    auto sessionID = webPage.sessionID();
+    if (sessionID.isEphemeral())
+        send(Messages::WebProcess::AddWebsiteDataStore(WebsiteDataStoreParameters::privateSessionParameters(sessionID)), 0);
+    else if (sessionID != PAL::SessionID::defaultSessionID())
+        send(Messages::WebProcess::AddWebsiteDataStore(webPage.websiteDataStore().parameters()), 0);
+
     m_pageMap.set(pageID, &webPage);
     globalPageMap().set(pageID, &webPage);
 
@@ -492,11 +498,24 @@
     if (endsUsingDataStore == EndsUsingDataStore::Yes)
         m_processPool->pageEndUsingWebsiteDataStore(webPage);
 
+    auto sessionID = webPage.sessionID();
+    if (sessionID != PAL::SessionID::defaultSessionID() && !hasPageUsingSession(sessionID))
+        send(Messages::WebProcess::DestroySession(sessionID), 0);
+
     updateBackgroundResponsivenessTimer();
 
     maybeShutDown();
 }
 
+bool WebProcessProxy::hasPageUsingSession(PAL::SessionID sessionID) const
+{
+    for (auto& page : m_pageMap.values()) {
+        if (page->sessionID() == sessionID)
+            return true;
+    }
+    return false;
+}
+
 void WebProcessProxy::addVisitedLinkStore(VisitedLinkStore& store)
 {
     m_visitedLinkStores.add(&store);

Modified: branches/safari-607-branch/Source/WebKit/UIProcess/WebProcessProxy.h (242019 => 242020)


--- branches/safari-607-branch/Source/WebKit/UIProcess/WebProcessProxy.h	2019-02-25 04:41:53 UTC (rev 242019)
+++ branches/safari-607-branch/Source/WebKit/UIProcess/WebProcessProxy.h	2019-02-25 04:46:52 UTC (rev 242020)
@@ -283,6 +283,8 @@
     bool canBeAddedToWebProcessCache() const;
     void shouldTerminate(bool& shouldTerminate);
 
+    bool hasPageUsingSession(PAL::SessionID) const;
+
     void createNewMessagePortChannel(const WebCore::MessagePortIdentifier& port1, const WebCore::MessagePortIdentifier& port2);
     void entangleLocalPortInThisProcessToRemote(const WebCore::MessagePortIdentifier& local, const WebCore::MessagePortIdentifier& remote);
     void messagePortDisentangled(const WebCore::MessagePortIdentifier&);

Modified: branches/safari-607-branch/Tools/ChangeLog (242019 => 242020)


--- branches/safari-607-branch/Tools/ChangeLog	2019-02-25 04:41:53 UTC (rev 242019)
+++ branches/safari-607-branch/Tools/ChangeLog	2019-02-25 04:46:52 UTC (rev 242020)
@@ -1,3 +1,18 @@
+2019-02-24  Babak Shafiei  <[email protected]>
+
+        Apply patch. rdar://problem/48317433
+
+    2019-02-24  Chris Dumez  <[email protected]>
+
+            REGRESSION(PSON): Google login page refreshes repeatedly in Reeder 3 app
+            <rdar://problem/47471222>
+
+            Reviewed by Alex Christensen.
+
+            Add API test coverage.
+
+            * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
+
 2019-02-21  Alan Coon  <[email protected]>
 
         Cherry-pick r241736. rdar://problem/48243264

Modified: branches/safari-607-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm (242019 => 242020)


--- branches/safari-607-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm	2019-02-25 04:41:53 UTC (rev 242019)
+++ branches/safari-607-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm	2019-02-25 04:46:52 UTC (rev 242020)
@@ -4395,6 +4395,73 @@
     EXPECT_WK_STREQ(@"foo=bar", receivedMessages.get()[0]);
 }
 
+TEST(ProcessSwap, UseSessionCookiesAfterProcessSwapInNonDefaultPersistentSession)
+{
+    auto processPoolConfiguration = psonProcessPoolConfiguration();
+
+    // Prevent WebProcess reuse.
+    processPoolConfiguration.get().usesWebProcessCache = NO;
+    processPoolConfiguration.get().pageCacheEnabled = NO;
+    processPoolConfiguration.get().prewarmsProcessesAutomatically = NO;
+
+    auto websiteDataStoreConfiguration = adoptNS([[_WKWebsiteDataStoreConfiguration alloc] init]);
+    auto customDataStore = adoptNS([[WKWebsiteDataStore alloc] _initWithConfiguration:websiteDataStoreConfiguration.get()]);
+
+    auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
+
+    auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
+
+    [webViewConfiguration setProcessPool:processPool.get()];
+    webViewConfiguration.get().websiteDataStore = customDataStore.get();
+
+    auto handler = adoptNS([[PSONScheme alloc] init]);
+    [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"pson"];
+
+    auto messageHandler = adoptNS([[PSONMessageHandler alloc] init]);
+    [[webViewConfiguration userContentController] addScriptMessageHandler:messageHandler.get() name:@"testHandler"];
+
+    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
+    auto delegate = adoptNS([[PSONNavigationDelegate alloc] init]);
+    [webView setNavigationDelegate:delegate.get()];
+
+    [processPool _setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];
+
+    NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"SetSessionCookie" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+    [webView loadRequest:request];
+
+    TestWebKitAPI::Util::run(&done);
+    done = false;
+
+    auto pid1 = [webView _webProcessIdentifier];
+
+    // Should process-swap.
+    request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.apple.com/main.html"]];
+    [webView loadRequest:request];
+
+    TestWebKitAPI::Util::run(&done);
+    done = false;
+
+    auto pid2 = [webView _webProcessIdentifier];
+    EXPECT_NE(pid1, pid2);
+
+    // Should process-swap.
+    request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"GetSessionCookie" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+    [webView loadRequest:request];
+
+    TestWebKitAPI::Util::run(&done);
+    done = false;
+
+    auto pid3 = [webView _webProcessIdentifier];
+    EXPECT_NE(pid2, pid3);
+    EXPECT_NE(pid1, pid3);
+
+    TestWebKitAPI::Util::run(&receivedMessage);
+    receivedMessage = false;
+
+    EXPECT_EQ(1u, [receivedMessages count]);
+    EXPECT_WK_STREQ(@"foo=bar", receivedMessages.get()[0]);
+}
+
 #if PLATFORM(MAC)
 
 TEST(ProcessSwap, TerminateProcessAfterProcessSwap)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to