Changeset 251048 in webkit
- Timestamp:
- Oct 12, 2019 9:17:52 AM (5 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r251045 r251048 1 2019-10-12 Chris Dumez <cdumez@apple.com> 2 3 Clearing Website data for a given session should not shut down cached processes for other sessions 4 https://bugs.webkit.org/show_bug.cgi?id=202865 5 <rdar://problem/56202912> 6 7 Reviewed by Antti Koivisto. 8 9 When clearing Website data for a given data store, we now only clear cached processes 10 (either if BackForwardCache or WebProcessCache) if they are associated with this 11 particular data store. It is very wasteful otherwise. 12 13 * UIProcess/ProvisionalPageProxy.cpp: 14 (WebKit::ProvisionalPageProxy::~ProvisionalPageProxy): 15 * UIProcess/SuspendedPageProxy.cpp: 16 (WebKit::SuspendedPageProxy::~SuspendedPageProxy): 17 ProvisionalPageProxy & SuspendedPageProxy's destructors no longer call 18 WebProcessProxy::maybeShutdown() asynchronously. We now call maybeShutdown() 19 synchronously in WebProcessProxy::decrementSuspendedPageCount() and 20 WebProcessProxy::removeProvisionalPageProxy() instead. This makes things a 21 lot more predictable. 22 23 * UIProcess/WebBackForwardCache.cpp: 24 (WebKit::WebBackForwardCache::removeEntriesForSession): 25 Add new removeEntriesForSession() method to clear only back / forward cache 26 entries associated with a particular session. 27 28 (WebKit::WebBackForwardCache::clear): 29 Stop taking a parameter indicating if we allow the processes to enter the 30 process cache. Now that we call maybeShutdown() synchronously when destroying 31 a SuspendedPageProxy, we can simply allow the processes to enter the process 32 cache unconditionally. If the caller does not want this processes in the page 33 cache, they can clear the process cache afterwards. 34 35 * UIProcess/WebBackForwardCache.h: 36 * UIProcess/WebPageProxy.cpp: 37 (WebKit::WebPageProxy::receivedNavigationPolicyDecision): 38 Now that destroying a SuspendedPageProxy or a ProvisionalPageProxy may shutdown 39 their process synchronously, add a scope here to prevent shutdown of the process 40 for the duration of this scope, since we're about to use it for a navigation and 41 we don't want it to get shutdown, even if there is no longer anything using it. 42 43 (WebKit::WebPageProxy::continueNavigationInNewProcess): 44 Add new assertion and rename parameter for consistency. 45 46 * UIProcess/WebProcessPool.cpp: 47 (WebKit::WebProcessPool::handleMemoryPressureWarning): 48 49 * UIProcess/WebProcessProxy.cpp: 50 (WebKit::WebProcessProxy::addProvisionalPageProxy): 51 Add new assertion. 52 53 (WebKit::WebProcessProxy::removeProvisionalPageProxy): 54 Call maybeShutDown() if this was the last provisional page. 55 56 (WebKit::WebProcessProxy::maybeShutDown): 57 Drop parameter indicating if we want to allow the process to enter the process 58 cache and allow caching unconditionally. 59 60 (WebKit::WebProcessProxy::canTerminateAuxiliaryProcess): 61 Prevent termination if there is a ScopePreventingShutdown. 62 63 (WebKit::WebProcessProxy::decrementSuspendedPageCount): 64 Call maybeShutDown() if this was the last suspended page. 65 66 * UIProcess/WebProcessProxy.h: 67 (WebKit::WebProcessProxy::ScopePreventingShutdown::ScopePreventingShutdown): 68 (WebKit::WebProcessProxy::ScopePreventingShutdown::~ScopePreventingShutdown): 69 (WebKit::WebProcessProxy::makeScopePreventingShutdown): 70 Add new facility to prevent shutdown of a process for the duration of the scope. 71 72 * UIProcess/WebsiteData/WebsiteDataStore.cpp: 73 (WebKit::WebsiteDataStore::removeData): 74 When removing website data, only clear cached processes if they are associated with 75 the current data store. 76 1 77 2019-10-12 Chris Fleizach <cfleizach@apple.com> 2 78 -
trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.cpp
r249329 r251048 89 89 ProvisionalPageProxy::~ProvisionalPageProxy() 90 90 { 91 if (!m_wasCommitted) { 92 if (&m_process->websiteDataStore() != &m_page.websiteDataStore()) 93 m_process->processPool().pageEndUsingWebsiteDataStore(m_page.identifier(), m_process->websiteDataStore()); 94 95 m_process->removeMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_webPageID); 96 m_process->send(Messages::WebPage::Close(), m_webPageID); 97 m_process->removeVisitedLinkStoreUser(m_page.visitedLinkStore(), m_page.identifier()); 98 } 99 91 100 m_process->removeProvisionalPageProxy(*this); 92 93 if (m_wasCommitted)94 return;95 96 if (&m_process->websiteDataStore() != &m_page.websiteDataStore())97 m_process->processPool().pageEndUsingWebsiteDataStore(m_page.identifier(), m_process->websiteDataStore());98 99 m_process->removeMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_webPageID);100 m_process->send(Messages::WebPage::Close(), m_webPageID);101 m_process->removeVisitedLinkStoreUser(m_page.visitedLinkStore(), m_page.identifier());102 103 RunLoop::main().dispatch([process = m_process.copyRef()] {104 process->maybeShutDown();105 });106 101 } 107 102 -
trunk/Source/WebKit/UIProcess/SuspendedPageProxy.cpp
r251022 r251048 117 117 SuspendedPageProxy::~SuspendedPageProxy() 118 118 { 119 m_process->decrementSuspendedPageCount();120 119 allSuspendedPages().remove(this); 121 120 … … 126 125 } 127 126 128 if (m_suspensionState == SuspensionState::Resumed) 129 return; 130 131 // If the suspended page was not consumed before getting destroyed, then close the corresponding page 132 // on the WebProcess side. 133 close(); 134 135 if (m_suspensionState == SuspensionState::Suspending) 136 m_process->removeMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_webPageID); 137 138 // We call maybeShutDown() asynchronously since the SuspendedPage is currently being removed from the WebProcessPool 139 // and we want to avoid re-entering WebProcessPool methods. 140 RunLoop::main().dispatch([process = m_process.copyRef()] { 141 process->maybeShutDown(); 142 }); 127 if (m_suspensionState != SuspensionState::Resumed) { 128 // If the suspended page was not consumed before getting destroyed, then close the corresponding page 129 // on the WebProcess side. 130 close(); 131 132 if (m_suspensionState == SuspensionState::Suspending) 133 m_process->removeMessageReceiver(Messages::WebPageProxy::messageReceiverName(), m_webPageID); 134 } 135 136 m_process->decrementSuspendedPageCount(); 143 137 } 144 138 -
trunk/Source/WebKit/UIProcess/WebBackForwardCache.cpp
r251022 r251048 31 31 #include "WebPageProxy.h" 32 32 #include "WebProcessProxy.h" 33 #include "WebsiteDataStore.h" 33 34 34 35 namespace WebKit { … … 84 85 } 85 86 87 void WebBackForwardCache::removeEntriesForSession(PAL::SessionID sessionID) 88 { 89 removeEntriesMatching([sessionID](auto& item) { 90 return item.suspendedPage()->process().websiteDataStore().sessionID() == sessionID; 91 }); 92 } 93 86 94 void WebBackForwardCache::removeEntriesForPage(WebPageProxy& page) 87 95 { … … 103 111 } 104 112 105 void WebBackForwardCache::clear( AllowProcessCaching allowProcessCaching)113 void WebBackForwardCache::clear() 106 114 { 107 115 auto itemsWithCachedPage = WTFMove(m_itemsWithCachedPage); 108 for (auto* item : itemsWithCachedPage) { 109 auto process = makeRef(item->suspendedPage()->process()); 116 for (auto* item : itemsWithCachedPage) 110 117 item->setSuspendedPage(nullptr); 111 process->maybeShutDown(allowProcessCaching);112 }113 118 } 114 119 -
trunk/Source/WebKit/UIProcess/WebBackForwardCache.h
r251022 r251048 26 26 #pragma once 27 27 28 #include <pal/SessionID.h> 28 29 #include <wtf/Forward.h> 29 30 #include <wtf/ListHashSet.h> … … 35 36 class WebPageProxy; 36 37 class WebProcessProxy; 37 enum class AllowProcessCaching;38 38 39 39 class WebBackForwardCache { … … 47 47 unsigned size() const { return m_itemsWithCachedPage.size(); } 48 48 49 void clear( AllowProcessCaching);49 void clear(); 50 50 void removeEntriesForProcess(WebProcessProxy&); 51 51 void removeEntriesForPage(WebPageProxy&); 52 void removeEntriesForSession(PAL::SessionID); 52 53 53 54 void addEntry(WebBackForwardListItem&, std::unique_ptr<SuspendedPageProxy>&&); -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r251022 r251048 2955 2955 2956 2956 if (shouldProcessSwap) { 2957 // Make sure the process to be used for the navigation does not get shutDown now due to destroying SuspendedPageProxy or ProvisionalPageProxy objects. 2958 auto preventNavigationProcessShutdown = processForNavigation->makeScopePreventingShutdown(); 2959 2957 2960 auto suspendedPage = destinationSuspendedPage ? backForwardCache().takeEntry(*destinationSuspendedPage->backForwardListItem()) : nullptr; 2958 2961 if (suspendedPage && suspendedPage->pageIsClosedOrClosing()) … … 3036 3039 } 3037 3040 3038 void WebPageProxy::continueNavigationInNewProcess(API::Navigation& navigation, std::unique_ptr<SuspendedPageProxy>&& suspendedPage Proxy, Ref<WebProcessProxy>&& newProcess, ProcessSwapRequestedByClient processSwapRequestedByClient, Optional<WebsitePoliciesData>&& websitePolicies)3039 { 3040 RELEASE_LOG_IF_ALLOWED(Loading, "continueNavigationInNewProcess: newProcessPID = %i, hasSuspendedPage = %i", newProcess->processIdentifier(), !!suspendedPage Proxy);3041 void WebPageProxy::continueNavigationInNewProcess(API::Navigation& navigation, std::unique_ptr<SuspendedPageProxy>&& suspendedPage, Ref<WebProcessProxy>&& newProcess, ProcessSwapRequestedByClient processSwapRequestedByClient, Optional<WebsitePoliciesData>&& websitePolicies) 3042 { 3043 RELEASE_LOG_IF_ALLOWED(Loading, "continueNavigationInNewProcess: newProcessPID = %i, hasSuspendedPage = %i", newProcess->processIdentifier(), !!suspendedPage); 3041 3044 LOG(Loading, "Continuing navigation %" PRIu64 " '%s' in a new web process", navigation.navigationID(), navigation.loggingString()); 3045 RELEASE_ASSERT(!newProcess->isInProcessCache()); 3042 3046 3043 3047 if (m_provisionalPage) { … … 3048 3052 } 3049 3053 3050 m_provisionalPage = makeUnique<ProvisionalPageProxy>(*this, newProcess.copyRef(), WTFMove(suspendedPage Proxy), navigation.navigationID(), navigation.currentRequestIsRedirect(), navigation.currentRequest(), processSwapRequestedByClient);3054 m_provisionalPage = makeUnique<ProvisionalPageProxy>(*this, newProcess.copyRef(), WTFMove(suspendedPage), navigation.navigationID(), navigation.currentRequestIsRedirect(), navigation.currentRequest(), processSwapRequestedByClient); 3051 3055 3052 3056 if (auto* item = navigation.targetItem()) { -
trunk/Source/WebKit/UIProcess/WebProcessPool.cpp
r251041 r251048 1387 1387 RELEASE_LOG(PerformanceLogging, "%p - WebProcessPool::handleMemoryPressureWarning", this); 1388 1388 1389 1390 m_backForwardCache->clear(AllowProcessCaching::No); 1389 // Clear back/forward cache first as processes removed from the back/forward cache will likely 1390 // be added to the WebProcess cache. 1391 m_backForwardCache->clear(); 1391 1392 m_webProcessCache->clear(); 1392 1393 -
trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp
r250799 r251048 249 249 void WebProcessProxy::addProvisionalPageProxy(ProvisionalPageProxy& provisionalPage) 250 250 { 251 ASSERT(!m_isInProcessCache); 251 252 ASSERT(!m_provisionalPages.contains(&provisionalPage)); 252 253 m_provisionalPages.add(&provisionalPage); … … 259 260 m_provisionalPages.remove(&provisionalPage); 260 261 updateRegistrationWithDataStore(); 262 if (m_provisionalPages.isEmpty()) 263 maybeShutDown(); 261 264 } 262 265 … … 938 941 } 939 942 940 void WebProcessProxy::maybeShutDown( AllowProcessCaching allowProcessCaching)943 void WebProcessProxy::maybeShutDown() 941 944 { 942 945 if (processPool().dummyProcessProxy() == this && m_pageMap.isEmpty()) { … … 949 952 return; 950 953 951 if ( allowProcessCaching == AllowProcessCaching::Yes &&canBeAddedToWebProcessCache() && processPool().webProcessCache().addProcessIfPossible(*this))954 if (canBeAddedToWebProcessCache() && processPool().webProcessCache().addProcessIfPossible(*this)) 952 955 return; 953 956 … … 957 960 bool WebProcessProxy::canTerminateAuxiliaryProcess() 958 961 { 959 if (!m_pageMap.isEmpty() || m_suspendedPageCount || !m_provisionalPages.isEmpty() || m_isInProcessCache )962 if (!m_pageMap.isEmpty() || m_suspendedPageCount || !m_provisionalPages.isEmpty() || m_isInProcessCache || m_shutdownPreventingScopeCount) 960 963 return false; 961 964 … … 1484 1487 ASSERT(m_suspendedPageCount); 1485 1488 --m_suspendedPageCount; 1486 if (!m_suspendedPageCount) 1489 if (!m_suspendedPageCount) { 1487 1490 send(Messages::WebProcess::SetHasSuspendedPageProxy(false), 0); 1491 maybeShutDown(); 1492 } 1488 1493 } 1489 1494 -
trunk/Source/WebKit/UIProcess/WebProcessProxy.h
r250799 r251048 95 95 #endif 96 96 97 enum class AllowProcessCaching { No, Yes };98 99 97 class WebProcessProxy : public AuxiliaryProcessProxy, public ResponsivenessTimer::Client, public ThreadSafeRefCounted<WebProcessProxy>, public CanMakeWeakPtr<WebProcessProxy>, private ProcessThrottlerClient { 100 98 public: … … 273 271 // Will potentially cause the WebProcessProxy object to be freed. 274 272 void shutDown(); 275 void maybeShutDown(AllowProcessCaching = AllowProcessCaching::Yes); 273 274 class ScopePreventingShutdown { 275 public: 276 explicit ScopePreventingShutdown(WebProcessProxy& process) 277 : m_process(process) 278 { 279 ++(m_process->m_shutdownPreventingScopeCount); 280 } 281 282 ~ScopePreventingShutdown() 283 { 284 ASSERT(m_process->m_shutdownPreventingScopeCount); 285 if (!--(m_process->m_shutdownPreventingScopeCount)) 286 m_process->maybeShutDown(); 287 } 288 289 private: 290 Ref<WebProcessProxy> m_process; 291 }; 292 293 ScopePreventingShutdown makeScopePreventingShutdown() { return ScopePreventingShutdown { *this }; } 276 294 277 295 void didStartProvisionalLoadForMainFrame(const URL&); … … 405 423 void updateRegistrationWithDataStore(); 406 424 425 void maybeShutDown(); 426 407 427 enum class IsWeak { No, Yes }; 408 428 template<typename T> class WeakOrStrongPtr { … … 483 503 484 504 unsigned m_suspendedPageCount { 0 }; 505 unsigned m_shutdownPreventingScopeCount { 0 }; 485 506 bool m_hasCommittedAnyProvisionalLoads { false }; 486 507 bool m_isPrewarmed; -
trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
r251022 r251048 727 727 if (webProcessAccessType != ProcessAccessType::None) { 728 728 for (auto& processPool : processPools()) { 729 processPool->backForwardCache().clear(AllowProcessCaching::No); 730 processPool->webProcessCache().clear(); 729 // Clear back/forward cache first as processes removed from the back/forward cache will likely 730 // be added to the WebProcess cache. 731 processPool->backForwardCache().removeEntriesForSession(sessionID()); 732 processPool->webProcessCache().clearAllProcessesForSession(sessionID()); 731 733 } 732 734
Note: See TracChangeset
for help on using the changeset viewer.