Diff
Modified: trunk/Source/WebCore/ChangeLog (227988 => 227989)
--- trunk/Source/WebCore/ChangeLog 2018-02-02 00:16:50 UTC (rev 227988)
+++ trunk/Source/WebCore/ChangeLog 2018-02-02 00:25:12 UTC (rev 227989)
@@ -1,3 +1,16 @@
+2018-02-01 Youenn Fablet <you...@apple.com>
+
+ Delay service worker process creation until actually needed by SWServer
+ https://bugs.webkit.org/show_bug.cgi?id=182301
+
+ Reviewed by Chris Dumez.
+
+ Rename SWServer::Connection::scheduleJobInServer to scheduleJob.
+ Add sessionID getter from an SWServer.
+
+ * workers/service/server/SWServer.h:
+ (WebCore::SWServer::sessionID const):
+
2018-02-01 Fujii Hironori <hironori.fu...@sony.com>
REGRESSION(r227594) [WinCairo] NULL pointer crash in GraphicsContext::getWindowsContext
Modified: trunk/Source/WebCore/workers/service/server/SWServer.cpp (227988 => 227989)
--- trunk/Source/WebCore/workers/service/server/SWServer.cpp 2018-02-02 00:16:50 UTC (rev 227988)
+++ trunk/Source/WebCore/workers/service/server/SWServer.cpp 2018-02-02 00:25:12 UTC (rev 227989)
@@ -216,14 +216,6 @@
m_registrationStore.flushChanges(WTFMove(completionHandler));
}
-void SWServer::Connection::scheduleJobInServer(ServiceWorkerJobData&& jobData)
-{
- LOG(ServiceWorker, "Scheduling ServiceWorker job %s in server", jobData.identifier().loggingString().utf8().data());
- ASSERT(identifier() == jobData.connectionIdentifier());
-
- m_server.scheduleJob(WTFMove(jobData));
-}
-
void SWServer::Connection::finishFetchingScriptInServer(const ServiceWorkerFetchResult& result)
{
m_server.scriptFetchFinished(*this, result);
Modified: trunk/Source/WebCore/workers/service/server/SWServer.h (227988 => 227989)
--- trunk/Source/WebCore/workers/service/server/SWServer.h 2018-02-02 00:16:50 UTC (rev 227988)
+++ trunk/Source/WebCore/workers/service/server/SWServer.h 2018-02-02 00:25:12 UTC (rev 227989)
@@ -92,7 +92,6 @@
WEBCORE_EXPORT explicit Connection(SWServer&);
SWServer& server() { return m_server; }
- WEBCORE_EXPORT void scheduleJobInServer(ServiceWorkerJobData&&);
WEBCORE_EXPORT void finishFetchingScriptInServer(const ServiceWorkerFetchResult&);
WEBCORE_EXPORT void addServiceWorkerRegistrationInServer(ServiceWorkerRegistrationIdentifier);
WEBCORE_EXPORT void removeServiceWorkerRegistrationInServer(ServiceWorkerRegistrationIdentifier);
@@ -129,7 +128,7 @@
void removeRegistration(const ServiceWorkerRegistrationKey&);
WEBCORE_EXPORT Vector<ServiceWorkerRegistrationData> getRegistrations(const SecurityOriginData& topOrigin, const URL& clientURL);
- void scheduleJob(ServiceWorkerJobData&&);
+ WEBCORE_EXPORT void scheduleJob(ServiceWorkerJobData&&);
void rejectJob(const ServiceWorkerJobData&, const ExceptionData&);
void resolveRegistrationJob(const ServiceWorkerJobData&, const ServiceWorkerRegistrationData&, ShouldNotifyWhenResolved);
void resolveUnregistrationJob(const ServiceWorkerJobData&, const ServiceWorkerRegistrationKey&, bool unregistrationResult);
@@ -177,6 +176,8 @@
WEBCORE_EXPORT void getOriginsWithRegistrations(WTF::Function<void(const HashSet<SecurityOriginData>&)>);
+ PAL::SessionID sessionID() const { return m_sessionID; }
+
private:
void registerConnection(Connection&);
void unregisterConnection(Connection&);
Modified: trunk/Source/WebKit/ChangeLog (227988 => 227989)
--- trunk/Source/WebKit/ChangeLog 2018-02-02 00:16:50 UTC (rev 227988)
+++ trunk/Source/WebKit/ChangeLog 2018-02-02 00:25:12 UTC (rev 227989)
@@ -1,3 +1,24 @@
+2018-02-01 Youenn Fablet <you...@apple.com>
+
+ Delay service worker process creation until actually needed by SWServer
+ https://bugs.webkit.org/show_bug.cgi?id=182301
+
+ Reviewed by Chris Dumez.
+
+ Do not create a service worker process at creation of the first SWServerConnection.
+ Wait for a WebProcess message that needs it:
+ - postMessage message
+ - fetchEvent message
+ - job scheduling.
+
+ * StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
+ (WebKit::WebSWServerConnection::startFetch):
+ (WebKit::WebSWServerConnection::postMessageToServiceWorker):
+ (WebKit::WebSWServerConnection::scheduleJobInServer):
+ * StorageProcess/ServiceWorker/WebSWServerConnection.h:
+ * StorageProcess/StorageToWebProcessConnection.cpp:
+ (WebKit::StorageToWebProcessConnection::establishSWServerConnection):
+
2018-02-01 Wenson Hsieh <wenson_hs...@apple.com>
[Extra zoom mode] Implement basic support for interacting with text form controls
Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp (227988 => 227989)
--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp 2018-02-02 00:16:50 UTC (rev 227988)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp 2018-02-02 00:25:12 UTC (rev 227989)
@@ -149,6 +149,9 @@
return;
}
+ if (!StorageProcess::singleton().globalServerToContextConnection())
+ StorageProcess::singleton().createServerToContextConnection(server().sessionID());
+
server().runServiceWorkerIfNecessary(serviceWorkerIdentifier, [weakThis = WTFMove(weakThis), this, fetchIdentifier, serviceWorkerIdentifier, request = WTFMove(request), options = WTFMove(options), formData = WTFMove(formData), referrer = WTFMove(referrer)](bool success, auto& contextConnection) {
if (!weakThis)
return;
@@ -189,6 +192,9 @@
if (!sourceData)
return;
+ if (!StorageProcess::singleton().globalServerToContextConnection())
+ StorageProcess::singleton().createServerToContextConnection(server().sessionID());
+
// It's possible this specific worker cannot be re-run (e.g. its registration has been removed)
server().runServiceWorkerIfNecessary(destinationIdentifier, [destinationIdentifier, message = WTFMove(message), sourceData = WTFMove(*sourceData)](bool success, auto& contextConnection) mutable {
if (success)
@@ -196,6 +202,18 @@
});
}
+void WebSWServerConnection::scheduleJobInServer(ServiceWorkerJobData&& jobData)
+{
+ if (!StorageProcess::singleton().globalServerToContextConnection())
+ StorageProcess::singleton().createServerToContextConnection(server().sessionID());
+
+ SWSERVERCONNECTION_RELEASE_LOG_IF_ALLOWED("Scheduling ServiceWorker job %s in server", jobData.identifier().loggingString().utf8().data());
+ ASSERT(identifier() == jobData.connectionIdentifier());
+
+ server().scheduleJob(WTFMove(jobData));
+}
+
+
void WebSWServerConnection::didReceiveFetchResponse(uint64_t fetchIdentifier, const ResourceResponse& response)
{
m_contentConnection->send(Messages::ServiceWorkerClientFetch::DidReceiveResponse { response }, fetchIdentifier);
Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h (227988 => 227989)
--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h 2018-02-02 00:16:50 UTC (rev 227988)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h 2018-02-02 00:25:12 UTC (rev 227989)
@@ -84,6 +84,8 @@
void notifyClientsOfControllerChange(const HashSet<WebCore::DocumentIdentifier>& contextIdentifiers, const WebCore::ServiceWorkerData& newController);
void registrationReady(uint64_t registrationReadyRequestIdentifier, WebCore::ServiceWorkerRegistrationData&&) final;
+ void scheduleJobInServer(WebCore::ServiceWorkerJobData&&);
+
void startFetch(uint64_t fetchIdentifier, WebCore::ServiceWorkerRegistrationIdentifier, WebCore::ResourceRequest&&, WebCore::FetchOptions&&, IPC::FormDataReference&&, String&& referrer);
void postMessageToServiceWorker(WebCore::ServiceWorkerIdentifier destination, WebCore::MessageWithMessagePorts&&, const WebCore::ServiceWorkerOrClientIdentifier& source);
Modified: trunk/Source/WebKit/StorageProcess/StorageToWebProcessConnection.cpp (227988 => 227989)
--- trunk/Source/WebKit/StorageProcess/StorageToWebProcessConnection.cpp 2018-02-02 00:16:50 UTC (rev 227988)
+++ trunk/Source/WebKit/StorageProcess/StorageToWebProcessConnection.cpp 2018-02-02 00:25:12 UTC (rev 227989)
@@ -169,9 +169,6 @@
auto addResult = m_swConnections.add(serverConnectionIdentifier, WTFMove(connection));
ASSERT_UNUSED(addResult, addResult.isNewEntry);
-
- if (!StorageProcess::singleton().globalServerToContextConnection())
- StorageProcess::singleton().createServerToContextConnection(sessionID);
}
void StorageToWebProcessConnection::workerContextProcessConnectionCreated()
Modified: trunk/Tools/ChangeLog (227988 => 227989)
--- trunk/Tools/ChangeLog 2018-02-02 00:16:50 UTC (rev 227988)
+++ trunk/Tools/ChangeLog 2018-02-02 00:25:12 UTC (rev 227989)
@@ -1,3 +1,13 @@
+2018-02-01 Youenn Fablet <you...@apple.com>
+
+ Delay service worker process creation until actually needed by SWServer
+ https://bugs.webkit.org/show_bug.cgi?id=182301
+
+ Reviewed by Chris Dumez.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
+ (function):
+
2018-02-01 Aakash Jain <aakash_j...@apple.com>
Bubbles intermittently disappear from bot watchers dashboard
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm (227988 => 227989)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm 2018-02-02 00:16:50 UTC (rev 227988)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm 2018-02-02 00:25:12 UTC (rev 227989)
@@ -731,6 +731,113 @@
EXPECT_EQ(0, webView.get().configuration.processPool._storageProcessIdentifier);
}
+static const char* mainBytesWithScope = R"SWRESOURCE(
+<script>
+
+function log(msg)
+{
+ window.webkit.messageHandlers.sw.postMessage(msg);
+}
+
+navigator.serviceWorker.addEventListener("message", function(event) {
+ log("Message from worker: " + event.data);
+});
+
+try {
+
+navigator.serviceWorker.register('/sw.js', {scope: 'whateverscope'}).then(function(reg) {
+ reg.installing.postMessage("Hello from the web page");
+}).catch(function(error) {
+ log("Registration failed with: " + error);
+});
+} catch(e) {
+ log("Exception: " + e);
+}
+
+</script>
+)SWRESOURCE";
+
+TEST(ServiceWorkers, ServiceWorkerProcessCreation)
+{
+ [WKWebsiteDataStore _allowWebsiteDataRecordsForAllOrigins];
+
+ RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ setConfigurationInjectedBundlePath(configuration.get());
+
+ done = false;
+
+ [[configuration websiteDataStore] removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] modifiedSince:[NSDate distantPast] completionHandler:^() {
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+
+ [[configuration websiteDataStore] fetchDataRecordsOfTypes:[NSSet setWithObject:WKWebsiteDataTypeServiceWorkerRegistrations] completionHandler:^(NSArray<WKWebsiteDataRecord *> *websiteDataRecords) {
+
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+
+ RetainPtr<SWMessageHandler> messageHandler = adoptNS([[SWMessageHandler alloc] init]);
+ [[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"];
+ RetainPtr<RegularPageMessageHandler> regularPageMessageHandler = adoptNS([[RegularPageMessageHandler alloc] init]);
+ [[configuration userContentController] addScriptMessageHandler:regularPageMessageHandler.get() name:@"regularPage"];
+
+ RetainPtr<SWSchemes> handler = adoptNS([[SWSchemes alloc] init]);
+ handler->resources.set("sw://host/regularPageWithoutConnection.html", ResourceInfo { @"text/html", regularPageWithoutConnectionBytes });
+ handler->resources.set("sw://host/regularPageWithConnection.html", ResourceInfo { @"text/html", regularPageWithConnectionBytes });
+ handler->resources.set("sw://host/mainWithScope.html", ResourceInfo { @"text/html", mainBytesWithScope });
+ handler->resources.set("sw://host/main.html", ResourceInfo { @"text/html", mainBytes });
+ handler->resources.set("sw://host/sw.js", ResourceInfo { @"application/_javascript_", scriptBytes });
+ [configuration setURLSchemeHandler:handler.get() forURLScheme:@"SW"];
+
+ RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+
+ // Load a page that registers a service worker.
+ NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"sw://host/mainWithScope.html"]];
+
+ [webView loadRequest:request];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+ webView = nullptr;
+
+ // Now that a sw is registered, let's create a new configuration and try loading a regular page, there should be no service worker process created.
+ RetainPtr<WKWebViewConfiguration> newConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
+ setConfigurationInjectedBundlePath(newConfiguration.get());
+ newConfiguration.get().websiteDataStore = [configuration websiteDataStore];
+
+ [[newConfiguration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"];
+ [[newConfiguration userContentController] addScriptMessageHandler:regularPageMessageHandler.get() name:@"regularPage"];
+ [newConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"SW"];
+
+ webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:newConfiguration.get()]);
+ EXPECT_EQ(1u, webView.get().configuration.processPool._webProcessCount);
+ request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"sw://host/regularPageWithConnection.html"]];
+ [webView loadRequest:request];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+
+ // Make sure that loading the simple page did not start the service worker process.
+ EXPECT_EQ(1u, webView.get().configuration.processPool._webProcessCount);
+
+ webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:newConfiguration.get()]);
+ EXPECT_EQ(2u, webView.get().configuration.processPool._webProcessCount);
+ request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"sw://host/main.html"]];
+ [webView loadRequest:request];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+
+ // Make sure that loading this page did start the service worker process.
+ EXPECT_EQ(3u, webView.get().configuration.processPool._webProcessCount);
+
+ [[configuration websiteDataStore] removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] modifiedSince:[NSDate distantPast] completionHandler:^() {
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+}
+
#endif // WK_HAVE_C_SPI
#endif // WK_API_ENABLED