Changeset 266771 in webkit
- Timestamp:
- Sep 8, 2020 9:12:33 PM (4 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r266766 r266771 1 2020-09-08 Chris Dumez <cdumez@apple.com> 2 3 Regression(r260614) Power usage has increased due to extra thread hopping 4 https://bugs.webkit.org/show_bug.cgi?id=216296 5 <rdar://problem/67719299> 6 7 Reviewed by Simon Fraser. 8 9 Power usage has increased after r260614 due to extra thread hopping. To recover, 10 we now process the DisplayWasRefreshed IPC to a background queue if there is 11 scrolling going on and responsiveness is thus critical. In the common case, where 12 the user is not scrolling, we keep processing the IPC on the main thread, like 13 before r260614. This avoids extra thread hopping and saves power. 14 15 * UIProcess/WebPageProxy.cpp: 16 (WebKit::ScrollingObserver::willSendWheelEvent): 17 (WebKit::ScrollingObserver::ScrollingObserver): 18 (WebKit::ScrollingObserver::singleton): 19 (WebKit::WebPageProxy::sendWheelEvent): 20 * UIProcess/mac/DisplayLink.cpp: 21 (WebKit::DisplayLink::displayLinkCallback): 22 * UIProcess/mac/DisplayLink.h: 23 (WebKit::DisplayLink::setShouldSendIPCOnBackgroundQueue): 24 * WebProcess/WebPage/EventDispatcher.cpp: 25 (WebKit::EventDispatcher::notifyScrollingTreesDisplayWasRefreshed): 26 (WebKit::EventDispatcher::displayWasRefreshed): 27 * WebProcess/WebPage/EventDispatcher.h: 28 * WebProcess/WebProcess.cpp: 29 (WebKit::WebProcess::displayWasRefreshed): 30 * WebProcess/WebProcess.h: 31 * WebProcess/WebProcess.messages.in: 32 1 33 2020-09-08 Megan Gardner <megan_gardner@apple.com> 2 34 -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r266654 r266771 180 180 #include <WebCore/WindowFeatures.h> 181 181 #include <WebCore/WritingDirection.h> 182 #include <pal/HysteresisActivity.h> 182 183 #include <stdio.h> 183 184 #include <wtf/CallbackAggregator.h> … … 295 296 #endif 296 297 298 #if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING) 299 #include "DisplayLink.h" 300 #endif 301 297 302 // This controls what strategy we use for mouse wheel coalescing. 298 303 #define MERGE_WHEEL_EVENTS 1 … … 317 322 318 323 DEFINE_DEBUG_ONLY_GLOBAL(WTF::RefCountedLeakCounter, webPageProxyCounter, ("WebPageProxy")); 324 325 #if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING) 326 class ScrollingObserver { 327 WTF_MAKE_NONCOPYABLE(ScrollingObserver); 328 WTF_MAKE_FAST_ALLOCATED; 329 friend NeverDestroyed<ScrollingObserver>; 330 public: 331 static ScrollingObserver& singleton(); 332 333 void willSendWheelEvent() 334 { 335 m_hysteresis.impulse(); 336 } 337 338 private: 339 ScrollingObserver() 340 : m_hysteresis([](PAL::HysteresisState state) { DisplayLink::setShouldSendIPCOnBackgroundQueue(state == PAL::HysteresisState::Started); }) 341 { 342 } 343 344 PAL::HysteresisActivity m_hysteresis; 345 }; 346 347 ScrollingObserver& ScrollingObserver::singleton() 348 { 349 static NeverDestroyed<ScrollingObserver> detector; 350 return detector; 351 } 352 #endif // ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING) 319 353 320 354 class StorageRequests { … … 2697 2731 void WebPageProxy::sendWheelEvent(const WebWheelEvent& event) 2698 2732 { 2733 #if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING) 2734 ScrollingObserver::singleton().willSendWheelEvent(); 2735 #endif 2736 2699 2737 send( 2700 2738 Messages::EventDispatcher::WheelEvent( -
trunk/Source/WebKit/UIProcess/mac/DisplayLink.cpp
r266710 r266771 33 33 34 34 namespace WebKit { 35 36 bool DisplayLink::shouldSendIPCOnBackgroundQueue { false }; 35 37 36 38 DisplayLink::DisplayLink(WebCore::PlatformDisplayID displayID) … … 132 134 auto* displayLink = static_cast<DisplayLink*>(data); 133 135 LockHolder locker(displayLink->m_observersLock); 134 for (auto& connection : displayLink->m_observers.keys()) 135 connection->send(Messages::EventDispatcher::DisplayWasRefreshed(displayLink->m_displayID), 0); 136 for (auto& connection : displayLink->m_observers.keys()) { 137 if (shouldSendIPCOnBackgroundQueue) 138 connection->send(Messages::EventDispatcher::DisplayWasRefreshed(displayLink->m_displayID), 0); 139 else 140 connection->send(Messages::WebProcess::DisplayWasRefreshed(displayLink->m_displayID), 0); 141 } 136 142 return kCVReturnSuccess; 137 143 } -
trunk/Source/WebKit/UIProcess/mac/DisplayLink.h
r266710 r266771 55 55 Optional<unsigned> nominalFramesPerSecond() const; 56 56 57 // When responsiveness is critical, we send the IPC to a background queue. Otherwise, we send it to the 58 // main thread to avoid unnecessary thread hopping and save power. 59 static void setShouldSendIPCOnBackgroundQueue(bool value) { shouldSendIPCOnBackgroundQueue = value; } 60 57 61 private: 58 62 static CVReturn displayLinkCallback(CVDisplayLinkRef, const CVTimeStamp*, const CVTimeStamp*, CVOptionFlags, CVOptionFlags*, void* data); … … 62 66 HashMap<RefPtr<IPC::Connection>, Vector<DisplayLinkObserverID>> m_observers; 63 67 WebCore::PlatformDisplayID m_displayID; 68 static bool shouldSendIPCOnBackgroundQueue; 64 69 }; 65 70 -
trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.cpp
r265743 r266771 270 270 271 271 #if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING) 272 void EventDispatcher::displayWasRefreshed(PlatformDisplayID displayID) 272 273 void EventDispatcher::notifyScrollingTreesDisplayWasRefreshed(PlatformDisplayID displayID) 273 274 { 274 275 #if ENABLE(SCROLLING_THREAD) … … 277 278 keyValuePair.value->displayDidRefresh(displayID); 278 279 #endif 280 } 281 282 void EventDispatcher::displayWasRefreshed(PlatformDisplayID displayID) 283 { 284 ASSERT(!RunLoop::isMain()); 285 notifyScrollingTreesDisplayWasRefreshed(displayID); 279 286 280 287 RunLoop::main().dispatch([displayID]() { -
trunk/Source/WebKit/WebProcess/WebPage/EventDispatcher.h
r265515 r266771 69 69 void initializeConnection(IPC::Connection*); 70 70 71 #if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING) 72 void notifyScrollingTreesDisplayWasRefreshed(WebCore::PlatformDisplayID); 73 #endif 74 71 75 private: 72 76 EventDispatcher(); -
trunk/Source/WebKit/WebProcess/WebProcess.cpp
r266395 r266771 194 194 #endif 195 195 196 #if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING) 197 #include <WebCore/DisplayRefreshMonitorManager.h> 198 #endif 199 196 200 #define RELEASE_LOG_SESSION_ID (m_sessionID ? m_sessionID->toUInt64() : 0) 197 201 #define RELEASE_LOG_IF_ALLOWED(channel, fmt, ...) RELEASE_LOG_IF(isAlwaysOnLoggingAllowed(), channel, "%p - [sessionID=%" PRIu64 "] WebProcess::" fmt, this, RELEASE_LOG_SESSION_ID, ##__VA_ARGS__) … … 1901 1905 } 1902 1906 1907 #if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING) 1908 void WebProcess::displayWasRefreshed(uint32_t displayID) 1909 { 1910 ASSERT(RunLoop::isMain()); 1911 m_eventDispatcher->notifyScrollingTreesDisplayWasRefreshed(displayID); 1912 DisplayRefreshMonitorManager::sharedManager().displayWasUpdated(displayID); 1913 } 1914 #endif 1915 1903 1916 #if ENABLE(RESOURCE_LOAD_STATISTICS) 1904 1917 void WebProcess::setThirdPartyCookieBlockingMode(ThirdPartyCookieBlockingMode thirdPartyCookieBlockingMode, CompletionHandler<void()>&& completionHandler) -
trunk/Source/WebKit/WebProcess/WebProcess.h
r266214 r266771 479 479 #endif 480 480 481 #if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING) 482 void displayWasRefreshed(uint32_t displayID); 483 #endif 484 481 485 void platformInitializeProcess(const AuxiliaryProcessInitializationParameters&); 482 486 -
trunk/Source/WebKit/WebProcess/WebProcess.messages.in
r266214 r266771 184 184 DidWriteToPasteboardAsynchronously(String pasteboardName); 185 185 #endif 186 187 #if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING) 188 DisplayWasRefreshed(uint32_t displayID) 189 #endif 186 190 }
Note: See TracChangeset
for help on using the changeset viewer.