commit | 28e362aaae5fe2d9f147b5f1e301091a8e4836d6 | [log] [tgz] |
---|---|---|
author | sihui_liu@apple.com <sihui_liu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc> | Thu Aug 15 18:41:53 2019 +0000 |
committer | sihui_liu@apple.com <sihui_liu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc> | Thu Aug 15 18:41:53 2019 +0000 |
tree | 87be38c73bc4bb0f523b07a0c62c27d1c20e6715 | |
parent | 05724e00488ebbae36060bcbe27d847608b4bd5b [diff] |
Some improvements on web storage https://bugs.webkit.org/show_bug.cgi?id=200373 Reviewed by Geoffrey Garen. Source/WebCore: Remove storage type EphemeralLocalStorage, which is used for localStorage in ephemeral session, and use LocalStorage instead. Add SessionID to StorageNamespace to make StorageNamespace session-specific. No new test, updating existing tests for new behavior. * loader/EmptyClients.cpp: (WebCore::EmptyStorageNamespaceProvider::createLocalStorageNamespace): (WebCore::EmptyStorageNamespaceProvider::createTransientLocalStorageNamespace): (WebCore::EmptyStorageNamespaceProvider::createEphemeralLocalStorageNamespace): Deleted. * page/Chrome.cpp: (WebCore::Chrome::createWindow const): ephemeral localStorage of different windows will connect to the same StorageArea in network process, so no need to copy from parent window to child window. * page/DOMWindow.cpp: (WebCore::DOMWindow::prewarmLocalStorageIfNecessary): localStorage will be prewarmed in network process in the initialization of StorageAreaMap. * page/Page.cpp: (WebCore::m_applicationManifest): (WebCore::Page::~Page): (WebCore::Page::setSessionID): (WebCore::Page::ephemeralLocalStorage): Deleted. (WebCore::Page::setEphemeralLocalStorage): Deleted. (WebCore::Page::setStorageNamespaceProvider): Deleted. * page/Page.h: (WebCore::Page::storageNamespaceProvider): * storage/Storage.cpp: (WebCore::Storage::prewarm): Deleted. * storage/Storage.h: * storage/StorageArea.h: (WebCore::StorageArea::closeDatabaseIfIdle): (WebCore::StorageArea::prewarm): Deleted. * storage/StorageNamespace.h: * storage/StorageNamespaceProvider.cpp: (WebCore::StorageNamespaceProvider::~StorageNamespaceProvider): (WebCore::StorageNamespaceProvider::localStorageArea): (WebCore::StorageNamespaceProvider::localStorageNamespace): (WebCore::StorageNamespaceProvider::transientLocalStorageNamespace): (WebCore::StorageNamespaceProvider::enableLegacyPrivateBrowsingForTesting): change SessionID of storageNamespace and update every StorageArea in this namespace. (WebCore::StorageNamespaceProvider::addPage): Deleted. (WebCore::StorageNamespaceProvider::removePage): Deleted. * storage/StorageNamespaceProvider.h: * storage/StorageType.h: (WebCore::isLocalStorage): Source/WebKit: Fix some issues in web storage architecture. For example, sessionStorageNameSpace for web page is prepared and destroyed in the network process when the page comes and goes, even though the page may not use sessionStorage at all. The messages about page state sent from web process to network process can be waste. Here are some general ideas of this patch: 1. Network process owns the web storage, and web process keeps a small local copy (based on session and origins that are visited). There is a virtual connection from the local copy in the web process to the original copy in the network process. The connection is created by web process when some page asks for web storage. 2. If connection is lost because network process is gone, storage in memory will be lost. The local copy in web processs will be discarded. 3. (SessionID, StorageNamespaceID, SecurityOrigin) is used to identify a storage area. If session is changed in web process (like enabling private browsing in layout test now), a re-connection with different sessionID would suffice to load another copy of storage. 4. localStorage in ephemeral session has the same behavior as localStorage instead of sessionStorage, which means different pages in the same ephemeral session share the same localStorage. Also, this patch introduces StorageManagerSet to network process. It handles web storage stuff, including receiving storage messages from web process, on one background thread. Previously each session has its own StorageManager and each StorageManager has its own WorkQueue. * CMakeLists.txt: * DerivedSources-input.xcfilelist: * DerivedSources-output.xcfilelist: * DerivedSources.make: * NetworkProcess/NetworkConnectionToWebProcess.cpp: remove message handlers that are no longer needed. Network process no longer needs to know page states from web process. (WebKit::NetworkConnectionToWebProcess::didClose): (WebKit::NetworkConnectionToWebProcess::webPageWasAdded): Deleted. (WebKit::NetworkConnectionToWebProcess::webPageWasRemoved): Deleted. (WebKit::NetworkConnectionToWebProcess::webProcessSessionChanged): Deleted. * NetworkProcess/NetworkConnectionToWebProcess.h: * NetworkProcess/NetworkConnectionToWebProcess.messages.in: * NetworkProcess/NetworkProcess.cpp: NetworkProcess uses StorageManagerSet instead of StorageManager from different sessions to deal with web storage. (WebKit::NetworkProcess::NetworkProcess): (WebKit::NetworkProcess::initializeNetworkProcess): (WebKit::NetworkProcess::createNetworkConnectionToWebProcess): StorageManagerSet starts handling StorageManagerSet messages from the new connection. (WebKit::NetworkProcess::addWebsiteDataStore): (WebKit::NetworkProcess::destroySession): (WebKit::NetworkProcess::hasLocalStorage): (WebKit::NetworkProcess::fetchWebsiteData): (WebKit::NetworkProcess::deleteWebsiteData): (WebKit::NetworkProcess::deleteWebsiteDataForOrigins): (WebKit::NetworkProcess::deleteWebsiteDataForRegistrableDomains): (WebKit::NetworkProcess::actualPrepareToSuspend): (WebKit::NetworkProcess::resume): (WebKit::NetworkProcess::syncLocalStorage): (WebKit::NetworkProcess::clearLegacyPrivateBrowsingLocalStorage): added for clearing in-memory ephemeral localStorage. (WebKit::NetworkProcess::getLocalStorageOriginDetails): (WebKit::NetworkProcess::connectionToWebProcessClosed): (WebKit::NetworkProcess::webPageWasAdded): Deleted. (WebKit::NetworkProcess::webPageWasRemoved): Deleted. (WebKit::NetworkProcess::webProcessWasDisconnected): Deleted. (WebKit::NetworkProcess::webProcessSessionChanged): Deleted. * NetworkProcess/NetworkProcess.h: * NetworkProcess/NetworkProcess.messages.in: * NetworkProcess/NetworkSession.cpp: StorageManager is moved out of NetworkSession. It is now managed by StorageManagerSet. (WebKit::NetworkSession::NetworkSession): (WebKit::NetworkSession::~NetworkSession): * NetworkProcess/NetworkSession.h: (WebKit::NetworkSession::storageManager): Deleted. * NetworkProcess/NetworkSessionCreationParameters.cpp: creation parameters of StorageManager is moved out of NetworkSessionCreationParameters. (WebKit::NetworkSessionCreationParameters::privateSessionParameters): (WebKit::NetworkSessionCreationParameters::encode const): (WebKit::NetworkSessionCreationParameters::decode): * NetworkProcess/NetworkSessionCreationParameters.h: * NetworkProcess/WebStorage/LocalStorageDatabase.cpp: (WebKit::LocalStorageDatabase::updateDatabase): remove an assertion that is no longer true as we can force an update with syncLocalStorage now. * NetworkProcess/WebStorage/LocalStorageDatabase.h: make updateDatabase public for syncLocalStorage. * NetworkProcess/WebStorage/LocalStorageDatabaseTracker.cpp: LocalStorageDatabaseTracker is created on the background thread now, so it does not hold WorkQueue to do the file operation. (WebKit::LocalStorageDatabaseTracker::create): (WebKit::LocalStorageDatabaseTracker::LocalStorageDatabaseTracker): (WebKit::LocalStorageDatabaseTracker::~LocalStorageDatabaseTracker): * NetworkProcess/WebStorage/LocalStorageDatabaseTracker.h: * NetworkProcess/WebStorage/LocalStorageNamespace.cpp: (WebKit::LocalStorageNamespace::getOrCreateStorageArea): (WebKit::LocalStorageNamespace::cloneTo): Deleted. * NetworkProcess/WebStorage/LocalStorageNamespace.h: * NetworkProcess/WebStorage/SessionStorageNamespace.cpp: (WebKit::SessionStorageNamespace::getOrCreateStorageArea): (WebKit::SessionStorageNamespace::addAllowedConnection): Deleted. (WebKit::SessionStorageNamespace::removeAllowedConnection): Deleted. * NetworkProcess/WebStorage/SessionStorageNamespace.h: (WebKit::SessionStorageNamespace::allowedConnections const): Deleted. * NetworkProcess/WebStorage/StorageArea.cpp: (WebKit::generateStorageAreaIdentifier): each StorageArea has an identifier. StorageAreaMap in web process uses this identifier to indicate which StorageArea it is connecting to. (WebKit::StorageArea::StorageArea): (WebKit::StorageArea::~StorageArea): StorageArea may still have listeners because StorageArea should be destroyed by requests from UI process, and listeners are connections to web processses. (WebKit::StorageArea::addListener): load localStorageDatabase in advance if there is some connection to this LocalStorage area. (WebKit::StorageArea::removeListener): (WebKit::StorageArea::hasListener const): (WebKit::StorageArea::clear): (WebKit::StorageArea::openDatabaseAndImportItemsIfNeeded const): (WebKit::StorageArea::dispatchEvents const): (WebKit::StorageArea::syncToDatabase): (WebKit::StorageArea::setItems): Deleted. Stop syncing from web process to network process after network process is relaunched. * NetworkProcess/WebStorage/StorageArea.h: (WebKit::StorageArea::identifier): (WebKit::StorageArea::setWorkQueue): * NetworkProcess/WebStorage/StorageManager.cpp: StorageManager should be accessed by only background thread now. (WebKit::StorageManager::StorageManager): (WebKit::StorageManager::~StorageManager): (WebKit::StorageManager::createSessionStorageNamespace): (WebKit::StorageManager::destroySessionStorageNamespace): this is not used now but keep it for future improvement to remove in-memory sessionStorage in network process if we know some web page is gone forever. (WebKit::StorageManager::cloneSessionStorageNamespace): previously each page had its own ephemeral localStorageNamespace and now all pages in the same session share one localStorage, so we don't need to clone localStorageNamespace. (WebKit::StorageManager::getSessionStorageOrigins): (WebKit::StorageManager::deleteSessionStorageOrigins): (WebKit::StorageManager::deleteSessionStorageEntriesForOrigins): (WebKit::StorageManager::getLocalStorageOrigins): (WebKit::StorageManager::getLocalStorageOriginDetails): (WebKit::StorageManager::deleteLocalStorageOriginsModifiedSince): (WebKit::StorageManager::deleteLocalStorageEntriesForOrigins): (WebKit::StorageManager::createLocalStorageArea): (WebKit::StorageManager::createTransientLocalStorageArea): (WebKit::StorageManager::createSessionStorageArea): (WebKit::StorageManager::getOrCreateLocalStorageNamespace): (WebKit::StorageManager::getOrCreateTransientLocalStorageNamespace): (WebKit::StorageManager::getOrCreateSessionStorageNamespace): (WebKit::StorageManager::clearStorageNamespaces): (WebKit::StorageManager::addAllowedSessionStorageNamespaceConnection): Deleted. (WebKit::StorageManager::removeAllowedSessionStorageNamespaceConnection): Deleted. (WebKit::StorageManager::processDidCloseConnection): Deleted. (WebKit::StorageManager::deleteLocalStorageEntriesForOrigin): Deleted. (WebKit::StorageManager::createLocalStorageMap): Deleted. (WebKit::StorageManager::createTransientLocalStorageMap): Deleted. (WebKit::StorageManager::createSessionStorageMap): Deleted. (WebKit::StorageManager::destroyStorageMap): Deleted. (WebKit::StorageManager::prewarm): Deleted. (WebKit::StorageManager::getValues): Deleted. (WebKit::StorageManager::setItem): Deleted. (WebKit::StorageManager::setItems): Deleted. (WebKit::StorageManager::removeItem): Deleted. (WebKit::StorageManager::clear): Deleted. (WebKit::StorageManager::waitUntilTasksFinished): Deleted. (WebKit::StorageManager::suspend): Deleted. (WebKit::StorageManager::resume): Deleted. (WebKit::StorageManager::findStorageArea const): Deleted. * NetworkProcess/WebStorage/StorageManager.h: (WebKit::StorageManager::workQueue const): Deleted. (): Deleted. * NetworkProcess/WebStorage/StorageManager.messages.in: Removed. Moved to StorageManagerSet.messages.in. * NetworkProcess/WebStorage/StorageManagerSet.cpp: Added. (WebKit::StorageManagerSet::create): (WebKit::StorageManagerSet::StorageManagerSet): (WebKit::StorageManagerSet::~StorageManagerSet): (WebKit::StorageManagerSet::add): (WebKit::StorageManagerSet::remove): (WebKit::StorageManagerSet::contains): (WebKit::StorageManagerSet::addConnection): (WebKit::StorageManagerSet::removeConnection): (WebKit::StorageManagerSet::waitUntilTasksFinished): (WebKit::StorageManagerSet::waitUntilSyncingLocalStorageFinished): (WebKit::StorageManagerSet::suspend): (WebKit::StorageManagerSet::resume): (WebKit::StorageManagerSet::getSessionStorageOrigins): (WebKit::StorageManagerSet::deleteSessionStorage): (WebKit::StorageManagerSet::deleteSessionStorageForOrigins): (WebKit::StorageManagerSet::getLocalStorageOrigins): (WebKit::StorageManagerSet::deleteLocalStorageModifiedSince): (WebKit::StorageManagerSet::deleteLocalStorageForOrigins): (WebKit::StorageManagerSet::getLocalStorageOriginDetails): (WebKit::StorageManagerSet::connectToLocalStorageArea): (WebKit::StorageManagerSet::connectToTransientLocalStorageArea): (WebKit::StorageManagerSet::connectToSessionStorageArea): (WebKit::StorageManagerSet::disconnectFromStorageArea): (WebKit::StorageManagerSet::getValues): (WebKit::StorageManagerSet::setItem): (WebKit::StorageManagerSet::removeItem): (WebKit::StorageManagerSet::clear): (WebKit::StorageManagerSet::cloneSessionStorageNamespace): * NetworkProcess/WebStorage/StorageManagerSet.h: Added. * NetworkProcess/WebStorage/StorageManagerSet.messages.in: Added. * Shared/WebsiteDataStoreParameters.cpp: creation parameters of StorageManager are moved to WebsiteDataStoreParameters. (WebKit::WebsiteDataStoreParameters::encode const): (WebKit::WebsiteDataStoreParameters::decode): (WebKit::WebsiteDataStoreParameters::privateSessionParameters): * Shared/WebsiteDataStoreParameters.h: * Sources.txt: * UIProcess/API/C/WKContext.cpp: add SPI for tests. (WKContextSyncLocalStorage): (WKContextClearLegacyPrivateBrowsingLocalStorage): * UIProcess/API/C/WKContextPrivate.h: * UIProcess/API/C/WKWebsiteDataStoreRef.cpp: (WKWebsiteDataStoreRemoveLocalStorage): * UIProcess/API/C/WKWebsiteDataStoreRef.h: * UIProcess/WebProcessPool.cpp: (WebKit::WebProcessPool::ensureNetworkProcess): (WebKit::WebProcessPool::syncLocalStorage): (WebKit::WebProcessPool::clearLegacyPrivateBrowsingLocalStorage): * UIProcess/WebProcessPool.h: * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm: (WebKit::WebsiteDataStore::parameters): * UIProcess/WebsiteData/WebsiteDataStore.cpp: (WebKit::WebsiteDataStore::parameters): * WebKit.xcodeproj/project.pbxproj: * WebProcess/InjectedBundle/InjectedBundle.cpp: session change of web storage is done via WebStorageNamespaceProvider instead of WebProcess now. (WebKit::InjectedBundle::setPrivateBrowsingEnabled): * WebProcess/WebProcess.cpp: web process no longer sends messsages about page state to network process. (WebKit::WebProcess::createWebPage): (WebKit::WebProcess::removeWebPage): (WebKit::WebProcess::ensureNetworkProcessConnection): (WebKit::WebProcess::networkProcessConnectionClosed): (WebKit::WebProcess::storageAreaMap const): (WebKit::WebProcess::enablePrivateBrowsingForTesting): Deleted. This was used for changing session via WebProcess. * WebProcess/WebProcess.h: * WebProcess/WebStorage/StorageAreaImpl.cpp: (WebKit::StorageAreaImpl::StorageAreaImpl): (WebKit::StorageAreaImpl::length): (WebKit::StorageAreaImpl::key): (WebKit::StorageAreaImpl::item): (WebKit::StorageAreaImpl::setItem): (WebKit::StorageAreaImpl::removeItem): (WebKit::StorageAreaImpl::clear): (WebKit::StorageAreaImpl::contains): (WebKit::StorageAreaImpl::storageType const): (WebKit::StorageAreaImpl::incrementAccessCount): (WebKit::StorageAreaImpl::decrementAccessCount): (WebKit::StorageAreaImpl::prewarm): Deleted. (WebKit::StorageAreaImpl::securityOrigin const): Deleted. * WebProcess/WebStorage/StorageAreaImpl.h: make StorageAreaImpl hold a weak reference to StorageAreaMap and StorageNamespaceImpl hold a strong reference. In this way lifeime of localStorage StorageAreraMap stays align with StorageNameSpaceProvider and Page. * WebProcess/WebStorage/StorageAreaMap.cpp: identifier of StorageAreaMap is the same as identifier of StorageArea it connects to. If the identifier is 0, it means the StorageAreaMap is disconnected. (WebKit::StorageAreaMap::StorageAreaMap): (WebKit::StorageAreaMap::~StorageAreaMap): (WebKit::StorageAreaMap::setItem): (WebKit::StorageAreaMap::removeItem): (WebKit::StorageAreaMap::clear): (WebKit::StorageAreaMap::resetValues): (WebKit::StorageAreaMap::loadValuesIfNeeded): (WebKit::StorageAreaMap::applyChange): (WebKit::StorageAreaMap::dispatchStorageEvent): (WebKit::StorageAreaMap::dispatchSessionStorageEvent): (WebKit::StorageAreaMap::dispatchLocalStorageEvent): (WebKit::StorageAreaMap::connect): (WebKit::StorageAreaMap::disconnect): (WebKit::generateStorageMapID): Deleted. (WebKit::StorageAreaMap::prewarm): Deleted. (WebKit::StorageAreaMap::didGetValues): Deleted. This is useless as GetValues is a synchronous operation. * WebProcess/WebStorage/StorageAreaMap.h: (): Deleted. * WebProcess/WebStorage/StorageAreaMap.messages.in: there are two synchronous messages, one for connection and one for getting values. We may merge them into one in future improvement. * WebProcess/WebStorage/StorageNamespaceImpl.cpp: (WebKit::StorageNamespaceImpl::createSessionStorageNamespace): (WebKit::StorageNamespaceImpl::createLocalStorageNamespace): (WebKit::StorageNamespaceImpl::createTransientLocalStorageNamespace): (WebKit::StorageNamespaceImpl::StorageNamespaceImpl): (WebKit::StorageNamespaceImpl::storageArea): (WebKit::StorageNamespaceImpl::copy): (WebKit::StorageNamespaceImpl::setSessionIDForTesting): (WebKit::StorageNamespaceImpl::createEphemeralLocalStorageNamespace): Deleted. * WebProcess/WebStorage/StorageNamespaceImpl.h: * WebProcess/WebStorage/WebStorageNamespaceProvider.cpp: (WebKit::WebStorageNamespaceProvider::createSessionStorageNamespace): (WebKit::WebStorageNamespaceProvider::createLocalStorageNamespace): (WebKit::WebStorageNamespaceProvider::createTransientLocalStorageNamespace): (WebKit::WebStorageNamespaceProvider::createEphemeralLocalStorageNamespace): Deleted. * WebProcess/WebStorage/WebStorageNamespaceProvider.h: Source/WebKitLegacy: Do some clean-up and add support for session change of web storage in layout tests. * Storage/StorageAreaImpl.cpp: (WebKit::StorageAreaImpl::sessionChanged): * Storage/StorageAreaImpl.h: (): Deleted. * Storage/StorageAreaSync.h: make sure StorageAreaSync is destructed on the main thread, as it can be dereferenced in StorageAreaImpl::sessionChanged and its last reference for final sync could be released on the background thread. * Storage/StorageNamespaceImpl.cpp: replace EphemeralLocalStorage with LocalStorage, and store SessionID in StorageNamespace. (WebKit::StorageNamespaceImpl::createSessionStorageNamespace): (WebKit::StorageNamespaceImpl::getOrCreateLocalStorageNamespace): (WebKit::StorageNamespaceImpl::StorageNamespaceImpl): (WebKit::StorageNamespaceImpl::copy): (WebKit::StorageNamespaceImpl::close): (WebKit::StorageNamespaceImpl::setSessionIDForTesting): (WebKit::StorageNamespaceImpl::createEphemeralLocalStorageNamespace): Deleted. * Storage/StorageNamespaceImpl.h: * Storage/WebStorageNamespaceProvider.cpp: (WebKit::WebStorageNamespaceProvider::createSessionStorageNamespace): (WebKit::WebStorageNamespaceProvider::createLocalStorageNamespace): (WebKit::WebStorageNamespaceProvider::createTransientLocalStorageNamespace): (WebKit::WebStorageNamespaceProvider::createEphemeralLocalStorageNamespace): Deleted. * Storage/WebStorageNamespaceProvider.h: Source/WebKitLegacy/mac: * WebView/WebView.mm: (-[WebView _preferencesChanged:]): notify storageNamespaceProvider about session change. Tools: * TestWebKitAPI/Tests/WebKitCocoa/LocalStoragePersistence.mm: (TEST): update expectation for behavior change. * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: new SPI to synchronously flush localStorage to database file. * WebKitTestRunner/InjectedBundle/TestRunner.cpp: (WTR::TestRunner::syncLocalStorage): * WebKitTestRunner/InjectedBundle/TestRunner.h: * WebKitTestRunner/TestController.cpp: clear local storage between test runs to make each test isolated. (WTR::TestController::resetStateToConsistentValues): (WTR::StorageVoidCallbackContext::StorageVoidCallbackContext): (WTR::StorageVoidCallback): (WTR::TestController::clearIndexedDatabases): (WTR::TestController::clearLocalStorage): (WTR::TestController::syncLocalStorage): (WTR::RemoveAllIndexedDatabasesCallbackContext::RemoveAllIndexedDatabasesCallbackContext): Deleted. Replaced with StorageVoidCallbackContext for general usage. (WTR::RemoveAllIndexedDatabasesCallback): Deleted. Replaced with StorageVoidCallback. (WTR::TestController::ClearIndexedDatabases): Deleted. Use lowercase for consistent style. * WebKitTestRunner/TestController.h: * WebKitTestRunner/TestInvocation.cpp: (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle): add handler for new message SyncLocalStorage. LayoutTests: Modify tests for a behavior change: sessionStorage will be lost when network process crashes. For tests which use sessionStorage to store items, crash network process, then read from sessionStorage and expect items to be in sessionStorage, replace sessionStorage with localStorage. Also, to make sure localStorage is stored persistently before network process gets terminated, adopt a newly introduced SPI to synchronously flush localStorage content to disk before terminating network process. * platform/ios-simulator-wk2/TestExpectations: * platform/mac-wk2/TestExpectations: * storage/domstorage/localstorage/private-browsing-affects-storage-expected.txt: * storage/indexeddb/IDBObject-leak.html: * storage/indexeddb/modern/opendatabase-after-storage-crash-expected.txt: * storage/indexeddb/modern/opendatabase-after-storage-crash.html: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@248734 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.