Changeset 286905 in webkit
- Timestamp:
- Dec 10, 2021, 11:17:48 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 12 edited
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/page/Page.cpp (modified) (1 diff)
-
WebCore/page/Page.h (modified) (1 diff)
-
WebCore/page/scrolling/ScrollingCoordinator.h (modified) (1 diff)
-
WebCore/page/scrolling/ThreadedScrollingTree.cpp (modified) (2 diffs)
-
WebCore/page/scrolling/ThreadedScrollingTree.h (modified) (2 diffs)
-
WebCore/page/scrolling/mac/ScrollingCoordinatorMac.h (modified) (1 diff)
-
WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm (modified) (1 diff)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/WebProcess/WebPage/WebPage.cpp (modified) (1 diff)
-
WebKit/WebProcess/WebPage/WebPage.h (modified) (1 diff)
-
WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r286904 r286905 1 2021-12-10 Simon Fraser <simon.fraser@apple.com> 2 3 Scrolling can drop frames when CoreAnimation commits take a long time 4 https://bugs.webkit.org/show_bug.cgi?id=234160 5 <rdar://86235740> 6 7 Reviewed by Tim Horton. 8 9 In r261985 I added a mechanism that has the scrolling thread wait for the main thread to 10 finish a rendering update, and, if the main thread fails to complete in time, then the 11 scrolling thread commits. This allows for scrolling synchronization when the main thread is 12 responsive, but smooth scrolling when the main thread is busy. 13 14 However, r261985 only waits for WebKit work to finish; what we really care about is whether 15 the main thread completes its CA commit in time (because that determines whether the scroll 16 shows on the screen). 17 18 So plumb through pre-/post-commit hooks from TiledCoreAnimationDrawingArea, which already 19 had them for inspector instrumentation. Then have ThreadedScrollingTree notify 20 m_stateCondition in didCompletePlatformRenderingUpdate(), instead of 21 didCompleteRenderingUpdate(). 22 23 Also, now we can call the inspector hooks from Page, rather than out in TiledCoreAnimationDrawingArea. 24 25 * page/Page.cpp: 26 (WebCore::Page::willStartPlatformRenderingUpdate): 27 (WebCore::Page::didCompletePlatformRenderingUpdate): 28 * page/Page.h: 29 * page/scrolling/ScrollingCoordinator.h: 30 (WebCore::ScrollingCoordinator::willStartPlatformRenderingUpdate): 31 (WebCore::ScrollingCoordinator::didCompletePlatformRenderingUpdate): 32 * page/scrolling/ThreadedScrollingTree.cpp: 33 (WebCore::ThreadedScrollingTree::didCompletePlatformRenderingUpdate): 34 (WebCore::ThreadedScrollingTree::didCompleteRenderingUpdate): Deleted. 35 * page/scrolling/ThreadedScrollingTree.h: 36 * page/scrolling/mac/ScrollingCoordinatorMac.h: 37 * page/scrolling/mac/ScrollingCoordinatorMac.mm: 38 (WebCore::ScrollingCoordinatorMac::didCompletePlatformRenderingUpdate): 39 1 40 2021-12-10 Chris Dumez <cdumez@apple.com> 2 41 -
trunk/Source/WebCore/page/Page.cpp
r286772 r286905 1793 1793 } 1794 1794 1795 void Page::willStartPlatformRenderingUpdate() 1796 { 1797 // Inspector's use of "composite" is rather innacurate. On Apple platforms, the "composite" step happens 1798 // in another process; these hooks wrap the non-WebKit CA commit time which is mostly painting-related. 1799 m_inspectorController->willComposite(mainFrame()); 1800 1801 if (m_scrollingCoordinator) 1802 m_scrollingCoordinator->willStartPlatformRenderingUpdate(); 1803 } 1804 1805 void Page::didCompletePlatformRenderingUpdate() 1806 { 1807 if (m_scrollingCoordinator) 1808 m_scrollingCoordinator->didCompletePlatformRenderingUpdate(); 1809 1810 m_inspectorController->didComposite(mainFrame()); 1811 } 1812 1795 1813 void Page::prioritizeVisibleResources() 1796 1814 { -
trunk/Source/WebCore/page/Page.h
r286767 r286905 621 621 WEBCORE_EXPORT unsigned renderingUpdateCount() const; 622 622 623 // A "platform rendering update" here describes the work done by the system graphics framework before work is submitted to the system compositor. 624 // On macOS, this is a CoreAnimation commit. 625 WEBCORE_EXPORT void willStartPlatformRenderingUpdate(); 626 WEBCORE_EXPORT void didCompletePlatformRenderingUpdate(); 627 623 628 WEBCORE_EXPORT void suspendScriptedAnimations(); 624 629 WEBCORE_EXPORT void resumeScriptedAnimations(); -
trunk/Source/WebCore/page/scrolling/ScrollingCoordinator.h
r284738 r286905 105 105 virtual void didCompleteRenderingUpdate() { } 106 106 107 virtual void willStartPlatformRenderingUpdate() { } 108 virtual void didCompletePlatformRenderingUpdate() { } 109 107 110 #if ENABLE(KINETIC_SCROLLING) 108 111 // Dispatched by the scrolling tree during handleWheelEvent. This is required as long as scrollbars are painted on the main thread. -
trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp
r286411 r286905 390 390 391 391 // This code allows the main thread about half a frame to complete its rendering udpate. If the main thread 392 // is responsive (i.e. managing to render every frame), then we expect to get a didComplete RenderingUpdate()392 // is responsive (i.e. managing to render every frame), then we expect to get a didCompletePlatformRenderingUpdate() 393 393 // within 8ms of willStartRenderingUpdate(). We time this via m_stateCondition, which blocks the scrolling 394 394 // thread (with m_treeLock locked at the start and end) so that we don't handle wheel events while waiting. … … 431 431 void ThreadedScrollingTree::didCompleteRenderingUpdate() 432 432 { 433 // macOS needs to wait for the CA commit (the "platform rendering update"). 434 #if !PLATFORM(MAC) 435 renderingUpdateComplete(); 436 #endif 437 } 438 439 void ThreadedScrollingTree::didCompletePlatformRenderingUpdate() 440 { 441 renderingUpdateComplete(); 442 } 443 444 void ThreadedScrollingTree::renderingUpdateComplete() 445 { 433 446 ASSERT(isMainThread()); 447 434 448 Locker locker { m_treeLock }; 435 449 -
trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.h
r286410 r286905 62 62 void didCompleteRenderingUpdate(); 63 63 64 void didCompletePlatformRenderingUpdate(); 65 64 66 Lock& treeLock() WTF_RETURNS_LOCK(m_treeLock) { return m_treeLock; } 65 67 … … 97 99 void displayDidRefreshOnScrollingThread(); 98 100 void waitForRenderingUpdateCompletionOrTimeout() WTF_REQUIRES_LOCK(m_treeLock); 101 void renderingUpdateComplete(); 99 102 100 103 bool canUpdateLayersOnScrollingThread() const WTF_REQUIRES_LOCK(m_treeLock); -
trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.h
r285094 r286905 54 54 void didCompleteRenderingUpdate() final; 55 55 56 void didCompletePlatformRenderingUpdate() final; 57 56 58 void updateTiledScrollingIndicator(); 57 59 -
trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm
r285094 r286905 143 143 } 144 144 145 void ScrollingCoordinatorMac::didCompletePlatformRenderingUpdate() 146 { 147 downcast<ThreadedScrollingTree>(scrollingTree())->didCompletePlatformRenderingUpdate(); 148 } 149 145 150 void ScrollingCoordinatorMac::hasNodeWithAnimatedScrollChanged(bool hasAnimatingNode) 146 151 { -
trunk/Source/WebKit/ChangeLog
r286900 r286905 1 2021-12-10 Simon Fraser <simon.fraser@apple.com> 2 3 Scrolling can drop frames when CoreAnimation commits take a long time 4 https://bugs.webkit.org/show_bug.cgi?id=234160 5 <rdar://86235740> 6 7 Reviewed by Tim Horton. 8 9 In r261985 I added a mechanism that has the scrolling thread wait for the main thread to 10 finish a rendering update, and, if the main thread fails to complete in time, then the 11 scrolling thread commits. This allows for scrolling synchronization when the main thread is 12 responsive, but smooth scrolling when the main thread is busy. 13 14 However, r261985 only waits for WebKit work to finish; what we really care about is whether 15 the main thread completes its CA commit in time (because that determines whether the scroll 16 shows on the screen). 17 18 So plumb through pre-/post-commit hooks from TiledCoreAnimationDrawingArea, which already 19 had them for inspector instrumentation. Then have ThreadedScrollingTree notify 20 m_stateCondition in didCompletePlatformRenderingUpdate(), instead of 21 didCompleteRenderingUpdate(). 22 23 Also, now we can call the inspector hooks from Page, rather than out in TiledCoreAnimationDrawingArea. 24 25 * WebProcess/WebPage/WebPage.cpp: 26 (WebKit::WebPage::willStartPlatformRenderingUpdate): 27 (WebKit::WebPage::didCompletePlatformRenderingUpdate): 28 * WebProcess/WebPage/WebPage.h: 29 * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm: 30 (WebKit::TiledCoreAnimationDrawingArea::addCommitHandlers): 31 1 32 2021-12-10 Tim Horton <timothy_horton@apple.com> 2 33 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r286825 r286905 4289 4289 } 4290 4290 4291 void WebPage::willStartPlatformRenderingUpdate() 4292 { 4293 if (m_isClosed) 4294 return; 4295 m_page->willStartPlatformRenderingUpdate(); 4296 } 4297 4298 void WebPage::didCompletePlatformRenderingUpdate() 4299 { 4300 if (m_isClosed) 4301 return; 4302 m_page->didCompletePlatformRenderingUpdate(); 4303 } 4304 4291 4305 void WebPage::releaseMemory(Critical) 4292 4306 { -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r286886 r286905 667 667 void didUpdateRendering(); 668 668 669 // A "platform rendering update" here describes the work done by the system graphics framework before work is submitted to the system compositor. 670 // On macOS, this is a CoreAnimation commit. 671 void willStartPlatformRenderingUpdate(); 672 void didCompletePlatformRenderingUpdate(); 673 669 674 #if PLATFORM(MAC) 670 675 void setTopOverhangImage(WebImage*); -
trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm
r286834 r286905 415 415 416 416 [CATransaction addCommitHandler:[retainedPage = Ref { m_webPage }] { 417 if (Page* corePage = retainedPage->corePage()) { 418 if (Frame* coreFrame = retainedPage->mainFrame()) 419 corePage->inspectorController().willComposite(*coreFrame); 420 } 417 retainedPage->willStartPlatformRenderingUpdate(); 421 418 } forPhase:kCATransactionPhasePreLayout]; 422 419 423 420 [CATransaction addCommitHandler:[retainedPage = Ref { m_webPage }] { 424 if (Page* corePage = retainedPage->corePage()) {425 if (Frame* coreFrame = retainedPage->mainFrame())426 corePage->inspectorController().didComposite(*coreFrame);427 }428 421 if (auto drawingArea = static_cast<TiledCoreAnimationDrawingArea*>(retainedPage->drawingArea())) 429 422 drawingArea->sendPendingNewlyReachedPaintingMilestones(); 423 430 424 retainedPage->setFirstFlushAfterCommit(false); 425 retainedPage->didCompletePlatformRenderingUpdate(); 431 426 } forPhase:kCATransactionPhasePostCommit]; 432 427
Note:
See TracChangeset
for help on using the changeset viewer.