Changeset 245299 in webkit
- Timestamp:
- May 14, 2019, 12:48:51 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 32 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/http/wpt/service-workers/mac (added)
-
LayoutTests/http/wpt/service-workers/mac/throttleable-worker.js (added)
-
LayoutTests/http/wpt/service-workers/mac/throttleable.https-expected.txt (added)
-
LayoutTests/http/wpt/service-workers/mac/throttleable.https.html (added)
-
LayoutTests/platform/ios-wk2/TestExpectations (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/platform/RegistrableDomain.h (modified) (4 diffs)
-
Source/WebCore/testing/ServiceWorkerInternals.cpp (modified) (1 diff)
-
Source/WebCore/testing/ServiceWorkerInternals.h (modified) (1 diff)
-
Source/WebCore/testing/ServiceWorkerInternals.idl (modified) (1 diff)
-
Source/WebCore/workers/service/SWClientConnection.h (modified) (1 diff)
-
Source/WebCore/workers/service/context/SWContextManager.h (modified) (1 diff)
-
Source/WebCore/workers/service/server/SWServer.cpp (modified) (1 diff)
-
Source/WebCore/workers/service/server/SWServer.h (modified) (2 diffs)
-
Source/WebCore/workers/service/server/SWServerToContextConnection.h (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.cpp (modified) (3 diffs)
-
Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.h (modified) (2 diffs)
-
Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.messages.in (modified) (1 diff)
-
Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp (modified) (1 diff)
-
Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h (modified) (2 diffs)
-
Source/WebKit/UIProcess/ServiceWorkerProcessProxy.cpp (modified) (1 diff)
-
Source/WebKit/UIProcess/ServiceWorkerProcessProxy.h (modified) (1 diff)
-
Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp (modified) (2 diffs)
-
Source/WebKit/WebProcess/Storage/WebSWClientConnection.h (modified) (2 diffs)
-
Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp (modified) (1 diff)
-
Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h (modified) (3 diffs)
-
Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in (modified) (1 diff)
-
Source/WebKit/WebProcess/WebPage/WebPage.cpp (modified) (2 diffs)
-
Source/WebKit/WebProcess/WebPage/WebPage.h (modified) (1 diff)
-
Source/WebKit/WebProcess/WebProcess.cpp (modified) (2 diffs)
-
Source/WebKit/WebProcess/WebProcess.h (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/WebKitTestRunner/TestController.cpp (modified) (2 diffs)
-
Tools/WebKitTestRunner/TestOptions.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r245295 r245299 1 2019-05-14 Youenn Fablet <youenn@apple.com> 2 3 A service worker process should app nap when all its clients app nap 4 https://bugs.webkit.org/show_bug.cgi?id=185626 5 <rdar://problem/46785908> 6 7 Reviewed by Alex Christensen. 8 9 * http/wpt/service-workers/mac/throttleable-worker.js: Added. 10 * http/wpt/service-workers/mac/throttleable.https-expected.txt: Added. 11 * http/wpt/service-workers/mac/throttleable.https.html: Added. 12 * platform/ios-wk2/TestExpectations: 13 1 14 2019-05-14 Oriol Brufau <obrufau@igalia.com> 2 15 -
trunk/LayoutTests/platform/ios-wk2/TestExpectations
r245242 r245299 368 368 http/tests/xmlhttprequest/cross-origin-authorization-with-embedder.html 369 369 370 http/wpt/service-workers/mac/ [ Skip ] 371 370 372 # HTTP tests that are flaky: 371 373 http/tests/navigation/forward-and-cancel.html [ Failure Pass ] -
trunk/Source/WebCore/ChangeLog
r245296 r245299 1 2019-05-14 Youenn Fablet <youenn@apple.com> 2 3 A service worker process should app nap when all its clients app nap 4 https://bugs.webkit.org/show_bug.cgi?id=185626 5 <rdar://problem/46785908> 6 7 Reviewed by Alex Christensen. 8 9 Update RegistrableDomain to work with SecurityOriginData. 10 Add internal API to enable accessing to service worker process throttle state. 11 12 Test: http/wpt/service-workers/mac/processSuppression.https.html 13 14 * platform/RegistrableDomain.h: 15 (WebCore::RegistrableDomain::RegistrableDomain): 16 (WebCore::RegistrableDomain::matches const): 17 (WebCore::RegistrableDomain::registrableDomainFromHost): 18 * testing/ServiceWorkerInternals.cpp: 19 (WebCore::ServiceWorkerInternals::isThrottleable const): 20 * testing/ServiceWorkerInternals.h: 21 * testing/ServiceWorkerInternals.idl: 22 * workers/service/SWClientConnection.h: 23 * workers/service/context/SWContextManager.cpp: 24 * workers/service/context/SWContextManager.h: 25 * workers/service/server/SWServer.cpp: 26 (WebCore::SWServer::serverToContextConnectionCreated): 27 * workers/service/server/SWServer.h: 28 (WebCore::SWServer::Connection::server const): 29 (WebCore::SWServer::connections const): 30 * workers/service/server/SWServerToContextConnection.h: 31 1 32 2019-05-14 Youenn Fablet <youenn@apple.com> 2 33 -
trunk/Source/WebCore/platform/RegistrableDomain.h
r242899 r245299 27 27 28 28 #include "PublicSuffix.h" 29 #include "SecurityOriginData.h" 29 30 #include <wtf/HashTraits.h> 30 31 #include <wtf/URL.h> … … 37 38 public: 38 39 RegistrableDomain() = default; 40 39 41 explicit RegistrableDomain(const URL& url) 40 #if ENABLE(PUBLIC_SUFFIX_LIST) 41 : m_registrableDomain { topPrivatelyControlledDomain(url.host().toString()) } 42 #else 43 : m_registrableDomain { url.host().toString() } 44 #endif 42 : RegistrableDomain(registrableDomainFromHost(url.host().toString())) 45 43 { 46 auto hostString = url.host().toString();47 if (hostString.isEmpty()) 48 m_registrableDomain = "nullOrigin"_s;49 else if (m_registrableDomain.isEmpty())50 m_registrableDomain = hostString;44 } 45 46 explicit RegistrableDomain(const SecurityOriginData& origin) 47 : RegistrableDomain(registrableDomainFromHost(origin.host)) 48 { 51 49 } 52 50 … … 59 57 bool matches(const URL& url) const 60 58 { 61 auto host = url.host(); 62 if (host.isEmpty() && m_registrableDomain == "nullOrigin"_s) 63 return true; 64 if (!host.endsWith(m_registrableDomain)) 65 return false; 66 if (host.length() == m_registrableDomain.length()) 67 return true; 68 return host[host.length() - m_registrableDomain.length() - 1] == '.'; 59 return matches(url.host()); 60 } 61 62 bool matches(const SecurityOriginData& origin) const 63 { 64 return matches(origin.host); 69 65 } 70 66 … … 110 106 } 111 107 108 bool matches(StringView host) const 109 { 110 if (host.isEmpty() && m_registrableDomain == "nullOrigin"_s) 111 return true; 112 if (!host.endsWith(m_registrableDomain)) 113 return false; 114 if (host.length() == m_registrableDomain.length()) 115 return true; 116 return host[host.length() - m_registrableDomain.length() - 1] == '.'; 117 } 118 119 static inline String registrableDomainFromHost(const String& host) 120 { 121 #if ENABLE(PUBLIC_SUFFIX_LIST) 122 auto domain = topPrivatelyControlledDomain(host); 123 #else 124 auto domain = host; 125 #endif 126 if (host.isEmpty()) 127 domain = "nullOrigin"_s; 128 else if (domain.isEmpty()) 129 domain = host; 130 return domain; 131 } 132 112 133 String m_registrableDomain; 113 134 }; -
trunk/Source/WebCore/testing/ServiceWorkerInternals.cpp
r244054 r245299 97 97 #endif 98 98 99 bool ServiceWorkerInternals::isThrottleable() const 100 { 101 auto* connection = SWContextManager::singleton().connection(); 102 return connection ? connection->isThrottleable() : true; 103 } 104 99 105 } // namespace WebCore 100 106 -
trunk/Source/WebCore/testing/ServiceWorkerInternals.h
r244054 r245299 52 52 String processName() const; 53 53 54 bool isThrottleable() const; 55 54 56 private: 55 57 explicit ServiceWorkerInternals(ServiceWorkerIdentifier); -
trunk/Source/WebCore/testing/ServiceWorkerInternals.idl
r244054 r245299 38 38 39 39 readonly attribute DOMString processName; 40 readonly attribute boolean isThrottleable; 40 41 }; -
trunk/Source/WebCore/workers/service/SWClientConnection.h
r244160 r245299 86 86 virtual void finishFetchingScriptInServer(const ServiceWorkerFetchResult&) = 0; 87 87 88 virtual bool isThrottleable() const = 0; 89 virtual void updateThrottleState() = 0; 90 88 91 protected: 89 92 WEBCORE_EXPORT SWClientConnection(); -
trunk/Source/WebCore/workers/service/context/SWContextManager.h
r242279 r245299 63 63 virtual void matchAll(ServiceWorkerIdentifier, const ServiceWorkerClientQueryOptions&, ServiceWorkerClientsMatchAllCallback&&) = 0; 64 64 virtual void claim(ServiceWorkerIdentifier, CompletionHandler<void()>&&) = 0; 65 66 virtual bool isThrottleable() const = 0; 65 67 }; 66 68 -
trunk/Source/WebCore/workers/service/server/SWServer.cpp
r245200 r245299 545 545 void SWServer::serverToContextConnectionCreated(SWServerToContextConnection& contextConnection) 546 546 { 547 for (auto& connection : m_connections.values()) 548 connection->serverToContextConnectionCreated(contextConnection); 549 547 550 auto pendingContextDatas = m_pendingContextDatas.take(contextConnection.registrableDomain()); 548 551 for (auto& data : pendingContextDatas) -
trunk/Source/WebCore/workers/service/server/SWServer.h
r244097 r245299 88 88 virtual void registrationReady(uint64_t registrationReadyRequestIdentifier, ServiceWorkerRegistrationData&&) = 0; 89 89 90 virtual void serverToContextConnectionCreated(SWServerToContextConnection&) = 0; 91 90 92 SWServer& server() { return m_server; } 93 const SWServer& server() const { return m_server; } 91 94 92 95 protected: … … 153 156 WEBCORE_EXPORT void removeConnection(SWServerConnectionIdentifier); 154 157 Connection* connection(SWServerConnectionIdentifier identifier) const { return m_connections.get(identifier); } 158 159 const HashMap<SWServerConnectionIdentifier, std::unique_ptr<Connection>>& connections() const { return m_connections; } 155 160 156 161 SWOriginStore& originStore() { return m_originStore; } -
trunk/Source/WebCore/workers/service/server/SWServerToContextConnection.h
r242905 r245299 77 77 WEBCORE_EXPORT void setScriptResource(ServiceWorkerIdentifier, URL&& scriptURL, String&& script, URL&& responseURL, String&& mimeType); 78 78 79 static SWServerToContextConnection* connectionForRegistrableDomain(const RegistrableDomain&);79 WEBCORE_EXPORT static SWServerToContextConnection* connectionForRegistrableDomain(const RegistrableDomain&); 80 80 81 81 const RegistrableDomain& registrableDomain() const { return m_registrableDomain; } -
trunk/Source/WebKit/ChangeLog
r245298 r245299 1 2019-05-14 Youenn Fablet <youenn@apple.com> 2 3 A service worker process should app nap when all its clients app nap 4 https://bugs.webkit.org/show_bug.cgi?id=185626 5 <rdar://problem/46785908> 6 7 Reviewed by Alex Christensen. 8 9 Compute whether a given web process can be throttled on every page throttling change. 10 Send that information to network process which stores that information in WebSWServerConnection. 11 Every WebSWServerToContextConnection throttle state is then computed based on all WebSWServerConnection 12 that have a client that matches the registrable domain of the context connection. 13 14 * NetworkProcess/ServiceWorker/WebSWServerConnection.cpp: 15 (WebKit::WebSWServerConnection::registerServiceWorkerClient): 16 (WebKit::WebSWServerConnection::unregisterServiceWorkerClient): 17 (WebKit::WebSWServerConnection::hasMatchingClient const): 18 (WebKit::WebSWServerConnection::computeThrottleState const): 19 (WebKit::WebSWServerConnection::setThrottleState): 20 (WebKit::WebSWServerConnection::updateThrottleState): 21 (WebKit::WebSWServerConnection::serverToContextConnectionCreated): 22 * NetworkProcess/ServiceWorker/WebSWServerConnection.h: 23 (WebKit::WebSWServerConnection::isThrottleable const): 24 * NetworkProcess/ServiceWorker/WebSWServerConnection.messages.in: 25 * NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp: 26 (WebKit::WebSWServerToContextConnection::setThrottleState): 27 * NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h: 28 (WebKit::WebSWServerToContextConnection::isThrottleable const): 29 * UIProcess/ServiceWorkerProcessProxy.cpp: 30 * UIProcess/ServiceWorkerProcessProxy.h: 31 * WebProcess/Storage/WebSWClientConnection.cpp: 32 (WebKit::WebSWClientConnection::WebSWClientConnection): 33 (WebKit::WebSWClientConnection::updateThrottleState): 34 * WebProcess/Storage/WebSWClientConnection.h: 35 * WebProcess/Storage/WebSWContextManagerConnection.cpp: 36 (WebKit::WebSWContextManagerConnection::setThrottleState): 37 (WebKit::WebSWContextManagerConnection::isThrottleable const): 38 * WebProcess/Storage/WebSWContextManagerConnection.h: 39 * WebProcess/Storage/WebSWContextManagerConnection.messages.in: 40 * WebProcess/WebPage/WebPage.cpp: 41 (WebKit::WebPage::updateUserActivity): 42 (WebKit::WebPage::isThrottleable const): 43 * WebProcess/WebPage/WebPage.h: 44 * WebProcess/WebProcess.cpp: 45 (WebKit::WebProcess::arePagesThrottleable const): 46 * WebProcess/WebProcess.h: 47 1 48 2019-05-14 Chris Dumez <cdumez@apple.com> 2 49 -
trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.cpp
r243345 r245299 52 52 #include <WebCore/ServiceWorkerJobData.h> 53 53 #include <WebCore/ServiceWorkerUpdateViaCache.h> 54 #include <wtf/Algorithms.h> 54 55 #include <wtf/MainThread.h> 55 56 … … 279 280 m_clientOrigins.add(data.identifier, clientOrigin); 280 281 server().registerServiceWorkerClient(WTFMove(clientOrigin), WTFMove(data), controllingServiceWorkerRegistrationIdentifier, WTFMove(userAgent)); 282 283 if (!m_isThrottleable) 284 updateThrottleState(); 281 285 } 282 286 … … 289 293 server().unregisterServiceWorkerClient(iterator->value, clientIdentifier); 290 294 m_clientOrigins.remove(iterator); 295 296 if (!m_isThrottleable) 297 updateThrottleState(); 298 } 299 300 bool WebSWServerConnection::hasMatchingClient(const RegistrableDomain& domain) const 301 { 302 return WTF::anyOf(m_clientOrigins.values(), [&domain](auto& origin) { 303 return domain.matches(origin.clientOrigin); 304 }); 305 } 306 307 bool WebSWServerConnection::computeThrottleState(const RegistrableDomain& domain) const 308 { 309 return WTF::allOf(server().connections().values(), [&domain](auto& serverConnection) { 310 auto& connection = static_cast<WebSWServerConnection&>(*serverConnection); 311 return connection.isThrottleable() || !connection.hasMatchingClient(domain); 312 }); 313 } 314 315 void WebSWServerConnection::setThrottleState(bool isThrottleable) 316 { 317 m_isThrottleable = isThrottleable; 318 updateThrottleState(); 319 } 320 321 void WebSWServerConnection::updateThrottleState() 322 { 323 HashSet<SecurityOriginData> origins; 324 for (auto& origin : m_clientOrigins.values()) 325 origins.add(origin.clientOrigin); 326 327 for (auto& origin : origins) { 328 if (auto* contextConnection = SWServerToContextConnection::connectionForRegistrableDomain(RegistrableDomain { origin })) { 329 auto& connection = static_cast<WebSWServerToContextConnection&>(*contextConnection); 330 331 if (connection.isThrottleable() == m_isThrottleable) 332 continue; 333 bool newThrottleState = computeThrottleState(connection.registrableDomain()); 334 if (connection.isThrottleable() == newThrottleState) 335 continue; 336 connection.setThrottleState(newThrottleState); 337 } 338 } 339 } 340 341 void WebSWServerConnection::serverToContextConnectionCreated(WebCore::SWServerToContextConnection& contextConnection) 342 { 343 auto& connection = static_cast<WebSWServerToContextConnection&>(contextConnection); 344 connection.setThrottleState(computeThrottleState(connection.registrableDomain())); 291 345 } 292 346 -
trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.h
r243345 r245299 95 95 void syncTerminateWorkerFromClient(WebCore::ServiceWorkerIdentifier&&, CompletionHandler<void()>&&); 96 96 97 void serverToContextConnectionCreated(WebCore::SWServerToContextConnection&) final; 98 99 bool isThrottleable() const { return m_isThrottleable; } 100 bool hasMatchingClient(const WebCore::RegistrableDomain&) const; 101 bool computeThrottleState(const WebCore::RegistrableDomain&) const; 102 void setThrottleState(bool isThrottleable); 103 void updateThrottleState(); 104 97 105 IPC::Connection* messageSenderConnection() const final { return m_contentConnection.ptr(); } 98 106 uint64_t messageSenderDestinationID() const final { return identifier().toUInt64(); } … … 104 112 Ref<NetworkProcess> m_networkProcess; 105 113 HashMap<WebCore::ServiceWorkerClientIdentifier, WebCore::ClientOrigin> m_clientOrigins; 114 bool m_isThrottleable { true }; 106 115 }; 107 116 -
trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.messages.in
r243345 r245299 45 45 46 46 SyncTerminateWorkerFromClient(WebCore::ServiceWorkerIdentifier workerIdentifier) -> () Synchronous 47 48 SetThrottleState(bool isThrottleable) 47 49 } 48 50 -
trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.cpp
r242905 r245299 116 116 } 117 117 118 void WebSWServerToContextConnection::setThrottleState(bool isThrottleable) 119 { 120 m_isThrottleable = isThrottleable; 121 send(Messages::WebSWContextManagerConnection::SetThrottleState { isThrottleable }); 122 } 123 118 124 void WebSWServerToContextConnection::terminate() 119 125 { -
trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerToContextConnection.h
r242905 r245299 72 72 void didReceiveFetchTaskMessage(IPC::Connection&, IPC::Decoder&); 73 73 74 void setThrottleState(bool isThrottleable); 75 bool isThrottleable() const { return m_isThrottleable; } 76 74 77 private: 75 78 WebSWServerToContextConnection(NetworkProcess&, const WebCore::RegistrableDomain&, Ref<IPC::Connection>&&); … … 98 101 HashMap<ServiceWorkerFetchTask::Identifier, WebCore::FetchIdentifier> m_ongoingFetchIdentifiers; 99 102 HashMap<WebCore::FetchIdentifier, Ref<ServiceWorkerFetchTask>> m_ongoingFetches; 103 bool m_isThrottleable { true }; 100 104 }; // class WebSWServerToContextConnection 101 105 -
trunk/Source/WebKit/UIProcess/ServiceWorkerProcessProxy.cpp
r243384 r245299 107 107 } 108 108 109 void ServiceWorkerProcessProxy::didFinishLaunching(ProcessLauncher* launcher, IPC::Connection::Identifier connectionIdentifier)110 {111 WebProcessProxy::didFinishLaunching(launcher, connectionIdentifier);112 113 // Prevent App Nap for Service Worker processes.114 // FIXME: Ideally, the Service Worker process would app nap when all its clients app nap (http://webkit.org/b/185626).115 setProcessSuppressionEnabled(false);116 }117 118 109 } // namespace WebKit 119 110 -
trunk/Source/WebKit/UIProcess/ServiceWorkerProcessProxy.h
r242905 r245299 55 55 void getLaunchOptions(ProcessLauncher::LaunchOptions&) final; 56 56 57 // ProcessLauncher::Client58 void didFinishLaunching(ProcessLauncher*, IPC::Connection::Identifier) final;59 60 57 bool isServiceWorkerProcess() const final { return true; } 61 58 -
trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp
r244160 r245299 61 61 62 62 ASSERT_UNUSED(result, result); 63 updateThrottleState(); 63 64 } 64 65 … … 232 233 } 233 234 235 void WebSWClientConnection::updateThrottleState() 236 { 237 m_isThrottleable = WebProcess::singleton().areAllPagesThrottleable(); 238 send(Messages::WebSWServerConnection::SetThrottleState { m_isThrottleable }); 239 } 240 234 241 } // namespace WebKit 235 242 -
trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h
r244160 r245299 88 88 89 89 void didResolveRegistrationPromise(const WebCore::ServiceWorkerRegistrationKey&) final; 90 void updateThrottleState() final; 91 bool isThrottleable() const final { return m_isThrottleable; } 90 92 91 93 void scheduleStorageJob(const WebCore::ServiceWorkerJobData&); … … 110 112 HashMap<uint64_t, WhenRegistrationReadyCallback> m_ongoingRegistrationReadyTasks; 111 113 Deque<WTF::Function<void()>> m_tasksPendingOriginImport; 112 114 bool m_isThrottleable { true }; 113 115 }; // class WebSWServerConnection 114 116 -
trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp
r242503 r245299 365 365 } 366 366 367 void WebSWContextManagerConnection::setThrottleState(bool isThrottleable) 368 { 369 RELEASE_LOG(ServiceWorker, "Service worker throttleable state is set to %d", isThrottleable); 370 m_isThrottleable = isThrottleable; 371 WebProcess::singleton().setProcessSuppressionEnabled(isThrottleable); 372 } 373 374 bool WebSWContextManagerConnection::isThrottleable() const 375 { 376 return m_isThrottleable; 377 } 378 367 379 } // namespace WebCore 368 380 -
trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h
r242279 r245299 74 74 void skipWaiting(WebCore::ServiceWorkerIdentifier, Function<void()>&&) final; 75 75 void setScriptResource(WebCore::ServiceWorkerIdentifier, const URL&, const WebCore::ServiceWorkerContextData::ImportedScript&) final; 76 bool isThrottleable() const final; 76 77 77 78 // IPC messages. … … 92 93 void setUserAgent(String&& userAgent); 93 94 NO_RETURN void terminateProcess(); 95 void setThrottleState(bool isThrottleable); 94 96 95 97 Ref<IPC::Connection> m_connectionToNetworkProcess; … … 107 109 uint64_t m_previousRequestIdentifier { 0 }; 108 110 String m_userAgent; 111 bool m_isThrottleable { true }; 109 112 }; 110 113 -
trunk/Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.messages.in
r243345 r245299 40 40 UpdatePreferencesStore(struct WebKit::WebPreferencesStore store) 41 41 TerminateProcess() 42 SetThrottleState(bool isThrottleable) 42 43 } 43 44 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r245196 r245299 214 214 #include <WebCore/ResourceResponse.h> 215 215 #include <WebCore/RuntimeEnabledFeatures.h> 216 #include <WebCore/SWClientConnection.h> 216 217 #include <WebCore/SchemeRegistry.h> 217 218 #include <WebCore/ScriptController.h> … … 766 767 void WebPage::updateThrottleState() 767 768 { 768 bool isActive = m_activityState.containsAny({ ActivityState::IsLoading, ActivityState::IsAudible, ActivityState::IsCapturingMedia, ActivityState::WindowIsActive }); 769 bool isVisuallyIdle = m_activityState.contains(ActivityState::IsVisuallyIdle); 770 771 bool shouldAllowAppNap = m_isAppNapEnabled && !isActive && isVisuallyIdle; 769 bool isThrottleable = this->isThrottleable(); 772 770 773 771 // The UserActivity prevents App Nap. So if we want to allow App Nap of the page, stop the activity. 774 772 // If the page should not be app nap'd, start it. 775 if ( shouldAllowAppNap)773 if (isThrottleable) 776 774 m_userActivity.stop(); 777 775 else 778 776 m_userActivity.start(); 777 778 #if ENABLE(SERVICE_WORKER) 779 if (auto* connection = ServiceWorkerProvider::singleton().existingServiceWorkerConnectionForSession(sessionID())) { 780 if (isThrottleable != connection->isThrottleable()) 781 connection->updateThrottleState(); 782 } 783 #endif 784 } 785 786 bool WebPage::isThrottleable() const 787 { 788 bool isActive = m_activityState.containsAny({ ActivityState::IsLoading, ActivityState::IsAudible, ActivityState::IsCapturingMedia, ActivityState::WindowIsActive }); 789 bool isVisuallyIdle = m_activityState.contains(ActivityState::IsVisuallyIdle); 790 791 return m_isAppNapEnabled && !isActive && isVisuallyIdle; 779 792 } 780 793 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r245183 r245299 1192 1192 void updateIntrinsicContentSizeIfNeeded(const WebCore::IntSize&); 1193 1193 void scheduleFullEditorStateUpdate(); 1194 bool isThrottleable() const; 1194 1195 1195 1196 private: -
trunk/Source/WebKit/WebProcess/WebProcess.cpp
r245069 r245299 118 118 #include <WebCore/Settings.h> 119 119 #include <WebCore/UserGestureIndicator.h> 120 #include <wtf/Algorithms.h> 120 121 #include <wtf/Language.h> 121 122 #include <wtf/ProcessPrivilege.h> … … 1908 1909 #endif 1909 1910 1911 bool WebProcess::areAllPagesThrottleable() const 1912 { 1913 return WTF::allOf(m_pageMap.values(), [](auto& page) { 1914 return page->isThrottleable(); 1915 }); 1916 } 1917 1910 1918 } // namespace WebKit -
trunk/Source/WebKit/WebProcess/WebProcess.h
r245069 r245299 270 270 #endif 271 271 272 bool areAllPagesThrottleable() const; 273 272 274 private: 273 275 WebProcess(); -
trunk/Tools/ChangeLog
r245290 r245299 1 2019-05-14 Youenn Fablet <youenn@apple.com> 2 3 A service worker process should app nap when all its clients app nap 4 https://bugs.webkit.org/show_bug.cgi?id=185626 5 <rdar://problem/46785908> 6 7 Reviewed by Alex Christensen. 8 9 Allow to enable app nap through test header. 10 11 * WebKitTestRunner/TestController.cpp: 12 (WTR::TestController::resetPreferencesToConsistentValues): 13 (WTR::updateTestOptionsFromTestHeader): 14 * WebKitTestRunner/TestOptions.h: 15 (WTR::TestOptions::hasSameInitializationOptions const): 16 1 17 2019-05-14 Commit Queue <commit-queue@webkit.org> 2 18 -
trunk/Tools/WebKitTestRunner/TestController.cpp
r245280 r245299 785 785 786 786 WKPreferencesSetProcessSwapOnNavigationEnabled(preferences, options.contextOptions.shouldEnableProcessSwapOnNavigation()); 787 WKPreferencesSetPageVisibilityBasedProcessSuppressionEnabled(preferences, false);787 WKPreferencesSetPageVisibilityBasedProcessSuppressionEnabled(preferences, options.enableAppNap); 788 788 WKPreferencesSetOfflineWebApplicationCacheEnabled(preferences, true); 789 789 WKPreferencesSetSubpixelAntialiasedLayerTextEnabled(preferences, false); … … 1398 1398 else if (key == "shouldUseModernCompatibilityMode") 1399 1399 testOptions.shouldUseModernCompatibilityMode = parseBooleanTestHeaderValue(value); 1400 else if (key == "enableAppNap") 1401 testOptions.enableAppNap = parseBooleanTestHeaderValue(value); 1400 1402 pairStart = pairEnd + 1; 1401 1403 } -
trunk/Tools/WebKitTestRunner/TestOptions.h
r245280 r245299 93 93 bool shouldPresentPopovers { true }; 94 94 bool shouldUseModernCompatibilityMode { false }; 95 bool enableAppNap { false }; 95 96 96 97 double contentInsetTop { 0 }; … … 145 146 || shouldPresentPopovers != options.shouldPresentPopovers 146 147 || contentInsetTop != options.contentInsetTop 147 || shouldUseModernCompatibilityMode != options.shouldUseModernCompatibilityMode) 148 || shouldUseModernCompatibilityMode != options.shouldUseModernCompatibilityMode 149 || enableAppNap != options.enableAppNap) 148 150 return false; 149 151
Note:
See TracChangeset
for help on using the changeset viewer.