Changeset 236959 in webkit
- Timestamp:
- Oct 9, 2018, 2:14:37 AM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 18 edited
- 1 copied
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/WebCore.xcodeproj/project.pbxproj (modified) (4 diffs)
-
WebCore/page/PrewarmInformation.h (copied) (copied from trunk/Source/WebCore/page/ProcessWarming.h ) (1 diff)
-
WebCore/page/ProcessWarming.cpp (modified) (2 diffs)
-
WebCore/page/ProcessWarming.h (modified) (2 diffs)
-
WebCore/platform/graphics/FontCache.cpp (modified) (1 diff)
-
WebCore/platform/graphics/FontCache.h (modified) (4 diffs)
-
WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (modified) (6 diffs)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/UIProcess/WebPageProxy.h (modified) (1 diff)
-
WebKit/UIProcess/WebProcessPool.cpp (modified) (4 diffs)
-
WebKit/UIProcess/WebProcessPool.h (modified) (2 diffs)
-
WebKit/UIProcess/WebProcessProxy.cpp (modified) (2 diffs)
-
WebKit/UIProcess/WebProcessProxy.h (modified) (1 diff)
-
WebKit/UIProcess/WebProcessProxy.messages.in (modified) (1 diff)
-
WebKit/WebProcess/WebPage/WebPage.cpp (modified) (2 diffs)
-
WebKit/WebProcess/WebProcess.cpp (modified) (2 diffs)
-
WebKit/WebProcess/WebProcess.h (modified) (3 diffs)
-
WebKit/WebProcess/WebProcess.messages.in (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r236955 r236959 1 2018-10-09 Antti Koivisto <antti@apple.com> 2 3 Prewarm FontDatabase on process swap 4 https://bugs.webkit.org/show_bug.cgi?id=190312 5 6 Reviewed by Chris Dumez. 7 8 Implement basic prewarming of FontDatabase. When the domain of the first page load on 9 a new process is known we pass the list of font families previous used by that domain to the 10 process. This is used to prewarm CoreText font database. Initialization (which involves lots of 11 blocking IPC) happens outside the main thread so the fonts are ready to use when needed. 12 13 * WebCore.xcodeproj/project.pbxproj: 14 * page/PrewarmInformation.h: Added. 15 (WebCore::PrewarmInformation::encode const): 16 (WebCore::PrewarmInformation::decode): 17 18 Add data structure for prewarm information with encode/decode support. 19 20 * page/ProcessWarming.cpp: 21 (WebCore::ProcessWarming::collectPrewarmInformation): 22 (WebCore::ProcessWarming::prewarmWithInformation): 23 24 Prewarming interface to be used from WebKit. 25 26 * page/ProcessWarming.h: 27 * platform/graphics/FontCache.cpp: 28 (WebCore::FontCache::collectPrewarmInformation const): 29 (WebCore::FontCache::prewarm): 30 * platform/graphics/FontCache.h: 31 * platform/graphics/cocoa/FontCacheCoreText.cpp: 32 (WebCore::FontDatabase::collectionForFamily): 33 (WebCore::FontDatabase::fontForPostScriptName): 34 (WebCore::FontDatabase::clear): 35 36 Add mutex for thread safe access. 37 38 (WebCore::FontCache::createFontPlatformData): 39 (WebCore::FontCache::collectPrewarmInformation const): 40 41 Collect font families seen by this process. 42 43 (WebCore::FontCache::prewarm): 44 45 Prewarm FontDatabase in a dispatch queue. 46 1 47 2018-10-08 Wenson Hsieh <wenson_hsieh@apple.com> 2 48 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r236954 r236959 4760 4760 E44FA1851BCA6B5A0091B6EF /* ComposedTreeIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E44FA1841BCA6B5A0091B6EF /* ComposedTreeIterator.h */; }; 4761 4761 E45322AC140CE267005A0F92 /* SelectorQuery.h in Headers */ = {isa = PBXBuildFile; fileRef = E45322AA140CE267005A0F92 /* SelectorQuery.h */; }; 4762 E4605FEC2166480900E53046 /* PrewarmInformation.h in Headers */ = {isa = PBXBuildFile; fileRef = E4605FEA2166480800E53046 /* PrewarmInformation.h */; settings = {ATTRIBUTES = (Private, ); }; }; 4762 4763 E461802D1C8DD2900026C02C /* StyleRelations.h in Headers */ = {isa = PBXBuildFile; fileRef = E461802C1C8DD2900026C02C /* StyleRelations.h */; }; 4763 4764 E461D65F1BB0C80D00CB5645 /* StyleScope.h in Headers */ = {isa = PBXBuildFile; fileRef = E461D65E1BB0C80D00CB5645 /* StyleScope.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 14512 14513 E453903C0EAFD637003695C8 /* WidgetIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WidgetIOS.mm; sourceTree = "<group>"; }; 14513 14514 E45390AD0EAFF4B5003695C8 /* SystemMemoryIOS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SystemMemoryIOS.cpp; sourceTree = "<group>"; }; 14515 E4605FEA2166480800E53046 /* PrewarmInformation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrewarmInformation.h; sourceTree = "<group>"; }; 14514 14516 E461802C1C8DD2900026C02C /* StyleRelations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleRelations.h; sourceTree = "<group>"; }; 14515 14517 E461802E1C8DD4D20026C02C /* StyleRelations.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleRelations.cpp; sourceTree = "<group>"; }; … … 19689 19691 5CFC434F192406A900A0D3B5 /* PointerLockController.h */, 19690 19692 3772B09516535856000A49CA /* PopupOpeningObserver.h */, 19693 E4605FEA2166480800E53046 /* PrewarmInformation.h */, 19691 19694 B776D43C1104527500BEB0EC /* PrintContext.cpp */, 19692 19695 B776D43A1104525D00BEB0EC /* PrintContext.h */, … … 27731 27734 CE799FAC1C6A50660097B518 /* ContentSecurityPolicySourceListDirective.h in Headers */, 27732 27735 41D015CA0F4B5C71004A662F /* ContentType.h in Headers */, 27736 E4605FEC2166480900E53046 /* PrewarmInformation.h in Headers */, 27733 27737 97627B8E14FB3CEE002CDCA1 /* ContextDestructionObserver.h in Headers */, 27734 27738 93B6A0E60B0BCA5C00F5027A /* ContextMenu.h in Headers */, -
trunk/Source/WebCore/page/PrewarmInformation.h
r236958 r236959 26 26 #pragma once 27 27 28 #include "FontCache.h" 29 #include <wtf/Vector.h> 30 #include <wtf/text/WTFString.h> 31 28 32 namespace WebCore { 29 33 30 class WEBCORE_EXPORT ProcessWarming { 31 public: 32 static void initializeNames(); 33 static void prewarm(); 34 struct WEBCORE_EXPORT PrewarmInformation { 35 FontPrewarmInformation font; 36 37 template<class Encoder> void encode(Encoder&) const; 38 template<class Decoder> static std::optional<PrewarmInformation> decode(Decoder&); 34 39 }; 35 40 41 template<class Encoder> 42 void PrewarmInformation::encode(Encoder& encoder) const 43 { 44 encoder << font; 36 45 } 46 47 template<class Decoder> 48 std::optional<PrewarmInformation> PrewarmInformation::decode(Decoder& decoder) 49 { 50 PrewarmInformation prewarmInfo; 51 if (!decoder.decode(prewarmInfo.font)) 52 return { }; 53 54 return prewarmInfo; 55 } 56 57 } -
trunk/Source/WebCore/page/ProcessWarming.cpp
r235758 r236959 59 59 } 60 60 61 void ProcessWarming::prewarm ()61 void ProcessWarming::prewarmGlobally() 62 62 { 63 63 initializeNames(); … … 77 77 } 78 78 79 WebCore::PrewarmInformation ProcessWarming::collectPrewarmInformation() 80 { 81 PrewarmInformation info; 82 info.font = FontCache::singleton().collectPrewarmInformation(); 83 return info; 79 84 } 85 86 void ProcessWarming::prewarmWithInformation(const PrewarmInformation& prewarmInfo) 87 { 88 FontCache::singleton().prewarm(prewarmInfo.font); 89 } 90 91 } -
trunk/Source/WebCore/page/ProcessWarming.h
r235758 r236959 26 26 #pragma once 27 27 28 #include "PrewarmInformation.h" 29 28 30 namespace WebCore { 29 31 … … 31 33 public: 32 34 static void initializeNames(); 33 static void prewarm(); 35 static void prewarmGlobally(); 36 37 static PrewarmInformation collectPrewarmInformation(); 38 static void prewarmWithInformation(const PrewarmInformation&); 34 39 }; 35 40 -
trunk/Source/WebCore/platform/graphics/FontCache.cpp
r236383 r236959 483 483 484 484 #if !PLATFORM(COCOA) 485 486 FontPrewarmInformation FontCache::collectPrewarmInformation() const 487 { 488 return { }; 489 } 490 491 void FontCache::prewarm(const FontPrewarmInformation&) 492 { 493 } 494 485 495 RefPtr<Font> FontCache::similarFont(const FontDescription&, const AtomicString&) 486 496 { -
trunk/Source/WebCore/platform/graphics/FontCache.h
r236013 r236959 39 39 #include <wtf/RefPtr.h> 40 40 #include <wtf/Vector.h> 41 #include <wtf/WorkQueue.h> 41 42 #include <wtf/text/AtomicStringHash.h> 42 43 #include <wtf/text/WTFString.h> … … 67 68 #endif 68 69 #endif 70 71 using FontPrewarmInformation = Vector<String>; 69 72 70 73 // This key contains the FontDescription fields other than family that matter when fetching FontDatas (platform fonts). … … 236 239 void setShouldMockBoldSystemFontForAccessibility(bool shouldMockBoldSystemFontForAccessibility) { m_shouldMockBoldSystemFontForAccessibility = shouldMockBoldSystemFontForAccessibility; } 237 240 241 FontPrewarmInformation collectPrewarmInformation() const; 242 void prewarm(const FontPrewarmInformation&); 243 238 244 private: 239 245 FontCache(); … … 259 265 260 266 #if PLATFORM(COCOA) 267 HashSet<String> m_seenFamiliesForPrewarming; 268 RefPtr<WorkQueue> m_prewarmQueue; 269 261 270 friend class ComplexTextController; 262 271 #endif -
trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
r236938 r236959 888 888 const InstalledFontFamily& collectionForFamily(const String& familyName) 889 889 { 890 std::lock_guard<Lock> locker(m_descriptorMapLock); 891 890 892 auto folded = familyName.foldCase(); 891 893 return m_familyNameToFontDescriptors.ensure(folded, [&] { … … 912 914 const InstalledFont& fontForPostScriptName(const AtomicString& postScriptName) 913 915 { 916 std::lock_guard<Lock> locker(m_descriptorMapLock); 917 914 918 const auto& folded = FontCascadeDescription::foldedFamilyName(postScriptName); 915 919 return m_postScriptNameToFontDescriptors.ensure(folded, [&] { … … 933 937 void clear() 934 938 { 939 std::lock_guard<Lock> locker(m_descriptorMapLock); 940 935 941 m_familyNameToFontDescriptors.clear(); 936 942 m_postScriptNameToFontDescriptors.clear(); … … 945 951 } 946 952 953 Lock m_descriptorMapLock; 947 954 HashMap<String, InstalledFontFamily> m_familyNameToFontDescriptors; 948 955 HashMap<String, InstalledFont> m_postScriptNameToFontDescriptors; … … 1265 1272 return nullptr; 1266 1273 1274 if (fontDescription.shouldAllowUserInstalledFonts() == AllowUserInstalledFonts::No) 1275 m_seenFamiliesForPrewarming.add(FontCascadeDescription::foldedFamilyName(family)); 1276 1267 1277 bool syntheticBold, syntheticOblique; 1268 1278 std::tie(syntheticBold, syntheticOblique) = computeNecessarySynthesis(font.get(), fontDescription).boldObliquePair(); … … 1503 1513 } 1504 1514 1505 } 1515 FontPrewarmInformation FontCache::collectPrewarmInformation() const 1516 { 1517 FontPrewarmInformation fontPrewarmInformation; 1518 fontPrewarmInformation = copyToVector(m_seenFamiliesForPrewarming); 1519 return fontPrewarmInformation; 1520 } 1521 1522 void FontCache::prewarm(const FontPrewarmInformation& fontPrewarmInformation) 1523 { 1524 auto& families = fontPrewarmInformation; 1525 1526 if (families.isEmpty()) 1527 return; 1528 1529 if (!m_prewarmQueue) 1530 m_prewarmQueue = WorkQueue::create("WebKit font prewarm queue"); 1531 1532 auto& database = FontDatabase::singletonDisallowingUserInstalledFonts(); 1533 1534 m_prewarmQueue->dispatch([&database, families = families.isolatedCopy()] { 1535 for (auto& family : families) 1536 database.collectionForFamily(family); 1537 }); 1538 } 1539 1540 } -
trunk/Source/WebKit/ChangeLog
r236955 r236959 1 2018-10-09 Antti Koivisto <antti@apple.com> 2 3 Prewarm FontDatabase on process swap 4 https://bugs.webkit.org/show_bug.cgi?id=190312 5 6 Reviewed by Chris Dumez. 7 8 Add mechanism for caching prewarm information per domain on UI process side. This information 9 is then passed to newly initialized web processes that are being used for the same domain. 10 11 * UIProcess/WebPageProxy.h: 12 * UIProcess/WebProcessPool.cpp: 13 (WebKit::WebProcessPool::processForNavigationInternal): 14 15 Pass prewarm information on process swap to the new process. 16 17 (WebKit::WebProcessPool::didCollectPrewarmInformation): 18 19 UI process side cache. 20 21 * UIProcess/WebProcessPool.h: 22 * UIProcess/WebProcessProxy.cpp: 23 (WebKit::WebProcessProxy::didCollectPrewarmInformation): 24 * UIProcess/WebProcessProxy.h: 25 * UIProcess/WebProcessProxy.messages.in: 26 * WebProcess/WebPage/WebPage.cpp: 27 (WebKit::WebPage::close): 28 (WebKit::WebPage::didReceivePolicyDecision): 29 30 Collect and cache prewarm information for the previous process on process swap. 31 32 * WebProcess/WebProcess.cpp: 33 (WebKit::WebProcess::prewarmGlobally): 34 35 Renamed for clarity. 36 37 (WebKit::WebProcess::prewarmWithDomainInformation): 38 (WebKit::WebProcess::sendPrewarmInformation): 39 * WebProcess/WebProcess.h: 40 * WebProcess/WebProcess.messages.in: 41 1 42 2018-10-08 Wenson Hsieh <wenson_hsieh@apple.com> 2 43 -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r236939 r236959 191 191 struct GlobalWindowIdentifier; 192 192 struct MediaStreamRequest; 193 struct PrewarmInformation; 193 194 struct SecurityOriginData; 194 195 struct ShareData; -
trunk/Source/WebKit/UIProcess/WebProcessPool.cpp
r236762 r236959 86 86 #include <WebCore/PlatformScreen.h> 87 87 #include <WebCore/Process.h> 88 #include <WebCore/ProcessWarming.h> 88 89 #include <WebCore/ResourceRequest.h> 89 90 #include <WebCore/URLParser.h> … … 737 738 m_prewarmedProcess = &process; 738 739 739 m_prewarmedProcess->send(Messages::WebProcess::Prewarm (), 0);740 m_prewarmedProcess->send(Messages::WebProcess::PrewarmGlobally(), 0); 740 741 } 741 742 … … 2174 2175 2175 2176 action = PolicyAction::Suspend; 2176 if (RefPtr<WebProcessProxy> process = tryTakePrewarmedProcess(page.websiteDataStore())) 2177 2178 if (RefPtr<WebProcessProxy> process = tryTakePrewarmedProcess(page.websiteDataStore())) { 2179 if (auto* prewarmInformation = m_prewarmInformationPerRegistrableDomain.get(toRegistrableDomain(targetURL))) 2180 process->send(Messages::WebProcess::PrewarmWithDomainInformation(*prewarmInformation), 0); 2181 2177 2182 return process.releaseNonNull(); 2183 } 2184 2178 2185 return createNewWebProcess(page.websiteDataStore()); 2179 2186 } … … 2249 2256 } 2250 2257 2258 void WebProcessPool::didCollectPrewarmInformation(const String& registrableDomain, const WebCore::PrewarmInformation& prewarmInformation) 2259 { 2260 static const size_t maximumSizeToPreventUnlimitedGrowth = 100; 2261 if (m_prewarmInformationPerRegistrableDomain.size() == maximumSizeToPreventUnlimitedGrowth) 2262 m_prewarmInformationPerRegistrableDomain.remove(m_prewarmInformationPerRegistrableDomain.begin()); 2263 2264 auto& value = m_prewarmInformationPerRegistrableDomain.ensure(registrableDomain, [] { 2265 return std::make_unique<WebCore::PrewarmInformation>(); 2266 }).iterator->value; 2267 2268 *value = prewarmInformation; 2269 } 2270 2251 2271 } // namespace WebKit -
trunk/Source/WebKit/UIProcess/WebProcessPool.h
r236690 r236959 445 445 void didReachGoodTimeToPrewarm(); 446 446 447 void didCollectPrewarmInformation(const String& registrableDomain, const WebCore::PrewarmInformation&); 448 447 449 void screenPropertiesStateChanged(); 448 450 … … 697 699 HashMap<WebCore::SecurityOriginData, Vector<SuspendedPageProxy*>> m_suspendedPages; 698 700 HashMap<String, RefPtr<WebProcessProxy>> m_swappedProcessesPerRegistrableDomain; 701 702 HashMap<String, std::unique_ptr<WebCore::PrewarmInformation>> m_prewarmInformationPerRegistrableDomain; 699 703 }; 700 704 -
trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp
r236773 r236959 54 54 #include "WebsiteDataFetchOption.h" 55 55 #include <WebCore/DiagnosticLoggingKeys.h> 56 #include <WebCore/PrewarmInformation.h> 56 57 #include <WebCore/PublicSuffix.h> 57 58 #include <WebCore/SuddenTermination.h> … … 1434 1435 } 1435 1436 1437 void WebProcessProxy::didCollectPrewarmInformation(const String& domain, const WebCore::PrewarmInformation& prewarmInformation) 1438 { 1439 processPool().didCollectPrewarmInformation(domain, prewarmInformation); 1440 } 1441 1436 1442 #if PLATFORM(WATCHOS) 1437 1443 -
trunk/Source/WebKit/UIProcess/WebProcessProxy.h
r236773 r236959 315 315 bool canTerminateChildProcess(); 316 316 317 void didCollectPrewarmInformation(const String& domain, const WebCore::PrewarmInformation&); 318 317 319 void logDiagnosticMessageForResourceLimitTermination(const String& limitKey); 318 320 -
trunk/Source/WebKit/UIProcess/WebProcessProxy.messages.in
r236773 r236959 65 65 DidCheckProcessLocalPortForActivity(uint64_t callbackIdentifier, bool isLocallyReachable) 66 66 67 DidCollectPrewarmInformation(String domain, struct WebCore::PrewarmInformation prewarmInformation) 68 67 69 #if PLATFORM(COCOA) 68 70 CacheMediaMIMETypes(Vector<String> types) -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r236867 r236959 1174 1174 1175 1175 // If there is still no URL, then we never loaded anything in this page, so nothing to report. 1176 if (!mainWebFrame()->url().isEmpty()) 1176 if (!mainWebFrame()->url().isEmpty()) { 1177 1177 reportUsedFeatures(); 1178 1179 WebProcess::singleton().sendPrewarmInformation(toRegistrableDomain(mainWebFrame()->url())); 1180 } 1178 1181 1179 1182 if (pageGroup()->isVisibleToInjectedBundle() && WebProcess::singleton().injectedBundle()) … … 2874 2877 ASSERT(frame == m_mainFrame); 2875 2878 setIsSuspended(true); 2879 2880 WebProcess::singleton().sendPrewarmInformation(toRegistrableDomain(mainWebFrame()->url())); 2876 2881 } 2877 2882 frame->didReceivePolicyDecision(listenerID, policyAction, navigationID, downloadID, WTFMove(websitePolicies)); -
trunk/Source/WebKit/WebProcess/WebProcess.cpp
r236690 r236959 421 421 } 422 422 423 void WebProcess::prewarm() 424 { 425 WebCore::ProcessWarming::prewarm(); 423 void WebProcess::prewarmGlobally() 424 { 425 WebCore::ProcessWarming::prewarmGlobally(); 426 } 427 428 void WebProcess::prewarmWithDomainInformation(const WebCore::PrewarmInformation& prewarmInformation) 429 { 430 WebCore::ProcessWarming::prewarmWithInformation(prewarmInformation); 426 431 } 427 432 … … 1460 1465 } 1461 1466 1467 void WebProcess::sendPrewarmInformation(const String& registrableDomain) 1468 { 1469 if (registrableDomain.isEmpty()) 1470 return; 1471 parentProcessConnection()->send(Messages::WebProcessProxy::DidCollectPrewarmInformation(registrableDomain, WebCore::ProcessWarming::collectPrewarmInformation()), 0); 1472 } 1473 1462 1474 void WebProcess::pageDidEnterWindow(uint64_t pageID) 1463 1475 { -
trunk/Source/WebKit/WebProcess/WebProcess.h
r236690 r236959 72 72 struct MockMediaDevice; 73 73 struct PluginInfo; 74 struct PrewarmInformation; 74 75 struct SecurityOriginData; 75 76 struct SoupNetworkProxySettings; … … 201 202 void processDidResume(); 202 203 204 void sendPrewarmInformation(const String& registrableDomain); 205 203 206 #if PLATFORM(IOS) 204 207 void resetAllGeolocationPermissions(); … … 246 249 void platformInitializeWebProcess(WebProcessCreationParameters&&); 247 250 248 void prewarm(); 251 void prewarmGlobally(); 252 void prewarmWithDomainInformation(const WebCore::PrewarmInformation&); 249 253 250 254 #if USE(OS_STATE) -
trunk/Source/WebKit/WebProcess/WebProcess.messages.in
r236546 r236959 27 27 CreateWebPage(uint64_t newPageID, struct WebKit::WebPageCreationParameters pageCreationParameters) 28 28 29 Prewarm(); 30 29 PrewarmGlobally(); 30 PrewarmWithDomainInformation(struct WebCore::PrewarmInformation prewarmInformation) 31 31 32 # Global preferences. 32 33 SetCacheModel(uint32_t cacheModel)
Note:
See TracChangeset
for help on using the changeset viewer.