Title: [266798] trunk
- Revision
- 266798
- Author
- [email protected]
- Date
- 2020-09-09 12:56:58 -0700 (Wed, 09 Sep 2020)
Log Message
Make sure WKWebsiteDataStore operations reuse existing process pools even when all WKWebViews have closed.
<rdar://problem/62978295> and https://bugs.webkit.org/show_bug.cgi?id=216317
Reviewed by Geoffrey Garen.
Source/WebKit:
Covered by new API test.
When WebsiteDataStores are gathering all the NetworkProcesses they might need to message, they miss some
obvious candidates if there are no longer any related WKWebViews.
Fix that by tracking which sessions a NetworkProcess knows about.
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::addSession):
(WebKit::NetworkProcessProxy::hasSession const):
(WebKit::NetworkProcessProxy::removeSession):
* UIProcess/Network/NetworkProcessProxy.h:
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::isAssociatedProcessPool const):
Tools:
* TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm:
(TestWebKitAPI::TEST):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (266797 => 266798)
--- trunk/Source/WebKit/ChangeLog 2020-09-09 19:47:53 UTC (rev 266797)
+++ trunk/Source/WebKit/ChangeLog 2020-09-09 19:56:58 UTC (rev 266798)
@@ -1,3 +1,26 @@
+2020-09-09 Brady Eidson <[email protected]>
+
+ Make sure WKWebsiteDataStore operations reuse existing process pools even when all WKWebViews have closed.
+ <rdar://problem/62978295> and https://bugs.webkit.org/show_bug.cgi?id=216317
+
+ Reviewed by Geoffrey Garen.
+
+ Covered by new API test.
+
+ When WebsiteDataStores are gathering all the NetworkProcesses they might need to message, they miss some
+ obvious candidates if there are no longer any related WKWebViews.
+
+ Fix that by tracking which sessions a NetworkProcess knows about.
+
+ * UIProcess/Network/NetworkProcessProxy.cpp:
+ (WebKit::NetworkProcessProxy::addSession):
+ (WebKit::NetworkProcessProxy::hasSession const):
+ (WebKit::NetworkProcessProxy::removeSession):
+ * UIProcess/Network/NetworkProcessProxy.h:
+
+ * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+ (WebKit::WebsiteDataStore::isAssociatedProcessPool const):
+
2020-09-09 Chris Dumez <[email protected]>
Move lazy DisplayLink tear down logic from the WebProcess to the UIProcess
Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (266797 => 266798)
--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp 2020-09-09 19:47:53 UTC (rev 266797)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp 2020-09-09 19:56:58 UTC (rev 266798)
@@ -1273,6 +1273,8 @@
void NetworkProcessProxy::addSession(Ref<WebsiteDataStore>&& store)
{
+ m_sessionIDs.add(store->sessionID());
+
if (canSendMessage())
send(Messages::NetworkProcess::AddWebsiteDataStore { store->parameters() }, 0);
auto sessionID = store->sessionID();
@@ -1283,8 +1285,15 @@
}
}
+bool NetworkProcessProxy::hasSession(PAL::SessionID sessionID) const
+{
+ return m_sessionIDs.contains(sessionID);
+}
+
void NetworkProcessProxy::removeSession(PAL::SessionID sessionID)
{
+ m_sessionIDs.remove(sessionID);
+
if (canSendMessage())
send(Messages::NetworkProcess::DestroySession { sessionID }, 0);
}
Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h (266797 => 266798)
--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h 2020-09-09 19:47:53 UTC (rev 266797)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h 2020-09-09 19:56:58 UTC (rev 266798)
@@ -212,6 +212,7 @@
#endif
void addSession(Ref<WebsiteDataStore>&&);
+ bool hasSession(PAL::SessionID) const;
void removeSession(PAL::SessionID);
#if ENABLE(INDEXED_DATABASE)
@@ -347,6 +348,8 @@
WeakPtr<NetworkProcessProxy> m_networkProcess;
};
#endif
+
+ HashSet<PAL::SessionID> m_sessionIDs;
};
} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (266797 => 266798)
--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2020-09-09 19:47:53 UTC (rev 266797)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2020-09-09 19:56:58 UTC (rev 266798)
@@ -1999,6 +1999,8 @@
{
if (auto* processPoolDataStore = processPool.websiteDataStore())
return processPoolDataStore == this;
+ if (auto* networkProcessProxy = processPool.networkProcess())
+ return networkProcessProxy->hasSession(m_sessionID);
return false;
}
Modified: trunk/Tools/ChangeLog (266797 => 266798)
--- trunk/Tools/ChangeLog 2020-09-09 19:47:53 UTC (rev 266797)
+++ trunk/Tools/ChangeLog 2020-09-09 19:56:58 UTC (rev 266798)
@@ -1,3 +1,13 @@
+2020-09-09 Brady Eidson <[email protected]>
+
+ Make sure WKWebsiteDataStore operations reuse existing process pools even when all WKWebViews have closed.
+ <rdar://problem/62978295> and https://bugs.webkit.org/show_bug.cgi?id=216317
+
+ Reviewed by Geoffrey Garen.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm:
+ (TestWebKitAPI::TEST):
+
2020-09-09 Angelos Oikonomopoulos <[email protected]>
run-jsc-stress-test: fix escaping for --gnu-parallel-runner
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm (266797 => 266798)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm 2020-09-09 19:47:53 UTC (rev 266797)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm 2020-09-09 19:56:58 UTC (rev 266798)
@@ -25,11 +25,13 @@
#import "config.h"
+#import "HTTPServer.h"
#import "PlatformUtilities.h"
#import "TCPServer.h"
#import "Test.h"
#import "TestWKWebView.h"
#import <WebKit/WKProcessPoolPrivate.h>
+#import <WebKit/WKWebViewPrivate.h>
#import <WebKit/WKWebsiteDataRecordPrivate.h>
#import <WebKit/WKWebsiteDataStorePrivate.h>
#import <WebKit/WebKit.h>
@@ -309,4 +311,63 @@
TestWebKitAPI::Util::run(&readyToContinue);
}
+TEST(WebKit, ClearCustomDataStoreNoWebViews)
+{
+ HTTPServer server([connectionCount = 0] (Connection connection) mutable {
+ ++connectionCount;
+ connection.receiveHTTPRequest([connection, connectionCount] (Vector<char>&& request) {
+ switch (connectionCount) {
+ case 1:
+ connection.send(
+ "HTTP/1.1 200 OK\r\n"
+ "Content-Length: 5\r\n"
+ "Set-Cookie: a=b\r\n"
+ "Connection: close\r\n"
+ "\r\n"
+ "Hello");
+ break;
+ case 2:
+ EXPECT_FALSE(strstr(request.data(), "Cookie: a=b\r\n"));
+ connection.send(
+ "HTTP/1.1 200 OK\r\n"
+ "Content-Length: 5\r\n"
+ "Connection: close\r\n"
+ "\r\n"
+ "Hello");
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+ });
+ });
+
+
+ NSURL *fileURL = [NSURL fileURLWithPath:@"/tmp/testcookiefile.cookie"];
+ auto configuration = adoptNS([[_WKWebsiteDataStoreConfiguration alloc] init]);
+ [configuration _setCookieStorageFile:fileURL];
+
+ auto dataStore = adoptNS([[WKWebsiteDataStore alloc] _initWithConfiguration:configuration.get()]);
+ auto viewConfiguration = adoptNS([WKWebViewConfiguration new]);
+ [viewConfiguration setWebsiteDataStore:dataStore.get()];
+ auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 100, 100) configuration:viewConfiguration.get() addToWindow:YES]);
+
+ auto *url = "" URLWithString:[NSString stringWithFormat:@"http://127.0.0.1:%d/index.html", server.port()]];
+
+ [webView synchronouslyLoadRequest:[NSURLRequest requestWithURL:url]];
+ [webView _close];
+ webView = nil;
+
+ // Now that the WebView is closed, remove all website data.
+ // Then recreate a WebView with the same configuration to confirm the website data was removed.
+ static bool done;
+ [dataStore removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] modifiedSince:[NSDate distantPast] completionHandler:^{
+ done = true;
+ }];
+ Util::run(&done);
+ done = false;
+
+ webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 100, 100) configuration:viewConfiguration.get() addToWindow:YES]);
+ [webView synchronouslyLoadRequest:[NSURLRequest requestWithURL:url]];
}
+
+} // namespace TestWebKitAPI
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes