Changeset 286977 in webkit
- Timestamp:
- Dec 13, 2021, 12:57:05 PM (5 years ago)
- Location:
- branches/safari-612-branch/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
-
branches/safari-612-branch/Source/WebCore/ChangeLog
r286975 r286977 1 2021-12-13 Alan Coon <alancoon@apple.com> 2 3 Cherry-pick r286905. rdar://problem/86235740 4 5 Scrolling can drop frames when CoreAnimation commits take a long time 6 https://bugs.webkit.org/show_bug.cgi?id=234160 7 <rdar://86235740> 8 9 Reviewed by Tim Horton. 10 11 In r261985 I added a mechanism that has the scrolling thread wait for the main thread to 12 finish a rendering update, and, if the main thread fails to complete in time, then the 13 scrolling thread commits. This allows for scrolling synchronization when the main thread is 14 responsive, but smooth scrolling when the main thread is busy. 15 16 However, r261985 only waits for WebKit work to finish; what we really care about is whether 17 the main thread completes its CA commit in time (because that determines whether the scroll 18 shows on the screen). 19 20 So plumb through pre-/post-commit hooks from TiledCoreAnimationDrawingArea, which already 21 had them for inspector instrumentation. Then have ThreadedScrollingTree notify 22 m_stateCondition in didCompletePlatformRenderingUpdate(), instead of 23 didCompleteRenderingUpdate(). 24 Source/WebCore: 25 26 Also, now we can call the inspector hooks from Page, rather than out in TiledCoreAnimationDrawingArea. 27 28 * page/Page.cpp: 29 (WebCore::Page::willStartPlatformRenderingUpdate): 30 (WebCore::Page::didCompletePlatformRenderingUpdate): 31 * page/Page.h: 32 * page/scrolling/ScrollingCoordinator.h: 33 (WebCore::ScrollingCoordinator::willStartPlatformRenderingUpdate): 34 (WebCore::ScrollingCoordinator::didCompletePlatformRenderingUpdate): 35 * page/scrolling/ThreadedScrollingTree.cpp: 36 (WebCore::ThreadedScrollingTree::didCompletePlatformRenderingUpdate): 37 (WebCore::ThreadedScrollingTree::didCompleteRenderingUpdate): Deleted. 38 * page/scrolling/ThreadedScrollingTree.h: 39 * page/scrolling/mac/ScrollingCoordinatorMac.h: 40 * page/scrolling/mac/ScrollingCoordinatorMac.mm: 41 (WebCore::ScrollingCoordinatorMac::didCompletePlatformRenderingUpdate): 42 43 Source/WebKit: 44 45 Also, now we can call the inspector hooks from Page, rather than out in TiledCoreAnimationDrawingArea. 46 47 * WebProcess/WebPage/WebPage.cpp: 48 (WebKit::WebPage::willStartPlatformRenderingUpdate): 49 (WebKit::WebPage::didCompletePlatformRenderingUpdate): 50 * WebProcess/WebPage/WebPage.h: 51 * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm: 52 (WebKit::TiledCoreAnimationDrawingArea::addCommitHandlers): 53 54 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@286905 268f45cc-cd09-0410-ab3c-d52691b4dbfc 55 56 2021-12-10 Simon Fraser <simon.fraser@apple.com> 57 58 Scrolling can drop frames when CoreAnimation commits take a long time 59 https://bugs.webkit.org/show_bug.cgi?id=234160 60 <rdar://86235740> 61 62 Reviewed by Tim Horton. 63 64 In r261985 I added a mechanism that has the scrolling thread wait for the main thread to 65 finish a rendering update, and, if the main thread fails to complete in time, then the 66 scrolling thread commits. This allows for scrolling synchronization when the main thread is 67 responsive, but smooth scrolling when the main thread is busy. 68 69 However, r261985 only waits for WebKit work to finish; what we really care about is whether 70 the main thread completes its CA commit in time (because that determines whether the scroll 71 shows on the screen). 72 73 So plumb through pre-/post-commit hooks from TiledCoreAnimationDrawingArea, which already 74 had them for inspector instrumentation. Then have ThreadedScrollingTree notify 75 m_stateCondition in didCompletePlatformRenderingUpdate(), instead of 76 didCompleteRenderingUpdate(). 77 78 Also, now we can call the inspector hooks from Page, rather than out in TiledCoreAnimationDrawingArea. 79 80 * page/Page.cpp: 81 (WebCore::Page::willStartPlatformRenderingUpdate): 82 (WebCore::Page::didCompletePlatformRenderingUpdate): 83 * page/Page.h: 84 * page/scrolling/ScrollingCoordinator.h: 85 (WebCore::ScrollingCoordinator::willStartPlatformRenderingUpdate): 86 (WebCore::ScrollingCoordinator::didCompletePlatformRenderingUpdate): 87 * page/scrolling/ThreadedScrollingTree.cpp: 88 (WebCore::ThreadedScrollingTree::didCompletePlatformRenderingUpdate): 89 (WebCore::ThreadedScrollingTree::didCompleteRenderingUpdate): Deleted. 90 * page/scrolling/ThreadedScrollingTree.h: 91 * page/scrolling/mac/ScrollingCoordinatorMac.h: 92 * page/scrolling/mac/ScrollingCoordinatorMac.mm: 93 (WebCore::ScrollingCoordinatorMac::didCompletePlatformRenderingUpdate): 94 1 95 2021-12-13 Alan Coon <alancoon@apple.com> 2 96 -
branches/safari-612-branch/Source/WebCore/page/Page.cpp
r284351 r286977 1766 1766 } 1767 1767 1768 void Page::willStartPlatformRenderingUpdate() 1769 { 1770 // Inspector's use of "composite" is rather innacurate. On Apple platforms, the "composite" step happens 1771 // in another process; these hooks wrap the non-WebKit CA commit time which is mostly painting-related. 1772 m_inspectorController->willComposite(mainFrame()); 1773 1774 if (m_scrollingCoordinator) 1775 m_scrollingCoordinator->willStartPlatformRenderingUpdate(); 1776 } 1777 1778 void Page::didCompletePlatformRenderingUpdate() 1779 { 1780 if (m_scrollingCoordinator) 1781 m_scrollingCoordinator->didCompletePlatformRenderingUpdate(); 1782 1783 m_inspectorController->didComposite(mainFrame()); 1784 } 1785 1768 1786 void Page::prioritizeVisibleResources() 1769 1787 { -
branches/safari-612-branch/Source/WebCore/page/Page.h
r284351 r286977 585 585 WEBCORE_EXPORT unsigned renderingUpdateCount() const; 586 586 587 // A "platform rendering update" here describes the work done by the system graphics framework before work is submitted to the system compositor. 588 // On macOS, this is a CoreAnimation commit. 589 WEBCORE_EXPORT void willStartPlatformRenderingUpdate(); 590 WEBCORE_EXPORT void didCompletePlatformRenderingUpdate(); 591 587 592 WEBCORE_EXPORT void suspendScriptedAnimations(); 588 593 WEBCORE_EXPORT void resumeScriptedAnimations(); -
branches/safari-612-branch/Source/WebCore/page/scrolling/ScrollingCoordinator.h
r278419 r286977 103 103 virtual void didCompleteRenderingUpdate() { } 104 104 105 virtual void willStartPlatformRenderingUpdate() { } 106 virtual void didCompletePlatformRenderingUpdate() { } 107 105 108 #if ENABLE(KINETIC_SCROLLING) 106 109 // Dispatched by the scrolling tree during handleWheelEvent. This is required as long as scrollbars are painted on the main thread. -
branches/safari-612-branch/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp
r286975 r286977 311 311 312 312 // This code allows the main thread about half a frame to complete its rendering udpate. If the main thread 313 // is responsive (i.e. managing to render every frame), then we expect to get a didComplete RenderingUpdate()313 // is responsive (i.e. managing to render every frame), then we expect to get a didCompletePlatformRenderingUpdate() 314 314 // within 8ms of willStartRenderingUpdate(). We time this via m_stateCondition, which blocks the scrolling 315 315 // thread (with m_treeLock locked at the start and end) so that we don't handle wheel events while waiting. … … 352 352 void ThreadedScrollingTree::didCompleteRenderingUpdate() 353 353 { 354 // macOS needs to wait for the CA commit (the "platform rendering update"). 355 #if !PLATFORM(MAC) 356 renderingUpdateComplete(); 357 #endif 358 } 359 360 void ThreadedScrollingTree::didCompletePlatformRenderingUpdate() 361 { 362 renderingUpdateComplete(); 363 } 364 365 void ThreadedScrollingTree::renderingUpdateComplete() 366 { 354 367 ASSERT(isMainThread()); 368 355 369 Locker locker { m_treeLock }; 356 370 -
branches/safari-612-branch/Source/WebCore/page/scrolling/ThreadedScrollingTree.h
r286975 r286977 61 61 void didCompleteRenderingUpdate(); 62 62 63 void didCompletePlatformRenderingUpdate(); 64 63 65 Lock& treeLock() WTF_RETURNS_LOCK(m_treeLock) { return m_treeLock; } 64 66 … … 89 91 void displayDidRefreshOnScrollingThread(); 90 92 void waitForRenderingUpdateCompletionOrTimeout() WTF_REQUIRES_LOCK(m_treeLock); 93 void renderingUpdateComplete(); 91 94 92 95 bool canUpdateLayersOnScrollingThread() const WTF_REQUIRES_LOCK(m_treeLock); -
branches/safari-612-branch/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.h
r278253 r286977 51 51 void didCompleteRenderingUpdate() final; 52 52 53 void didCompletePlatformRenderingUpdate() final; 54 53 55 void updateTiledScrollingIndicator(); 54 56 -
branches/safari-612-branch/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm
r278253 r286977 136 136 } 137 137 138 void ScrollingCoordinatorMac::didCompletePlatformRenderingUpdate() 139 { 140 downcast<ThreadedScrollingTree>(scrollingTree())->didCompletePlatformRenderingUpdate(); 141 } 142 138 143 void ScrollingCoordinatorMac::updateTiledScrollingIndicator() 139 144 { -
branches/safari-612-branch/Source/WebKit/ChangeLog
r286976 r286977 1 2021-12-13 Alan Coon <alancoon@apple.com> 2 3 Cherry-pick r286905. rdar://problem/86235740 4 5 Scrolling can drop frames when CoreAnimation commits take a long time 6 https://bugs.webkit.org/show_bug.cgi?id=234160 7 <rdar://86235740> 8 9 Reviewed by Tim Horton. 10 11 In r261985 I added a mechanism that has the scrolling thread wait for the main thread to 12 finish a rendering update, and, if the main thread fails to complete in time, then the 13 scrolling thread commits. This allows for scrolling synchronization when the main thread is 14 responsive, but smooth scrolling when the main thread is busy. 15 16 However, r261985 only waits for WebKit work to finish; what we really care about is whether 17 the main thread completes its CA commit in time (because that determines whether the scroll 18 shows on the screen). 19 20 So plumb through pre-/post-commit hooks from TiledCoreAnimationDrawingArea, which already 21 had them for inspector instrumentation. Then have ThreadedScrollingTree notify 22 m_stateCondition in didCompletePlatformRenderingUpdate(), instead of 23 didCompleteRenderingUpdate(). 24 Source/WebCore: 25 26 Also, now we can call the inspector hooks from Page, rather than out in TiledCoreAnimationDrawingArea. 27 28 * page/Page.cpp: 29 (WebCore::Page::willStartPlatformRenderingUpdate): 30 (WebCore::Page::didCompletePlatformRenderingUpdate): 31 * page/Page.h: 32 * page/scrolling/ScrollingCoordinator.h: 33 (WebCore::ScrollingCoordinator::willStartPlatformRenderingUpdate): 34 (WebCore::ScrollingCoordinator::didCompletePlatformRenderingUpdate): 35 * page/scrolling/ThreadedScrollingTree.cpp: 36 (WebCore::ThreadedScrollingTree::didCompletePlatformRenderingUpdate): 37 (WebCore::ThreadedScrollingTree::didCompleteRenderingUpdate): Deleted. 38 * page/scrolling/ThreadedScrollingTree.h: 39 * page/scrolling/mac/ScrollingCoordinatorMac.h: 40 * page/scrolling/mac/ScrollingCoordinatorMac.mm: 41 (WebCore::ScrollingCoordinatorMac::didCompletePlatformRenderingUpdate): 42 43 Source/WebKit: 44 45 Also, now we can call the inspector hooks from Page, rather than out in TiledCoreAnimationDrawingArea. 46 47 * WebProcess/WebPage/WebPage.cpp: 48 (WebKit::WebPage::willStartPlatformRenderingUpdate): 49 (WebKit::WebPage::didCompletePlatformRenderingUpdate): 50 * WebProcess/WebPage/WebPage.h: 51 * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm: 52 (WebKit::TiledCoreAnimationDrawingArea::addCommitHandlers): 53 54 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@286905 268f45cc-cd09-0410-ab3c-d52691b4dbfc 55 56 2021-12-10 Simon Fraser <simon.fraser@apple.com> 57 58 Scrolling can drop frames when CoreAnimation commits take a long time 59 https://bugs.webkit.org/show_bug.cgi?id=234160 60 <rdar://86235740> 61 62 Reviewed by Tim Horton. 63 64 In r261985 I added a mechanism that has the scrolling thread wait for the main thread to 65 finish a rendering update, and, if the main thread fails to complete in time, then the 66 scrolling thread commits. This allows for scrolling synchronization when the main thread is 67 responsive, but smooth scrolling when the main thread is busy. 68 69 However, r261985 only waits for WebKit work to finish; what we really care about is whether 70 the main thread completes its CA commit in time (because that determines whether the scroll 71 shows on the screen). 72 73 So plumb through pre-/post-commit hooks from TiledCoreAnimationDrawingArea, which already 74 had them for inspector instrumentation. Then have ThreadedScrollingTree notify 75 m_stateCondition in didCompletePlatformRenderingUpdate(), instead of 76 didCompleteRenderingUpdate(). 77 78 Also, now we can call the inspector hooks from Page, rather than out in TiledCoreAnimationDrawingArea. 79 80 * WebProcess/WebPage/WebPage.cpp: 81 (WebKit::WebPage::willStartPlatformRenderingUpdate): 82 (WebKit::WebPage::didCompletePlatformRenderingUpdate): 83 * WebProcess/WebPage/WebPage.h: 84 * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm: 85 (WebKit::TiledCoreAnimationDrawingArea::addCommitHandlers): 86 1 87 2021-12-13 Alan Coon <alancoon@apple.com> 2 88 -
branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r286683 r286977 4245 4245 } 4246 4246 4247 void WebPage::willStartPlatformRenderingUpdate() 4248 { 4249 if (m_isClosed) 4250 return; 4251 m_page->willStartPlatformRenderingUpdate(); 4252 } 4253 4254 void WebPage::didCompletePlatformRenderingUpdate() 4255 { 4256 if (m_isClosed) 4257 return; 4258 m_page->didCompletePlatformRenderingUpdate(); 4259 } 4260 4247 4261 void WebPage::releaseMemory(Critical) 4248 4262 { -
branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/WebPage.h
r286683 r286977 660 660 void didUpdateRendering(); 661 661 662 // A "platform rendering update" here describes the work done by the system graphics framework before work is submitted to the system compositor. 663 // On macOS, this is a CoreAnimation commit. 664 void willStartPlatformRenderingUpdate(); 665 void didCompletePlatformRenderingUpdate(); 666 662 667 #if PLATFORM(MAC) 663 668 void setTopOverhangImage(WebImage*); -
branches/safari-612-branch/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm
r286976 r286977 423 423 424 424 [CATransaction addCommitHandler:[retainedPage = makeRefPtr(&m_webPage)] { 425 if (Page* corePage = retainedPage->corePage()) { 426 if (Frame* coreFrame = retainedPage->mainFrame()) 427 corePage->inspectorController().willComposite(*coreFrame); 428 } 425 retainedPage->willStartPlatformRenderingUpdate(); 429 426 } forPhase:kCATransactionPhasePreLayout]; 430 427 431 428 [CATransaction addCommitHandler:[retainedPage = makeRefPtr(&m_webPage)] { 432 if (Page* corePage = retainedPage->corePage()) {433 if (Frame* coreFrame = retainedPage->mainFrame())434 corePage->inspectorController().didComposite(*coreFrame);435 }436 429 if (auto drawingArea = static_cast<TiledCoreAnimationDrawingArea*>(retainedPage->drawingArea())) 437 430 drawingArea->sendPendingNewlyReachedPaintingMilestones(); 431 438 432 retainedPage->setFirstFlushAfterCommit(false); 433 retainedPage->didCompletePlatformRenderingUpdate(); 439 434 } forPhase:kCATransactionPhasePostCommit]; 440 435
Note:
See TracChangeset
for help on using the changeset viewer.