Changeset 252011 in webkit
- Timestamp:
- Nov 4, 2019 1:36:24 PM (4 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r251979 r252011 1 2019-11-04 Chris Dumez <cdumez@apple.com> 2 3 [iOS][WK2] Simplify process assertion handling for the network process and service worker processes 4 https://bugs.webkit.org/show_bug.cgi?id=203633 5 6 Reviewed by Alex Christensen. 7 8 Simplify process assertion handling for the network process and service worker processes. 9 In particular, the following changes were made: 10 1. Put the NetworkProcessProxy in charge of keeping the network process runnable instead 11 of relying on the WebProcessPool to do it. 12 2. Put the WebProcessProxy in charge of keeping the web process runnable due to service 13 worker activity, instead of relying on the WebProcessPool to do it. 14 3. Introduce a new Variant data type which can store a foreground activity, a background 15 activity or no activity. This avoid having 2 separate and mutually-exclusive data 16 members for foreground and background activities. 17 4. The new code is a bit more correct because it makes sure the the activity we're holding 18 is valid, instead of simply checking that it has an activity. This means that if the 19 process assertion was previously invalidated, we will now properly take a new activity, 20 which will re-take a process assertion. 21 22 This patch also reduces the #ifdefing for IOS_FAMILY, since ProcessThrottler and 23 ProcessAssertion exist on all platforms. 24 25 * UIProcess/Network/NetworkProcessProxy.cpp: 26 (WebKit::NetworkProcessProxy::updateProcessAssertion): 27 * UIProcess/Network/NetworkProcessProxy.h: 28 * UIProcess/ProcessThrottler.cpp: 29 (WebKit::ProcessThrottler::isValidBackgroundActivity): 30 (WebKit::ProcessThrottler::isValidForegroundActivity): 31 * UIProcess/ProcessThrottler.h: 32 * UIProcess/WebProcessPool.cpp: 33 (WebKit::m_backgroundWebProcessCounter): 34 (WebKit::WebProcessPool::ensureNetworkProcess): 35 (WebKit::WebProcessPool::networkProcessCrashed): 36 (WebKit::WebProcessPool::establishWorkerContextConnectionToNetworkProcess): 37 (WebKit::WebProcessPool::disconnectProcess): 38 (WebKit::WebProcessPool::terminateNetworkProcess): 39 (WebKit::WebProcessPool::updateProcessAssertions): 40 * UIProcess/WebProcessPool.h: 41 * UIProcess/WebProcessProxy.cpp: 42 (WebKit::WebProcessProxy::didSetAssertionState): 43 (WebKit::WebProcessProxy::updateServiceWorkerProcessAssertion): 44 (WebKit::WebProcessProxy::enableServiceWorkers): 45 * UIProcess/WebProcessProxy.h: 46 (WebKit::WebProcessProxy::isStandaloneServiceWorkerProcess const): 47 1 48 2019-11-03 Jiewen Tan <jiewen_tan@apple.com> 2 49 -
trunk/Source/WebKit/UIProcess/Cocoa/DownloadClient.mm
r251778 r252011 270 270 RELEASE_LOG_IF(webPage->isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p - UIProcess is taking a background assertion because it is downloading a system preview", this); 271 271 ASSERT(!m_activity); 272 m_activity = webPage->process().throttler().backgroundActivity("System preview download"_s) ;272 m_activity = webPage->process().throttler().backgroundActivity("System preview download"_s).moveToUniquePtr(); 273 273 } 274 274 #else -
trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm
r251778 r252011 1238 1238 if (!m_networkActivity) { 1239 1239 RELEASE_LOG_IF(m_webView->_page->isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p - NavigationState is taking a process network assertion because a page load started", this); 1240 m_networkActivity = m_webView->_page->process().throttler().backgroundActivity("Page Load"_s) ;1240 m_networkActivity = m_webView->_page->process().throttler().backgroundActivity("Page Load"_s).moveToUniquePtr(); 1241 1241 } 1242 1242 } else if (m_networkActivity) { … … 1348 1348 // Transfer our background assertion from the old process to the new one. 1349 1349 if (m_networkActivity) 1350 m_networkActivity = m_webView->_page->process().throttler().backgroundActivity("Page Load"_s) ;1350 m_networkActivity = m_webView->_page->process().throttler().backgroundActivity("Page Load"_s).moveToUniquePtr(); 1351 1351 #endif 1352 1352 } -
trunk/Source/WebKit/UIProcess/Cocoa/UIRemoteObjectRegistry.cpp
r251778 r252011 34 34 std::unique_ptr<ProcessThrottler::BackgroundActivity> UIRemoteObjectRegistry::backgroundActivity(ASCIILiteral name) 35 35 { 36 return m_page.process().throttler().backgroundActivity(name) ;36 return m_page.process().throttler().backgroundActivity(name).moveToUniquePtr(); 37 37 } 38 38 -
trunk/Source/WebKit/UIProcess/GenericCallback.h
r251778 r252011 70 70 typedef const TypeTag* Type; 71 71 72 explicit CallbackBase(Type type, std::unique_ptr<ProcessThrottler::BackgroundActivity>&& activity)72 explicit CallbackBase(Type type, ProcessThrottler::ActivityVariant&& activity) 73 73 : m_type(type) 74 74 , m_callbackID(CallbackID::generateID()) … … 80 80 Type m_type; 81 81 CallbackID m_callbackID; 82 std::unique_ptr<ProcessThrottler::BackgroundActivity>m_activity;82 ProcessThrottler::ActivityVariant m_activity; 83 83 }; 84 84 … … 88 88 typedef Function<void (T..., Error)> CallbackFunction; 89 89 90 static Ref<GenericCallback> create(CallbackFunction&& callback, std::unique_ptr<ProcessThrottler::BackgroundActivity>&& activity = nullptr)90 static Ref<GenericCallback> create(CallbackFunction&& callback, ProcessThrottler::ActivityVariant&& activity = nullptr) 91 91 { 92 92 return adoptRef(*new GenericCallback(WTFMove(callback), WTFMove(activity))); … … 127 127 128 128 private: 129 GenericCallback(CallbackFunction&& callback, std::unique_ptr<ProcessThrottler::BackgroundActivity>&& activity)129 GenericCallback(CallbackFunction&& callback, ProcessThrottler::ActivityVariant&& activity) 130 130 : CallbackBase(type(), WTFMove(activity)) 131 131 , m_callback(WTFMove(callback)) … … 190 190 191 191 template<typename... T> 192 CallbackID put(Function<void(T...)>&& function, std::unique_ptr<ProcessThrottler::BackgroundActivity>&& activity)192 CallbackID put(Function<void(T...)>&& function, ProcessThrottler::ActivityVariant&& activity) 193 193 { 194 194 auto callback = GenericCallbackType<sizeof...(T), T...>::type::create(WTFMove(function), WTFMove(activity)); -
trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
r251778 r252011 1099 1099 if (!m_activityForHoldingLockedFiles) { 1100 1100 RELEASE_LOG(ProcessSuspension, "UIProcess is taking a background assertion because the Network process is holding locked files"); 1101 m_activityForHoldingLockedFiles = m_throttler.backgroundActivity("Holding locked files"_s) ;1101 m_activityForHoldingLockedFiles = m_throttler.backgroundActivity("Holding locked files"_s).moveToUniquePtr(); 1102 1102 } 1103 1103 } … … 1112 1112 1113 1113 RELEASE_LOG(ProcessSuspension, "%p - NetworkProcessProxy is taking a background assertion because the Network process is syncing cookies", this); 1114 m_syncAllCookiesActivity = throttler().backgroundActivity("Syncing cookies"_s) ;1114 m_syncAllCookiesActivity = throttler().backgroundActivity("Syncing cookies"_s).moveToUniquePtr(); 1115 1115 } 1116 1116 … … 1204 1204 } 1205 1205 #endif 1206 1207 void NetworkProcessProxy::sendProcessDidTransitionToForeground()1208 {1209 send(Messages::NetworkProcess::ProcessDidTransitionToForeground(), 0);1210 }1211 1212 void NetworkProcessProxy::sendProcessDidTransitionToBackground()1213 {1214 send(Messages::NetworkProcess::ProcessDidTransitionToBackground(), 0);1215 }1216 1206 1217 1207 #if ENABLE(SANDBOX_EXTENSIONS) … … 1339 1329 } 1340 1330 1331 void NetworkProcessProxy::updateProcessAssertion() 1332 { 1333 if (processPool().hasForegroundWebProcesses()) { 1334 if (!ProcessThrottler::isValidForegroundActivity(m_activityFromWebProcesses)) { 1335 m_activityFromWebProcesses = throttler().foregroundActivity("Networking for foreground view(s)"_s); 1336 send(Messages::NetworkProcess::ProcessDidTransitionToForeground(), 0); 1337 } 1338 return; 1339 } 1340 if (processPool().hasBackgroundWebProcesses()) { 1341 if (!ProcessThrottler::isValidBackgroundActivity(m_activityFromWebProcesses)) { 1342 m_activityFromWebProcesses = throttler().backgroundActivity("Networking for foreground background view(s)"_s); 1343 send(Messages::NetworkProcess::ProcessDidTransitionToBackground(), 0); 1344 } 1345 return; 1346 } 1347 m_activityFromWebProcesses = nullptr; 1348 } 1349 1341 1350 } // namespace WebKit 1342 1351 -
trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h
r251778 r252011 161 161 #endif 162 162 163 void sendProcessDidTransitionToForeground();164 void sendProcessDidTransitionToBackground();165 163 void synthesizeAppIsBackground(bool background); 166 164 … … 173 171 174 172 ProcessThrottler& throttler() { return m_throttler; } 173 void updateProcessAssertion(); 174 175 175 WebProcessPool& processPool() { return m_processPool; } 176 176 … … 280 280 std::unique_ptr<ProcessThrottler::BackgroundActivity> m_activityForHoldingLockedFiles; 281 281 std::unique_ptr<ProcessThrottler::BackgroundActivity> m_syncAllCookiesActivity; 282 ProcessThrottler::ActivityVariant m_activityFromWebProcesses; 282 283 283 284 unsigned m_syncAllCookiesCounter { 0 }; -
trunk/Source/WebKit/UIProcess/ProcessThrottler.cpp
r251778 r252011 206 206 } 207 207 208 bool ProcessThrottler::isValidBackgroundActivity(const ProcessThrottler::ActivityVariant& activity) 209 { 210 if (!WTF::holds_alternative<UniqueRef<ProcessThrottler::BackgroundActivity>>(activity)) 211 return false; 212 return WTF::get<UniqueRef<ProcessThrottler::BackgroundActivity>>(activity)->isValid(); 213 } 214 215 bool ProcessThrottler::isValidForegroundActivity(const ProcessThrottler::ActivityVariant& activity) 216 { 217 if (!WTF::holds_alternative<UniqueRef<ProcessThrottler::ForegroundActivity>>(activity)) 218 return false; 219 return WTF::get<UniqueRef<ProcessThrottler::ForegroundActivity>>(activity)->isValid(); 220 } 221 208 222 } // namespace WebKit -
trunk/Source/WebKit/UIProcess/ProcessThrottler.h
r251795 r252011 32 32 #include <wtf/RefCounter.h> 33 33 #include <wtf/RunLoop.h> 34 #include <wtf/UniqueRef.h> 35 #include <wtf/Variant.h> 34 36 #include <wtf/WeakPtr.h> 35 37 … … 87 89 88 90 using ForegroundActivity = Activity<ActivityType::Foreground>; 89 std::unique_ptr<ForegroundActivity> foregroundActivity(ASCIILiteral name);91 UniqueRef<ForegroundActivity> foregroundActivity(ASCIILiteral name); 90 92 91 93 using BackgroundActivity = Activity<ActivityType::Background>; 92 std::unique_ptr<BackgroundActivity> backgroundActivity(ASCIILiteral name); 94 UniqueRef<BackgroundActivity> backgroundActivity(ASCIILiteral name); 95 96 using ActivityVariant = Variant<std::nullptr_t, UniqueRef<BackgroundActivity>, UniqueRef<ForegroundActivity>>; 97 static bool isValidBackgroundActivity(const ActivityVariant&); 98 static bool isValidForegroundActivity(const ActivityVariant&); 93 99 94 100 void didConnectToProcess(ProcessID); … … 125 131 }; 126 132 127 inline auto ProcessThrottler::foregroundActivity(ASCIILiteral name) -> std::unique_ptr<ForegroundActivity>133 inline auto ProcessThrottler::foregroundActivity(ASCIILiteral name) -> UniqueRef<ForegroundActivity> 128 134 { 129 return makeUnique <ForegroundActivity>(*this, name);135 return makeUniqueRef<ForegroundActivity>(*this, name); 130 136 } 131 137 132 inline auto ProcessThrottler::backgroundActivity(ASCIILiteral name) -> std::unique_ptr<BackgroundActivity>138 inline auto ProcessThrottler::backgroundActivity(ASCIILiteral name) -> UniqueRef<BackgroundActivity> 133 139 { 134 return makeUnique <BackgroundActivity>(*this, name);140 return makeUniqueRef<BackgroundActivity>(*this, name); 135 141 } 136 142 -
trunk/Source/WebKit/UIProcess/ProvisionalPageProxy.h
r251778 r252011 144 144 #endif 145 145 #if PLATFORM(IOS_FAMILY) 146 std::unique_ptr<ProcessThrottler::ForegroundActivity> m_provisionalLoadActivity;146 UniqueRef<ProcessThrottler::ForegroundActivity> m_provisionalLoadActivity; 147 147 #endif 148 148 }; -
trunk/Source/WebKit/UIProcess/SuspendedPageProxy.cpp
r251778 r252011 103 103 , m_suspensionTimeoutTimer(RunLoop::main(), this, &SuspendedPageProxy::suspensionTimedOut) 104 104 #if PLATFORM(IOS_FAMILY) 105 , m_suspensionActivity(m_process->throttler().backgroundActivity("Page suspension for back/forward cache"_s) )105 , m_suspensionActivity(m_process->throttler().backgroundActivity("Page suspension for back/forward cache"_s).moveToUniquePtr()) 106 106 #endif 107 107 { -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r251976 r252011 1936 1936 if (!m_isVisibleActivity || !m_isVisibleActivity->isValid()) { 1937 1937 RELEASE_LOG_IF_ALLOWED(ProcessSuspension, "updateThrottleState: UIProcess is taking a foreground assertion because the view is visible"); 1938 m_isVisibleActivity = m_process->throttler().foregroundActivity("View is visible"_s) ;1938 m_isVisibleActivity = m_process->throttler().foregroundActivity("View is visible"_s).moveToUniquePtr(); 1939 1939 } 1940 1940 } else if (m_isVisibleActivity) { … … 1947 1947 if (!m_isAudibleActivity || !m_isAudibleActivity->isValid()) { 1948 1948 RELEASE_LOG_IF_ALLOWED(ProcessSuspension, "updateThrottleState: UIProcess is taking a foreground assertion because we are playing audio"); 1949 m_isAudibleActivity = m_process->throttler().foregroundActivity("View is playing audio"_s) ;1949 m_isAudibleActivity = m_process->throttler().foregroundActivity("View is playing audio"_s).moveToUniquePtr(); 1950 1950 } 1951 1951 } else if (m_isAudibleActivity) { … … 1958 1958 if (!m_isCapturingActivity || !m_isCapturingActivity->isValid()) { 1959 1959 RELEASE_LOG_IF_ALLOWED(ProcessSuspension, "updateThrottleState: UIProcess is taking a foreground assertion because media capture is active"); 1960 m_isCapturingActivity = m_process->throttler().foregroundActivity("View is capturing media"_s) ;1960 m_isCapturingActivity = m_process->throttler().foregroundActivity("View is capturing media"_s).moveToUniquePtr(); 1961 1961 } 1962 1962 } else if (m_isCapturingActivity) { … … 1968 1968 if (!m_alwaysRunsAtForegroundPriorityActivity || !m_alwaysRunsAtForegroundPriorityActivity->isValid()) { 1969 1969 RELEASE_LOG_IF_ALLOWED(ProcessSuspension, "updateThrottleState: UIProcess is taking a foreground assertion because m_alwaysRunsAtForegroundPriority is true"); 1970 m_alwaysRunsAtForegroundPriorityActivity = m_process->throttler().foregroundActivity("View always runs at foreground priority"_s) ;1970 m_alwaysRunsAtForegroundPriorityActivity = m_process->throttler().foregroundActivity("View always runs at foreground priority"_s).moveToUniquePtr(); 1971 1971 } 1972 1972 } else if (m_alwaysRunsAtForegroundPriorityActivity) { -
trunk/Source/WebKit/UIProcess/WebProcessPool.cpp
r251814 r252011 235 235 , m_hiddenPageThrottlingTimer(RunLoop::main(), this, &WebProcessPool::updateHiddenPageThrottlingAutoIncreaseLimit) 236 236 , m_serviceWorkerProcessesTerminationTimer(RunLoop::main(), this, &WebProcessPool::terminateServiceWorkerProcesses) 237 #if PLATFORM(IOS_FAMILY)238 237 , m_foregroundWebProcessCounter([this](RefCounterEvent) { updateProcessAssertions(); }) 239 238 , m_backgroundWebProcessCounter([this](RefCounterEvent) { updateProcessAssertions(); }) 240 #endif241 239 , m_backForwardCache(makeUniqueRef<WebBackForwardCache>(*this)) 242 240 , m_webProcessCache(makeUniqueRef<WebProcessCache>(*this)) … … 633 631 #endif 634 632 635 if (m_didNetworkProcessCrash) { 636 m_didNetworkProcessCrash = false; 637 reinstateNetworkProcessAssertionState(*networkProcess); 638 } 633 networkProcess->updateProcessAssertion(); 639 634 640 635 if (withWebsiteDataStore) { … … 657 652 ASSERT(m_networkProcess); 658 653 ASSERT(&networkProcessProxy == m_networkProcess.get()); 659 m_didNetworkProcessCrash = true;660 654 661 655 for (auto& supplement : m_supplements.values()) … … 737 731 RELEASE_LOG_IF(sessionID.isAlwaysOnLoggingAllowed(), ServiceWorker, "WebProcessPool::establishWorkerContextConnectionToNetworkProcess creating a new service worker process %p, process identifier %d", serviceWorkerProcessProxy, serviceWorkerProcessProxy->processIdentifier()); 738 732 739 updateProcessAssertions();740 733 initializeNewWebProcess(newProcessProxy, websiteDataStore); 741 734 m_processes.append(WTFMove(newProcessProxy)); … … 1131 1124 if (iterator != m_serviceWorkerProcesses.end() && iterator->value == process) 1132 1125 m_serviceWorkerProcesses.remove(iterator); 1133 updateProcessAssertions();1134 1126 } 1135 1127 #endif … … 1710 1702 m_networkProcess->terminate(); 1711 1703 m_networkProcess = nullptr; 1712 m_didNetworkProcessCrash = true;1713 1704 } 1714 1705 … … 2046 2037 void WebProcessPool::updateProcessAssertions() 2047 2038 { 2048 #if PLATFORM(IOS_FAMILY)2049 2039 #if ENABLE(SERVICE_WORKER) 2050 auto updateServiceWorkerProcessAssertion = [&] { 2051 if (!m_serviceWorkerProcesses.isEmpty() && m_foregroundWebProcessCounter.value()) { 2052 // FIXME: We can do better than this once we have process per origin. 2053 for (auto* serviceWorkerProcess : m_serviceWorkerProcesses.values()) { 2054 auto registrableDomain = serviceWorkerProcess->registrableDomain(); 2055 if (!m_foregroundActivitiesForServiceWorkerProcesses.contains(registrableDomain)) 2056 m_foregroundActivitiesForServiceWorkerProcesses.add(WTFMove(registrableDomain), serviceWorkerProcess->throttler().foregroundActivity("Service Worker for visible view(s)"_s)); 2057 } 2058 m_backgroundActivitiesForServiceWorkerProcesses.clear(); 2059 return; 2060 } 2061 if (!m_serviceWorkerProcesses.isEmpty() && m_backgroundWebProcessCounter.value()) { 2062 // FIXME: We can do better than this once we have process per origin. 2063 for (auto* serviceWorkerProcess : m_serviceWorkerProcesses.values()) { 2064 auto registrableDomain = serviceWorkerProcess->registrableDomain(); 2065 if (!m_backgroundActivitiesForServiceWorkerProcesses.contains(registrableDomain)) 2066 m_backgroundActivitiesForServiceWorkerProcesses.add(WTFMove(registrableDomain), serviceWorkerProcess->throttler().backgroundActivity("Service Worker for background view(s)"_s)); 2067 } 2068 m_foregroundActivitiesForServiceWorkerProcesses.clear(); 2069 return; 2070 } 2071 m_foregroundActivitiesForServiceWorkerProcesses.clear(); 2072 m_backgroundActivitiesForServiceWorkerProcesses.clear(); 2073 }; 2074 updateServiceWorkerProcessAssertion(); 2075 #endif 2076 2077 auto updateNetworkProcessAssertion = [&] { 2078 auto& networkProcess = ensureNetworkProcess(); 2079 2080 if (m_foregroundWebProcessCounter.value()) { 2081 if (!m_foregroundActivityForNetworkProcess) { 2082 m_foregroundActivityForNetworkProcess = networkProcess.throttler().foregroundActivity("Networking for foreground view(s)"_s); 2083 networkProcess.sendProcessDidTransitionToForeground(); 2084 } 2085 m_backgroundActivityForNetworkProcess = nullptr; 2086 return; 2087 } 2088 if (m_backgroundWebProcessCounter.value()) { 2089 if (!m_backgroundActivityForNetworkProcess) { 2090 m_backgroundActivityForNetworkProcess = networkProcess.throttler().backgroundActivity("Networking for foreground background view(s)"_s); 2091 networkProcess.sendProcessDidTransitionToBackground(); 2092 } 2093 m_foregroundActivityForNetworkProcess = nullptr; 2094 return; 2095 } 2096 m_foregroundActivityForNetworkProcess = nullptr; 2097 m_backgroundActivityForNetworkProcess = nullptr; 2098 }; 2099 updateNetworkProcessAssertion(); 2100 #endif 2101 } 2102 2103 void WebProcessPool::reinstateNetworkProcessAssertionState(NetworkProcessProxy& newNetworkProcessProxy) 2104 { 2105 #if PLATFORM(IOS_FAMILY) 2106 // The network process crashed; take new activities for the new network process. 2107 if (m_backgroundActivityForNetworkProcess) 2108 m_backgroundActivityForNetworkProcess = newNetworkProcessProxy.throttler().backgroundActivity("Networking for background view(s)"_s); 2109 else if (m_foregroundActivityForNetworkProcess) 2110 m_foregroundActivityForNetworkProcess = newNetworkProcessProxy.throttler().foregroundActivity("Networking for foreground view(s)"_s); 2111 #else 2112 UNUSED_PARAM(newNetworkProcessProxy); 2113 #endif 2040 for (auto* serviceWorkerProcess : m_serviceWorkerProcesses.values()) 2041 serviceWorkerProcess->updateServiceWorkerProcessAssertion(); 2042 #endif 2043 ensureNetworkProcess().updateProcessAssertion(); 2114 2044 } 2115 2045 -
trunk/Source/WebKit/UIProcess/WebProcessPool.h
r251814 r252011 473 473 static void unregisterProcessPoolCreationListener(uint64_t identifier); 474 474 475 #if PLATFORM(IOS_FAMILY)476 475 ForegroundWebProcessToken foregroundWebProcessToken() const { return ForegroundWebProcessToken(m_foregroundWebProcessCounter.count()); } 477 476 BackgroundWebProcessToken backgroundWebProcessToken() const { return BackgroundWebProcessToken(m_backgroundWebProcessCounter.count()); } 478 #endif 477 bool hasForegroundWebProcesses() const { return m_foregroundWebProcessCounter.value(); } 478 bool hasBackgroundWebProcesses() const { return m_backgroundWebProcessCounter.value(); } 479 479 480 480 void processForNavigation(WebPageProxy&, const API::Navigation&, Ref<WebProcessProxy>&& sourceProcess, const URL& sourceURL, ProcessSwapRequestedByClient, Ref<WebsiteDataStore>&&, CompletionHandler<void(Ref<WebProcessProxy>&&, SuspendedPageProxy*, const String&)>&&); … … 555 555 #endif 556 556 557 void reinstateNetworkProcessAssertionState(NetworkProcessProxy&);558 557 void updateProcessAssertions(); 559 558 … … 697 696 bool m_processTerminationEnabled { true }; 698 697 699 bool m_didNetworkProcessCrash { false };700 698 std::unique_ptr<NetworkProcessProxy> m_networkProcess; 701 699 … … 760 758 RunLoop::Timer<WebProcessPool> m_serviceWorkerProcessesTerminationTimer; 761 759 762 #if PLATFORM(IOS_FAMILY)763 760 ForegroundWebProcessCounter m_foregroundWebProcessCounter; 764 761 BackgroundWebProcessCounter m_backgroundWebProcessCounter; 765 std::unique_ptr<ProcessThrottler::ForegroundActivity> m_foregroundActivityForNetworkProcess;766 std::unique_ptr<ProcessThrottler::BackgroundActivity> m_backgroundActivityForNetworkProcess;767 #if ENABLE(SERVICE_WORKER)768 HashMap<WebCore::RegistrableDomain, std::unique_ptr<ProcessThrottler::ForegroundActivity>> m_foregroundActivitiesForServiceWorkerProcesses;769 HashMap<WebCore::RegistrableDomain, std::unique_ptr<ProcessThrottler::BackgroundActivity>> m_backgroundActivitiesForServiceWorkerProcesses;770 #endif771 #endif772 762 773 763 UniqueRef<WebBackForwardCache> m_backForwardCache; -
trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp
r251831 r252011 1233 1233 void WebProcessProxy::didSetAssertionState(AssertionState state) 1234 1234 { 1235 #if PLATFORM(IOS_FAMILY)1236 1235 RELEASE_LOG(ProcessSuspension, "%p - WebProcessProxy::didSetAssertionState(%u)", this, state); 1237 1236 1238 if (is RunningServiceWorkers() && !pageCount()) {1237 if (isStandaloneServiceWorkerProcess()) { 1239 1238 RELEASE_LOG(ProcessSuspension, "%p - WebProcessProxy::didSetAssertionState() release all assertions for network process because this is a service worker process without page", this); 1240 1239 m_foregroundToken = nullptr; … … 1250 1249 m_foregroundToken = nullptr; 1251 1250 m_backgroundToken = nullptr; 1251 #if PLATFORM(IOS_FAMILY) 1252 1252 for (auto& page : m_pageMap.values()) 1253 1253 page->processWillBecomeSuspended(); 1254 #endif 1254 1255 break; 1255 1256 … … 1264 1265 m_foregroundToken = processPool().foregroundWebProcessToken(); 1265 1266 m_backgroundToken = nullptr; 1267 #if PLATFORM(IOS_FAMILY) 1266 1268 for (auto& page : m_pageMap.values()) 1267 1269 page->processWillBecomeForeground(); 1270 #endif 1268 1271 break; 1269 1272 … … 1273 1276 1274 1277 ASSERT(!m_backgroundToken || !m_foregroundToken); 1275 #else1276 UNUSED_PARAM(state);1277 #endif1278 1278 } 1279 1279 … … 1300 1300 if (!m_activityForHoldingLockedFiles) { 1301 1301 RELEASE_LOG(ProcessSuspension, "UIProcess is taking a background assertion because the WebContent process is holding locked files"); 1302 m_activityForHoldingLockedFiles = m_throttler.backgroundActivity("Holding locked files"_s) ;1302 m_activityForHoldingLockedFiles = m_throttler.backgroundActivity("Holding locked files"_s).moveToUniquePtr(); 1303 1303 } 1304 1304 } … … 1558 1558 send(Messages::WebSWContextManagerConnection::UpdatePreferencesStore { store }, 0); 1559 1559 } 1560 #endif 1560 1561 void WebProcessProxy::updateServiceWorkerProcessAssertion() 1562 { 1563 RELEASE_LOG(ProcessSuspension, "%p - WebProcessProxy::updateServiceWorkerProcessAssertion() PID: %d", this, processIdentifier()); 1564 ASSERT(m_serviceWorkerInformation); 1565 if (!m_serviceWorkerInformation) 1566 return; 1567 1568 // FIXME: We could do better if we knew which WebContent processes needed this service worker process. 1569 if (processPool().hasForegroundWebProcesses()) { 1570 if (!ProcessThrottler::isValidForegroundActivity(m_serviceWorkerInformation->activity)) 1571 m_serviceWorkerInformation->activity = m_throttler.foregroundActivity("Service Worker for foreground view(s)"_s); 1572 return; 1573 } 1574 if (processPool().hasBackgroundWebProcesses()) { 1575 if (!ProcessThrottler::isValidBackgroundActivity(m_serviceWorkerInformation->activity)) 1576 m_serviceWorkerInformation->activity = m_throttler.backgroundActivity("Service Worker for background view(s)"_s); 1577 return; 1578 } 1579 m_serviceWorkerInformation->activity = nullptr; 1580 } 1581 #endif // ENABLE(SERVICE_WORKER) 1561 1582 1562 1583 void WebProcessProxy::disableServiceWorkers() … … 1606 1627 #endif 1607 1628 }, 1629 nullptr, 1608 1630 }; 1631 updateServiceWorkerProcessAssertion(); 1609 1632 } 1610 1633 -
trunk/Source/WebKit/UIProcess/WebProcessProxy.h
r251814 r252011 92 92 struct WebsiteData; 93 93 94 #if PLATFORM(IOS_FAMILY)95 94 enum ForegroundWebProcessCounterType { }; 96 95 typedef RefCounter<ForegroundWebProcessCounterType> ForegroundWebProcessCounter; … … 99 98 typedef RefCounter<BackgroundWebProcessCounterType> BackgroundWebProcessCounter; 100 99 typedef BackgroundWebProcessCounter::Token BackgroundWebProcessToken; 101 #endif102 100 103 101 class WebProcessProxy : public AuxiliaryProcessProxy, public ResponsivenessTimer::Client, public ThreadSafeRefCounted<WebProcessProxy>, public CanMakeWeakPtr<WebProcessProxy>, private ProcessThrottlerClient { … … 164 162 165 163 bool isRunningServiceWorkers() const { return !!m_serviceWorkerInformation; } 164 bool isStandaloneServiceWorkerProcess() const { return isRunningServiceWorkers() && !pageCount(); } 166 165 167 166 void didCreateWebPageInProcess(WebCore::PageIdentifier); … … 340 339 void updateServiceWorkerPreferencesStore(const WebPreferencesStore&); 341 340 bool hasServiceWorkerPageProxy(WebPageProxyIdentifier pageProxyID) { return m_serviceWorkerInformation && m_serviceWorkerInformation->serviceWorkerPageProxyID == pageProxyID; } 341 void updateServiceWorkerProcessAssertion(); 342 342 #endif 343 343 … … 484 484 ProcessThrottler m_throttler; 485 485 std::unique_ptr<ProcessThrottler::BackgroundActivity> m_activityForHoldingLockedFiles; 486 #if PLATFORM(IOS_FAMILY)487 486 ForegroundWebProcessToken m_foregroundToken; 488 487 BackgroundWebProcessToken m_backgroundToken; 488 #if PLATFORM(IOS_FAMILY) 489 489 bool m_hasSentMessageToUnblockAccessibilityServer { false }; 490 490 std::unique_ptr<WebCore::DeferrableOneShotTimer> m_unexpectedActivityTimer; … … 527 527 WebCore::PageIdentifier serviceWorkerPageID; 528 528 ServiceWorkerInitializationData initializationData; 529 ProcessThrottler::ActivityVariant activity; 529 530 }; 530 531 Optional<ServiceWorkerInformation> m_serviceWorkerInformation;
Note: See TracChangeset
for help on using the changeset viewer.