Prewarm FontDatabase on process swap
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Oct 2018 09:14:37 +0000 (09:14 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 9 Oct 2018 09:14:37 +0000 (09:14 +0000)
commit60c17ca2bde4658b0f970847efe1d1fc8999a754
tree4d4abbd26cafff57ecdb2c548674d52753ff6858
parent89703cb8b88e3e23b27b0fe28dc113469f4f8258
Prewarm FontDatabase on process swap
https://bugs.webkit.org/show_bug.cgi?id=190312

Reviewed by Chris Dumez.

Source/WebCore:

Implement basic prewarming of FontDatabase. When the domain of the first page load on
a new process is known we pass the list of font families previous used by that domain to the
process. This is used to prewarm CoreText font database. Initialization (which involves lots of
blocking IPC) happens outside the main thread so the fonts are ready to use when needed.

* WebCore.xcodeproj/project.pbxproj:
* page/PrewarmInformation.h: Added.
(WebCore::PrewarmInformation::encode const):
(WebCore::PrewarmInformation::decode):

Add data structure for prewarm information with encode/decode support.

* page/ProcessWarming.cpp:
(WebCore::ProcessWarming::collectPrewarmInformation):
(WebCore::ProcessWarming::prewarmWithInformation):

Prewarming interface to be used from WebKit.

* page/ProcessWarming.h:
* platform/graphics/FontCache.cpp:
(WebCore::FontCache::collectPrewarmInformation const):
(WebCore::FontCache::prewarm):
* platform/graphics/FontCache.h:
* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::FontDatabase::collectionForFamily):
(WebCore::FontDatabase::fontForPostScriptName):
(WebCore::FontDatabase::clear):

Add mutex for thread safe access.

(WebCore::FontCache::createFontPlatformData):
(WebCore::FontCache::collectPrewarmInformation const):

Collect font families seen by this process.

(WebCore::FontCache::prewarm):

Prewarm FontDatabase in a dispatch queue.

Source/WebKit:

Add mechanism for caching prewarm information per domain on UI process side. This information
is then passed to newly initialized web processes that are being used for the same domain.

* UIProcess/WebPageProxy.h:
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::processForNavigationInternal):

Pass prewarm information on process swap to the new process.

(WebKit::WebProcessPool::didCollectPrewarmInformation):

UI process side cache.

* UIProcess/WebProcessPool.h:
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::didCollectPrewarmInformation):
* UIProcess/WebProcessProxy.h:
* UIProcess/WebProcessProxy.messages.in:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::close):
(WebKit::WebPage::didReceivePolicyDecision):

Collect and cache prewarm information for the previous process on process swap.

* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::prewarmGlobally):

Renamed for clarity.

(WebKit::WebProcess::prewarmWithDomainInformation):
(WebKit::WebProcess::sendPrewarmInformation):
* WebProcess/WebProcess.h:
* WebProcess/WebProcess.messages.in:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236959 268f45cc-cd09-0410-ab3c-d52691b4dbfc
19 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/page/PrewarmInformation.h [new file with mode: 0644]
Source/WebCore/page/ProcessWarming.cpp
Source/WebCore/page/ProcessWarming.h
Source/WebCore/platform/graphics/FontCache.cpp
Source/WebCore/platform/graphics/FontCache.h
Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/WebPageProxy.h
Source/WebKit/UIProcess/WebProcessPool.cpp
Source/WebKit/UIProcess/WebProcessPool.h
Source/WebKit/UIProcess/WebProcessProxy.cpp
Source/WebKit/UIProcess/WebProcessProxy.h
Source/WebKit/UIProcess/WebProcessProxy.messages.in
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKit/WebProcess/WebProcess.cpp
Source/WebKit/WebProcess/WebProcess.h
Source/WebKit/WebProcess/WebProcess.messages.in