Changeset 279495 in webkit
- Timestamp:
- Jul 1, 2021, 8:14:26 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 9 edited
-
WebCore/workers/service/context/SWContextManager.cpp (modified) (2 diffs)
-
WebCore/workers/service/context/SWContextManager.h (modified) (2 diffs)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/UIProcess/WebProcessProxy.cpp (modified) (2 diffs)
-
WebKit/UIProcess/WebProcessProxy.h (modified) (1 diff)
-
WebKit/UIProcess/mac/WebProcessProxyMac.mm (modified) (2 diffs)
-
WebKit/WebProcess/WebProcess.cpp (modified) (2 diffs)
-
WebKit/WebProcess/WebProcess.h (modified) (1 diff)
-
WebKit/WebProcess/WebProcess.messages.in (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/workers/service/context/SWContextManager.cpp
r278253 r279495 144 144 completionHandler(); 145 145 146 if (m_pendingServiceWorkerTerminationRequests.isEmpty()) { 147 for (auto& handler : std::exchange(m_whenTerminationRequestsAreDoneHandlers, { })) 148 handler(); 149 } 150 146 151 // Spin the runloop before releasing the worker thread proxy, as there would otherwise be 147 152 // a race towards its destruction. … … 150 155 } 151 156 157 void SWContextManager::whenTerminationRequestsAreDone(CompletionHandler<void()>&& completionHandler) 158 { 159 if (m_pendingServiceWorkerTerminationRequests.isEmpty()) 160 return completionHandler(); 161 162 m_whenTerminationRequestsAreDoneHandlers.append(WTFMove(completionHandler)); 163 } 164 152 165 void SWContextManager::forEachServiceWorkerThread(const WTF::Function<void(ServiceWorkerThreadProxy&)>& apply) 153 166 { -
trunk/Source/WebCore/workers/service/context/SWContextManager.h
r278253 r279495 108 108 static constexpr Seconds syncWorkerTerminationTimeout { 100_ms }; // Only used by layout tests. 109 109 110 WEBCORE_EXPORT void whenTerminationRequestsAreDone(CompletionHandler<void()>&&); 111 110 112 private: 111 113 SWContextManager() = default; … … 129 131 }; 130 132 HashMap<ServiceWorkerIdentifier, std::unique_ptr<ServiceWorkerTerminationRequest>> m_pendingServiceWorkerTerminationRequests; 133 Vector<CompletionHandler<void()>> m_whenTerminationRequestsAreDoneHandlers; 131 134 }; 132 135 -
trunk/Source/WebKit/ChangeLog
r279494 r279495 1 2021-07-01 Chris Dumez <cdumez@apple.com> 2 3 [macOS] Suspend WebProcesses that are in the process cache 4 https://bugs.webkit.org/show_bug.cgi?id=227269 5 6 Reviewed by Geoffrey Garen. 7 8 Suspend WebProcesses that are in the process cache on macOS to make sure they use no CPU. 9 10 * UIProcess/WebProcessProxy.cpp: 11 (WebKit::WebProcessProxy::setIsInProcessCache): 12 (WebKit::WebProcessProxy::platformSuspendProcess): 13 (WebKit::WebProcessProxy::platformResumeProcess): 14 * UIProcess/WebProcessProxy.h: 15 * UIProcess/mac/WebProcessProxyMac.mm: 16 (WebKit::WebProcessProxy::platformSuspendProcess): 17 (WebKit::WebProcessProxy::platformResumeProcess): 18 * WebProcess/WebProcess.cpp: 19 (WebKit::WebProcess::setIsInProcessCache): 20 * WebProcess/WebProcess.h: 21 * WebProcess/WebProcess.messages.in: 22 1 23 2021-07-01 Alex Christensen <achristensen@webkit.org> 2 24 -
trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp
r279411 r279495 290 290 m_isInProcessCache = value; 291 291 292 send(Messages::WebProcess::SetIsInProcessCache(m_isInProcessCache), 0); 292 if (!m_isInProcessCache) 293 platformResumeProcess(); 294 295 sendWithAsyncReply(Messages::WebProcess::SetIsInProcessCache(m_isInProcessCache), [weakThis = makeWeakPtr(*this), isEnteringProcessCache = value]() mutable { 296 if (isEnteringProcessCache && weakThis && weakThis->m_isInProcessCache) 297 weakThis->platformSuspendProcess(); 298 }); 293 299 294 300 if (m_isInProcessCache) { … … 2004 2010 } 2005 2011 2012 #if !PLATFORM(MAC) 2013 void WebProcessProxy::platformSuspendProcess() 2014 { 2015 } 2016 2017 void WebProcessProxy::platformResumeProcess() 2018 { 2019 } 2020 #endif 2021 2006 2022 } // namespace WebKit 2007 2023 -
trunk/Source/WebKit/UIProcess/WebProcessProxy.h
r279411 r279495 472 472 void processDidTerminateOrFailedToLaunch(ProcessTerminationReason); 473 473 474 void platformSuspendProcess(); 475 void platformResumeProcess(); 476 474 477 // IPC::Connection::Client 475 478 friend class WebConnectionToWebProcess; -
trunk/Source/WebKit/UIProcess/mac/WebProcessProxyMac.mm
r279411 r279495 32 32 #import "WKFullKeyboardAccessWatcher.h" 33 33 #import <Kernel/kern/cs_blobs.h> 34 #import <signal.h> 34 35 #import <wtf/ProcessPrivilege.h> 35 36 #import <wtf/spi/cocoa/SecuritySPI.h> … … 79 80 } 80 81 82 void WebProcessProxy::platformSuspendProcess() 83 { 84 RELEASE_LOG(Process, "%p - [PID=%i] WebProcessProxy::platformSuspendProcess", this, processIdentifier()); 85 ALLOW_DEPRECATED_DECLARATIONS_BEGIN 86 if (auto* connection = this->connection()) 87 xpc_connection_kill(connection->xpcConnection(), SIGSTOP); 88 ALLOW_DEPRECATED_DECLARATIONS_END 89 } 90 91 void WebProcessProxy::platformResumeProcess() 92 { 93 RELEASE_LOG(Process, "%p - [PID=%i] WebProcessProxy::platformResumeProcess", this, processIdentifier()); 94 ALLOW_DEPRECATED_DECLARATIONS_BEGIN 95 if (auto* connection = this->connection()) 96 xpc_connection_kill(connection->xpcConnection(), SIGCONT); 97 ALLOW_DEPRECATED_DECLARATIONS_END 98 } 99 81 100 } // namespace WebKit 82 101 -
trunk/Source/WebKit/WebProcess/WebProcess.cpp
r279477 r279495 615 615 } 616 616 617 void WebProcess::setIsInProcessCache(bool isInProcessCache )617 void WebProcess::setIsInProcessCache(bool isInProcessCache, CompletionHandler<void()>&& completionHandler) 618 618 { 619 619 #if PLATFORM(COCOA) … … 630 630 UNUSED_PARAM(isInProcessCache); 631 631 #endif 632 633 #if ENABLE(SERVICE_WORKER) 634 if (isInProcessCache) { 635 // When calling the completion handler, the parent process may suspend us. We do not want to get suspended until pending requests to 636 // stop service workers are processed because this would be wasteful from a memory standpoint. Also, service worker termination 637 // requests have a timeout and this timeout would be reached if we suspended while it is being processed. 638 SWContextManager::singleton().whenTerminationRequestsAreDone(WTFMove(completionHandler)); 639 return; 640 } 641 #endif 642 643 completionHandler(); 632 644 } 633 645 -
trunk/Source/WebKit/WebProcess/WebProcess.h
r279411 r279495 421 421 422 422 void setHasSuspendedPageProxy(bool); 423 void setIsInProcessCache(bool );423 void setIsInProcessCache(bool, CompletionHandler<void()>&&); 424 424 void markIsNoLongerPrewarmed(); 425 425 -
trunk/Source/WebKit/WebProcess/WebProcess.messages.in
r279411 r279495 106 106 107 107 SetHasSuspendedPageProxy(bool hasSuspendedPageProxy); 108 SetIsInProcessCache(bool isInProcessCache) 108 SetIsInProcessCache(bool isInProcessCache) -> () Async 109 109 MarkIsNoLongerPrewarmed() 110 110 GetActivePagesOriginsForTesting() -> (Vector<String> activeOrigins) Async
Note:
See TracChangeset
for help on using the changeset viewer.