commit | c6951ff6f7d972427c05df8e7c39e3f2d74bf29c | [log] [tgz] |
---|---|---|
author | youenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc> | Mon Oct 14 07:54:00 2019 +0000 |
committer | youenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc> | Mon Oct 14 07:54:00 2019 +0000 |
tree | 8135a56efe13a89a72b0e168eb7d0302df5af77c | |
parent | c5ce17eb76debf360766bfa07269d63d48120610 [diff] |
Reuse existing web processes for running service workers https://bugs.webkit.org/show_bug.cgi?id=202195 Reviewed by Chris Dumez. Source/WebCore: Update implementation to be able to run service workers jointly with page. Add internals API to get the process ID. This allows writing tests to check whether a service worker is in the same process as its client or not. Test: http/wpt/service-workers/service-worker-different-process.https.html * testing/Internals.cpp: (WebCore::Internals::processIdentifier const): * testing/Internals.h: * testing/Internals.idl: * testing/ServiceWorkerInternals.cpp: (WebCore::ServiceWorkerInternals::processIdentifier const): * testing/ServiceWorkerInternals.h: * testing/ServiceWorkerInternals.idl: * workers/service/ServiceWorkerProvider.cpp: (WebCore::ServiceWorkerProvider::registerServiceWorkerClients): Do not register dummy documents whose sole purpose is to do loading for service workers. * workers/service/context/SWContextManager.cpp: (WebCore::SWContextManager::setConnection): Now that connections might be created more than once on a given process, Make sure that the replaced connection is stopped or there is no replaced connection. (WebCore::SWContextManager::stopAllServiceWorkers): Add routine to stop all service workers running in a given web process. * workers/service/context/SWContextManager.h: (WebCore::SWContextManager::Connection::isClosed const): (WebCore::SWContextManager::Connection::setAsClosed): Source/WebKit: When network process asks for a service worker context connection, we now iterate through existing web processes and reuse one if both session and registrable domain match. We then ask the web process to create a context connection to the network process. When network process no longer needs the connection, it instructs the UIProcess that will update its state so that the web process is no longer considered as running service workers. UIProcess then instructs the web process to stop its service workers and its connection. Later on, the same web process may be reused for running service workers in which case a new connection will replace the stopped connection. Similarly, on network process crash, all web process running service workers are updated so that they are no longer considered as running service workers. Add a boolean state to WebProcessPool to control whether creating a separate service worker process. We no longer terminate the web process when stopping service workers or when network process crash. We use the enableTermination/disableTermination at context connection start/stop time. We consider that the context connection is similar to running a page in the process and creating/removing a page calls disableTermination/enableTermination. NetworkProcess is handling the management of service worker processes by checking for clients. In case there is no client, the process is terminated. This removes the need for the WebProcessPool service worker process timer. This patch removes this timer. * NetworkProcess/NetworkConnectionToWebProcess.cpp: (WebKit::NetworkConnectionToWebProcess::didReceiveMessage): (WebKit::NetworkConnectionToWebProcess::establishSWContextConnection): (WebKit::NetworkConnectionToWebProcess::closeSWContextConnection): (WebKit::NetworkConnectionToWebProcess::serverToContextConnectionNoLongerNeeded): * NetworkProcess/NetworkConnectionToWebProcess.h: * NetworkProcess/NetworkConnectionToWebProcess.messages.in: * NetworkProcess/NetworkHTTPSUpgradeChecker.cpp: * NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp: (WebKit::WebSWServerToContextConnection::WebSWServerToContextConnection): (WebKit::WebSWServerToContextConnection::~WebSWServerToContextConnection): (WebKit::WebSWServerToContextConnection::messageSenderConnection const): (WebKit::WebSWServerToContextConnection::connectionIsNoLongerNeeded): (WebKit::WebSWServerToContextConnection::startFetch): * NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h: * UIProcess/API/C/WKContext.cpp: (WKContextSetUseSeparateServiceWorkerProcess): * UIProcess/API/C/WKContextPrivate.h: * UIProcess/API/Cocoa/WKProcessPool.mm: (-[WKProcessPool _setUseSeparateServiceWorkerProcess:]): (-[WKProcessPool _webPageContentProcessCount]): * UIProcess/API/Cocoa/WKProcessPoolPrivate.h: * UIProcess/Network/NetworkProcessProxy.cpp: (WebKit::NetworkProcessProxy::workerContextConnectionNoLongerNeeded): * UIProcess/Network/NetworkProcessProxy.h: * UIProcess/Network/NetworkProcessProxy.messages.in: * UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::networkProcessCrashed): (WebKit::WebProcessPool::establishWorkerContextConnectionToNetworkProcess): (WebKit::WebProcessPool::removeFromServiceWorkerProcesses): (WebKit::WebProcessPool::disconnectProcess): (WebKit::WebProcessPool::createWebPage): (WebKit::WebProcessPool::terminateNetworkProcess): (WebKit::WebProcessPool::setUseSeparateServiceWorkerProcess): * UIProcess/WebProcessPool.h: * UIProcess/WebProcessProxy.cpp: (WebKit::WebProcessProxy::createForServiceWorkers): (WebKit::WebProcessProxy::canTerminateAuxiliaryProcess): (WebKit::WebProcessProxy::didStartProvisionalLoadForMainFrame): (WebKit::WebProcessProxy::disableServiceWorkers): (WebKit::WebProcessProxy::enableServiceWorkers): * UIProcess/WebProcessProxy.h: (WebKit::WebProcessProxy::isMatchingRegistrableDomain const): * WebProcess/Storage/WebSWContextManagerConnection.cpp: (WebKit::m_userAgent): (WebKit::WebSWContextManagerConnection::terminateWorker): (WebKit::WebSWContextManagerConnection::syncTerminateWorker): (WebKit::WebSWContextManagerConnection::close): * WebProcess/Storage/WebSWContextManagerConnection.h: * WebProcess/Storage/WebSWContextManagerConnection.messages.in: * WebProcess/WebProcess.cpp: (WebKit::WebProcess::networkProcessConnectionClosed): (WebKit::WebProcess::registerServiceWorkerClients): Tools: Add support for enforcing a separate process for service workers. This is useful for tests trying to crash the service worker process. * TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm: Update test to use serviceWorkerProcessCount. Add test to check for in process and out of process service workers. * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: * WebKitTestRunner/InjectedBundle/TestRunner.cpp: (WTR::TestRunner::setUseSeparateServiceWorkerProcess): * WebKitTestRunner/InjectedBundle/TestRunner.h: * WebKitTestRunner/TestController.cpp: (WTR::TestController::resetStateToConsistentValues): * WebKitTestRunner/TestInvocation.cpp: (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle): LayoutTests: * http/tests/workers/service/resources/postmessage-after-sw-process-crash.js: (async.doTest): * http/tests/workers/service/resources/postmessage-after-terminate.js: (async.doTest): * http/tests/workers/service/resources/postmessage-after-terminating-hung-worker.js: (async.doTest): * http/wpt/service-workers/online.https.html: * http/wpt/service-workers/service-worker-different-process.https-expected.txt: Added. * http/wpt/service-workers/service-worker-different-process.https.html: Added. * http/wpt/service-workers/service-worker-process-worker.js: Added. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@251067 268f45cc-cd09-0410-ab3c-d52691b4dbfc
WebKit is a cross-platform web browser engine. On iOS and macOS, it powers Safari, Mail, iBooks, and many other applications.
Visit WebKit Feature Status page to see which Web API has been implemented, in development, or under consideration.
On macOS, download Safari Technology Preview to test the latest version of WebKit. On Linux, download Epiphany Technology Preview. On Windows, you'll have to build it yourself.
Once your bug is filed, you will receive email when it is updated at each stage in the bug life cycle. After the bug is considered fixed, you may be asked to download the latest nightly and confirm that the fix works for you.
On Windows, follow the instructions on our website.
Run the following command to clone WebKit's Git SVN repository:
git clone git://git.webkit.org/WebKit.git WebKit
or
git clone https://git.webkit.org/git/WebKit.git WebKit
If you want to be able to commit changes to the repository, or just want to check out branches that aren’t contained in WebKit.git, you will need track WebKit's Subversion repository. You can run the following command to configure this and other options of the new Git clone for WebKit development.
Tools/Scripts/webkit-patch setup-git-clone
For information about this, and other aspects of using Git with WebKit, read the wiki page.
If you don‘t want to use Git, run the following command to check out WebKit’s Subversion repository:
svn checkout https://svn.webkit.org/repository/webkit/trunk WebKit
Install Xcode and its command line tools if you haven't done so already:
xcode-select --install
Run the following command to build a debug build with debugging symbols and assertions:
Tools/Scripts/build-webkit --debug
For performance testing, and other purposes, use --release
instead.
You can open WebKit.xcworkspace
to build and debug WebKit within Xcode.
If you don't use a custom build location in Xcode preferences, you have to update the workspace settings to use WebKitBuild
directory. In menu bar, choose File > Workspace Settings, then click the Advanced button, select “Custom”, “Relative to Workspace”, and enter WebKitBuild
for both Products and Intermediates.
The first time after you install a new Xcode, you will need to run the following command to enable Xcode to build command line tools for iOS Simulator:
sudo Tools/Scripts/configure-xcode-for-ios-development
Without this step, you will see the error message: “target specifies product type ‘com.apple.product-type.tool’, but there’s no such product type for the ‘iphonesimulator’ platform.
” when building target JSCLLIntOffsetsExtractor
of project JavaScriptCore
.
Run the following command to build a debug build with debugging symbols and assertions for iOS:
Tools/Scripts/build-webkit --debug --ios-simulator
For production builds:
cmake -DPORT=GTK -DCMAKE_BUILD_TYPE=RelWithDebInfo -GNinja ninja sudo ninja install
For development builds:
Tools/gtk/install-dependencies Tools/Scripts/update-webkitgtk-libs Tools/Scripts/build-webkit --gtk --debug
For more information on building WebKitGTK+, see the wiki page.
For production builds:
cmake -DPORT=WPE -DCMAKE_BUILD_TYPE=RelWithDebInfo -GNinja ninja sudo ninja install
For development builds:
Tools/wpe/install-dependencies Tools/Scripts/update-webkitwpe-libs Tools/Scripts/build-webkit --wpe --debug
For building WebKit on Windows, see the wiki page.
Run the following command to launch Safari with your local build of WebKit:
Tools/Scripts/run-safari --debug
The run-safari
script sets the DYLD_FRAMEWORK_PATH
environment variable to point to your build products, and then launches /Applications/Safari.app
. DYLD_FRAMEWORK_PATH
tells the system loader to prefer your build products over the frameworks installed in /System/Library/Frameworks
.
To run other applications with your local build of WebKit, run the following command:
Tools/Scripts/run-webkit-app <application-path>
Run the following command to launch iOS simulator with your local build of WebKit:
run-safari --debug --ios-simulator
In both cases, if you have built release builds instead, use --release
instead of --debug
.
If you have a development build, you can use the run-minibrowser script, e.g.:
run-minibrowser --debug --wpe
Pass one of --gtk
, --jsc-only
, or --wpe
to indicate the port to use.
Congratulations! You’re up and running. Now you can begin coding in WebKit and contribute your fixes and new features to the project. For details on submitting your code to the project, read Contributing Code.