Diff
Modified: branches/safari-608-branch/Source/WebKit/ChangeLog (251344 => 251345)
--- branches/safari-608-branch/Source/WebKit/ChangeLog 2019-10-20 17:33:19 UTC (rev 251344)
+++ branches/safari-608-branch/Source/WebKit/ChangeLog 2019-10-20 17:33:22 UTC (rev 251345)
@@ -1,3 +1,34 @@
+2019-10-15 Alan Coon <alanc...@apple.com>
+
+ Cherry-pick r250833. rdar://problem/56280706
+
+ Apply patch. rdar://problem/55920073
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/branches/safari-608.3.10.1-branch@250833 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2019-10-08 Alan Coon <alanc...@apple.com>
+
+ Apply patch. rdar://problem/55920073
+
+ 2019-10-08 youenn fablet <you...@apple.com>
+
+ Remove the protection to spin more than one service worker process at a time.
+ rdar://problem/55044713
+
+ Before site isolation, we were creating one service worker process for all domains.
+ We now create one service worker process per domain, which makes the protection to only spin
+ one service worker process potentially harmful: if two requests to create a service worker processes
+ for two different domains are made, only one will actually succeed.
+ This is reproduced by API test.
+
+ At UIProcess side, there is already a check to see whether a service worker process for a given domain is launched.
+ That protects against spinning several service worker processes for the same domain.
+
+ * NetworkProcess/NetworkProcess.cpp:
+ (WebKit::NetworkProcess::createNetworkConnectionToWebProcess):
+ (WebKit::NetworkProcess::createServerToContextConnection):
+ * NetworkProcess/NetworkProcess.h:
+
2019-10-15 Kocsen Chung <kocsen_ch...@apple.com>
Cherry-pick r250780. rdar://problem/56061126
Modified: branches/safari-608-branch/Source/WebKit/NetworkProcess/NetworkProcess.cpp (251344 => 251345)
--- branches/safari-608-branch/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2019-10-20 17:33:19 UTC (rev 251344)
+++ branches/safari-608-branch/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2019-10-20 17:33:22 UTC (rev 251345)
@@ -430,13 +430,10 @@
#if ENABLE(SERVICE_WORKER)
if (isServiceWorkerProcess && !m_webProcessConnections.isEmpty()) {
ASSERT(parentProcessHasServiceWorkerEntitlement());
- ASSERT(m_waitingForServerToContextProcessConnection);
auto contextConnection = WebSWServerToContextConnection::create(*this, registrableDomain, m_webProcessConnections.last()->connection());
auto addResult = m_serverToContextConnections.add(WTFMove(registrableDomain), contextConnection.copyRef());
ASSERT_UNUSED(addResult, addResult.isNewEntry);
- m_waitingForServerToContextProcessConnection = false;
-
for (auto* server : SWServer::allServers())
server->serverToContextConnectionCreated(contextConnection);
}
@@ -2442,10 +2439,6 @@
void NetworkProcess::createServerToContextConnection(const RegistrableDomain& registrableDomain, Optional<PAL::SessionID> sessionID)
{
- if (m_waitingForServerToContextProcessConnection)
- return;
-
- m_waitingForServerToContextProcessConnection = true;
if (sessionID)
parentProcessConnection()->send(Messages::NetworkProcessProxy::EstablishWorkerContextConnectionToNetworkProcessForExplicitSession(registrableDomain, *sessionID), 0);
else
Modified: branches/safari-608-branch/Source/WebKit/NetworkProcess/NetworkProcess.h (251344 => 251345)
--- branches/safari-608-branch/Source/WebKit/NetworkProcess/NetworkProcess.h 2019-10-20 17:33:19 UTC (rev 251344)
+++ branches/safari-608-branch/Source/WebKit/NetworkProcess/NetworkProcess.h 2019-10-20 17:33:22 UTC (rev 251345)
@@ -536,7 +536,6 @@
#if ENABLE(SERVICE_WORKER)
HashMap<WebCore::RegistrableDomain, RefPtr<WebSWServerToContextConnection>> m_serverToContextConnections;
- bool m_waitingForServerToContextProcessConnection { false };
bool m_shouldDisableServiceWorkerProcessTerminationDelay { false };
HashMap<PAL::SessionID, String> m_swDatabasePaths;
HashMap<PAL::SessionID, std::unique_ptr<WebCore::SWServer>> m_swServers;
Modified: branches/safari-608-branch/Tools/ChangeLog (251344 => 251345)
--- branches/safari-608-branch/Tools/ChangeLog 2019-10-20 17:33:19 UTC (rev 251344)
+++ branches/safari-608-branch/Tools/ChangeLog 2019-10-20 17:33:22 UTC (rev 251345)
@@ -1,3 +1,22 @@
+2019-10-15 Alan Coon <alanc...@apple.com>
+
+ Cherry-pick r250833. rdar://problem/56280706
+
+ Apply patch. rdar://problem/55920073
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/branches/safari-608.3.10.1-branch@250833 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2019-10-08 Alan Coon <alanc...@apple.com>
+
+ Apply patch. rdar://problem/55920073
+
+ 2019-10-08 youenn fablet <you...@apple.com>
+
+ Remove the protection to spin more than one service worker process at a time.
+ rdar://problem/55044713
+
+ * TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
+
2019-10-15 Kocsen Chung <kocsen_ch...@apple.com>
Cherry-pick r250811. rdar://problem/56061121
Modified: branches/safari-608-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm (251344 => 251345)
--- branches/safari-608-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm 2019-10-20 17:33:19 UTC (rev 251344)
+++ branches/safari-608-branch/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm 2019-10-20 17:33:22 UTC (rev 251345)
@@ -1622,6 +1622,44 @@
EXPECT_EQ(0U, processPool._serviceWorkerProcessCount);
}
+TEST(ServiceWorkers, ParallelProcessLaunch)
+{
+ [WKWebsiteDataStore _allowWebsiteDataRecordsForAllOrigins];
+
+ // Start with a clean slate data store
+ [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] modifiedSince:[NSDate distantPast] completionHandler:^() {
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+
+ auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+
+ auto messageHandler = adoptNS([[SWMessageHandler alloc] init]);
+ [[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"];
+
+ auto handler1 = adoptNS([[SWSchemes alloc] init]);
+ handler1->resources.set("sw1://host/main.html", ResourceInfo { @"text/html", mainBytes });
+ handler1->resources.set("sw1://host/sw.js", ResourceInfo { @"application/_javascript_", scriptBytes });
+ handler1->resources.set("sw1://host2/main.html", ResourceInfo { @"text/html", mainBytes });
+ handler1->resources.set("sw1://host2/sw.js", ResourceInfo { @"application/_javascript_", scriptBytes });
+ [configuration setURLSchemeHandler:handler1.get() forURLScheme:@"sw1"];
+
+ auto *processPool = configuration.get().processPool;
+ [processPool _registerURLSchemeServiceWorkersCanHandle:@"sw1"];
+
+ auto webView1 = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+ NSURLRequest *request1 = [NSURLRequest requestWithURL:[NSURL URLWithString:@"sw1://host/main.html"]];
+
+ auto webView3 = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+ NSURLRequest *request2 = [NSURLRequest requestWithURL:[NSURL URLWithString:@"sw1://host2/main.html"]];
+
+ [webView1 loadRequest:request1];
+ [webView3 loadRequest:request2];
+
+ waitUntilServiceWorkerProcessCount(processPool, 2);
+}
+
TEST(ServiceWorkers, ThrottleCrash)
{
ASSERT(mainBytes);