Changeset 241928 in webkit
- Timestamp:
- Feb 21, 2019 6:58:40 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r241926 r241928 1 2019-02-21 Ryosuke Niwa <rniwa@webkit.org> 2 3 Discard cached processes when clearing website data store 4 https://bugs.webkit.org/show_bug.cgi?id=194894 5 6 Reviewed by Chris Dumez. 7 8 Clear the process cache when clearing the website data store so that there is no way to infer 9 which site the user had visited by observing for which sites WebContent processes had been cached. 10 11 There is one sublty in WebsiteDataStore::removeData that we have to delay the clearing of 12 the web process cache until the next run loop because SuspendedPageProxy::~SuspendedPageProxy 13 invokes WebProcessProxy::maybeShutDown in the next run loop. We also have to disable the process 14 cache during this time as it would otherwise trigger the responsiveness check of WebContent process 15 can take arbitrarily long time. 16 17 * UIProcess/API/Cocoa/WKProcessPool.mm: 18 (-[WKProcessPool _processCacheCapacity]): Added for testing. 19 * UIProcess/API/Cocoa/WKProcessPoolPrivate.h: 20 * UIProcess/WebProcessCache.cpp: 21 (WebKit::WebProcessCache::addProcess): Avoid adding web processes to the cache while the suspended 22 pages are being cleared. 23 * UIProcess/WebProcessCache.h: 24 (WebKit::WebProcessCache::disabled const): Added. 25 (WebKit::WebProcessCache::setDisabled): Added. 26 * UIProcess/WebProcessPool.cpp: 27 (WebKit::WebProcessPool::handleMemoryPressureWarning): 28 (WebKit::WebProcessPool::clearSuspendedPages): Added. 29 * UIProcess/WebProcessPool.h: 30 * UIProcess/WebsiteData/WebsiteDataStore.cpp: 31 (WebKit::WebsiteDataStore::removeData): 32 1 33 2019-02-21 Alex Christensen <achristensen@webkit.org> 2 34 -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPool.mm
r241556 r241928 515 515 } 516 516 517 - (NSUInteger)_processCacheCapacity 518 { 519 return _processPool->webProcessCache().capacity(); 520 } 521 517 522 - (size_t)_serviceWorkerProcessCount 518 523 { -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKProcessPoolPrivate.h
r241556 r241928 104 104 - (void)_makeNextNetworkProcessLaunchFailForTesting WK_API_AVAILABLE(macosx(10.14), ios(12.0)); 105 105 - (NSUInteger)_maximumSuspendedPageCount WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); 106 - (NSUInteger)_processCacheCapacity WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); 106 107 107 108 // Test only. Returns web processes running web pages (does not include web processes running service workers) -
trunk/Source/WebKit/UIProcess/WebProcessCache.cpp
r241919 r241928 52 52 ASSERT(!process->processPool().hasSuspendedPageFor(process)); 53 53 54 if (!capacity() )54 if (!capacity() || m_isDisabled) 55 55 return false; 56 56 … … 86 86 ASSERT(!process->processPool().hasSuspendedPageFor(process)); 87 87 88 if (!capacity() )88 if (!capacity() || m_isDisabled) 89 89 return false; 90 90 -
trunk/Source/WebKit/UIProcess/WebProcessCache.h
r241855 r241928 50 50 unsigned size() const { return m_processesPerRegistrableDomain.size(); } 51 51 52 void setIsDisabled(bool isDisabled) { m_isDisabled = isDisabled; } 53 52 54 void clear(); 53 55 void setApplicationIsActive(bool); … … 62 64 63 65 unsigned m_capacity { 0 }; 66 bool m_isDisabled { false }; 64 67 65 68 class CachedProcess { -
trunk/Source/WebKit/UIProcess/WebProcessPool.cpp
r241778 r241928 1341 1341 ASSERT(!m_prewarmedProcess); 1342 1342 1343 m_suspendedPages.clear();1343 clearSuspendedPages(); 1344 1344 } 1345 1345 … … 2353 2353 } 2354 2354 2355 void WebProcessPool::clearSuspendedPages() 2356 { 2357 m_suspendedPages.clear(); 2358 } 2359 2355 2360 void WebProcessPool::addMockMediaDevice(const MockMediaDevice& device) 2356 2361 { -
trunk/Source/WebKit/UIProcess/WebProcessPool.h
r241778 r241928 469 469 unsigned maxSuspendedPageCount() const { return m_maxSuspendedPageCount; } 470 470 RefPtr<WebProcessProxy> findReusableSuspendedPageProcess(const String&, WebPageProxy&); 471 void clearSuspendedPages(); 471 472 472 473 void didReachGoodTimeToPrewarm(); -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
r241826 r241928 37 37 #include "StorageAccessStatus.h" 38 38 #include "StorageManager.h" 39 #include "WebProcessCache.h" 39 40 #include "WebProcessMessages.h" 40 41 #include "WebProcessPool.h" … … 779 780 auto webProcessAccessType = computeWebProcessAccessTypeForDataRemoval(dataTypes, !isPersistent()); 780 781 if (webProcessAccessType != ProcessAccessType::None) { 782 for (auto& processPool : processPools()) { 783 processPool->webProcessCache().setIsDisabled(true); 784 processPool->clearSuspendedPages(); 785 // FIXME: We need to delay the clearing of the process cache because ~SuspendedPageProxy() calls maybeShutDown asynchronously. 786 RunLoop::main().dispatch([pool = makeRef(*processPool)] { 787 pool->webProcessCache().clear(); 788 pool->webProcessCache().setIsDisabled(false); 789 }); 790 } 791 781 792 for (auto& process : processes()) { 782 793 switch (webProcessAccessType) { -
trunk/Tools/ChangeLog
r241926 r241928 1 2019-02-21 Ryosuke Niwa <rniwa@webkit.org> 2 3 Discard cached processes when clearing website data store 4 https://bugs.webkit.org/show_bug.cgi?id=194894 5 6 Reviewed by Chris Dumez. 7 8 Added a test case. 9 10 * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm: 11 (TestWebKitAPI.ProcessSwap.NumberOfCachedProcesses): Added. 12 1 13 2019-02-21 Alex Christensen <achristensen@webkit.org> 2 14 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm
r241917 r241928 53 53 #import <wtf/RetainPtr.h> 54 54 #import <wtf/Vector.h> 55 #import <wtf/text/StringConcatenateNumbers.h> 55 56 #import <wtf/text/StringHash.h> 56 57 #import <wtf/text/WTFString.h> … … 3057 3058 EXPECT_EQ(2u, [processPool _webProcessCountIgnoringPrewarmedAndCached]); 3058 3059 EXPECT_TRUE([processPool _hasPrewarmedWebProcess]); 3060 } 3061 3062 TEST(ProcessSwap, NumberOfCachedProcesses) 3063 { 3064 auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]); 3065 processPoolConfiguration.get().processSwapsOnNavigation = YES; 3066 processPoolConfiguration.get().usesWebProcessCache = YES; 3067 processPoolConfiguration.get().prewarmsProcessesAutomatically = NO; 3068 auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]); 3069 3070 EXPECT_GT([processPool _maximumSuspendedPageCount], 0u); 3071 EXPECT_GT([processPool _processCacheCapacity], 0u); 3072 3073 auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]); 3074 [webViewConfiguration setProcessPool:processPool.get()]; 3075 auto handler = adoptNS([[PSONScheme alloc] init]); 3076 3077 const unsigned maxSuspendedPageCount = [processPool _maximumSuspendedPageCount]; 3078 for (unsigned i = 0; i < maxSuspendedPageCount + 2; i++) 3079 [handler addMappingFromURLString:makeString("pson://www.domain-", i, ".com") toData:pageCache1Bytes]; 3080 [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"PSON"]; 3081 3082 auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]); 3083 auto delegate = adoptNS([[PSONNavigationDelegate alloc] init]); 3084 [webView setNavigationDelegate:delegate.get()]; 3085 3086 for (unsigned i = 0; i < maxSuspendedPageCount + 1; i++) { 3087 NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:makeString("pson://www.domain-", i, ".com")]]; 3088 [webView loadRequest:request]; 3089 TestWebKitAPI::Util::run(&done); 3090 done = false; 3091 3092 EXPECT_EQ(i + 1, [processPool _webProcessCount]); 3093 EXPECT_EQ(i + 1, [processPool _webProcessCountIgnoringPrewarmedAndCached]); 3094 EXPECT_FALSE([processPool _hasPrewarmedWebProcess]); 3095 } 3096 3097 NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:makeString("pson://www.domain-", maxSuspendedPageCount + 1, ".com")]]; 3098 [webView loadRequest:request]; 3099 TestWebKitAPI::Util::run(&done); 3100 done = false; 3101 3102 EXPECT_EQ(maxSuspendedPageCount + 2, [processPool _webProcessCount]); 3103 EXPECT_EQ(maxSuspendedPageCount + 1, [processPool _webProcessCountIgnoringPrewarmedAndCached]); 3104 EXPECT_FALSE([processPool _hasPrewarmedWebProcess]); 3105 3106 static bool readyToContinue = false; 3107 [[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:[WKWebsiteDataStore _allWebsiteDataTypesIncludingPrivate] modifiedSince:[NSDate distantPast] completionHandler:^() { 3108 readyToContinue = true; 3109 }]; 3110 TestWebKitAPI::Util::run(&readyToContinue); 3111 3112 EXPECT_EQ(1u, [processPool _webProcessCount]); 3113 EXPECT_EQ(1u, [processPool _webProcessCountIgnoringPrewarmedAndCached]); 3114 EXPECT_FALSE([processPool _hasPrewarmedWebProcess]); 3115 3059 3116 } 3060 3117
Note: See TracChangeset
for help on using the changeset viewer.