Changeset 287079 in webkit
- Timestamp:
- Dec 15, 2021, 9:46:07 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 added
- 14 edited
-
ChangeLog (modified) (1 diff)
-
SourcesCocoa.txt (modified) (1 diff)
-
WebCore.xcodeproj/project.pbxproj (modified) (3 diffs)
-
page/scrolling/ScrollingTree.h (modified) (1 diff)
-
page/scrolling/ThreadedScrollingTree.h (modified) (1 diff)
-
page/scrolling/mac/ScrollingCoordinatorMac.h (modified) (1 diff)
-
page/scrolling/mac/ScrollingCoordinatorMac.mm (modified) (2 diffs)
-
page/scrolling/mac/ScrollingTreeMac.h (modified) (1 diff)
-
page/scrolling/mac/ScrollingTreeMac.mm (modified) (3 diffs)
-
platform/graphics/ca/GraphicsLayerCA.cpp (modified) (2 diffs)
-
platform/graphics/ca/PlatformCALayer.cpp (modified) (1 diff)
-
platform/graphics/ca/PlatformCALayer.h (modified) (1 diff)
-
platform/graphics/ca/cocoa/PlatformCALayerCocoa.h (modified) (1 diff)
-
platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm (modified) (3 diffs)
-
platform/graphics/ca/cocoa/PlatformCALayerContentsDelayedReleaser.h (added)
-
platform/graphics/ca/cocoa/PlatformCALayerContentsDelayedReleaser.mm (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r287077 r287079 1 2021-12-15 Simon Fraser <simon.fraser@apple.com> 2 3 Twitter scroll stutter: ensure that CA backing store is always deallocated on the main thread 4 https://bugs.webkit.org/show_bug.cgi?id=234328 5 <rdar://85892959> 6 7 Reviewed by Tim Horton. 8 9 When scrolling pages like Twitter and Facebook we observed CoreAnimation commits on the 10 scrolling thread taking longer than they should because CABackingStore objects were being 11 released in those transactions. 12 13 Work around this issue by extending the lifetime of CABackingStore objects if we detect that 14 they might be entrained into a scrolling tree commit, by virtue of having overlapping main 15 thread and scrolling thread commits. 16 17 The logic is contained in PlatformCALayerContentsDelayedReleaser, which puts layer contents 18 into a retaining vector when they are being cleared on the layer. They are released at the 19 end of a main thread commit; if we detected overlapping commits, then we release on a 20 dispatch to extend the lifetime slightly. 21 22 The remaining changes are plumbing to get commit willBegin/didEnd messages to PlatformCALayerContentsDelayedReleaser 23 for main and scrolling threads. 24 25 * SourcesCocoa.txt: 26 * WebCore.xcodeproj/project.pbxproj: 27 * page/scrolling/ScrollingTree.h: 28 * page/scrolling/ThreadedScrollingTree.h: 29 * page/scrolling/mac/ScrollingCoordinatorMac.h: 30 * page/scrolling/mac/ScrollingCoordinatorMac.mm: 31 (WebCore::ScrollingCoordinatorMac::willStartPlatformRenderingUpdate): 32 (WebCore::ScrollingCoordinatorMac::didCompletePlatformRenderingUpdate): 33 * page/scrolling/mac/ScrollingTreeMac.h: 34 * page/scrolling/mac/ScrollingTreeMac.mm: 35 (ScrollingTreeMac::applyLayerPositionsInternal): 36 (ScrollingTreeMac::registerForPlatformRenderingUpdateCallback): 37 * platform/graphics/ca/GraphicsLayerCA.cpp: 38 (WebCore::GraphicsLayerCA::updateContentsVisibility): 39 (WebCore::GraphicsLayerCA::updateDrawsContent): 40 * platform/graphics/ca/PlatformCALayer.cpp: 41 (WebCore::PlatformCALayer::clearContents): 42 * platform/graphics/ca/PlatformCALayer.h: 43 * platform/graphics/ca/cocoa/PlatformCALayerCocoa.h: 44 * platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm: 45 (WebCore::PlatformCALayerCocoa::setBackingStoreAttached): 46 (WebCore::PlatformCALayerCocoa::clearContents): 47 * platform/graphics/ca/cocoa/PlatformCALayerContentsDelayedReleaser.h: Added. 48 (WebCore::PlatformCALayerContentsDelayedReleaser::WTF_GUARDED_BY_LOCK): 49 * platform/graphics/ca/cocoa/PlatformCALayerContentsDelayedReleaser.mm: Added. 50 (WebCore::PlatformCALayerContentsDelayedReleaser::singleton): 51 (WebCore::PlatformCALayerContentsDelayedReleaser::takeLayerContents): 52 (WebCore::PlatformCALayerContentsDelayedReleaser::mainThreadCommitWillStart): 53 (WebCore::PlatformCALayerContentsDelayedReleaser::mainThreadCommitDidEnd): 54 (WebCore::PlatformCALayerContentsDelayedReleaser::scrollingThreadCommitWillStart): 55 (WebCore::PlatformCALayerContentsDelayedReleaser::scrollingThreadCommitDidEnd): 56 (WebCore::PlatformCALayerContentsDelayedReleaser::updateSawOverlappingCommit): 57 (WebCore::PlatformCALayerContentsDelayedReleaser::clearRetainedContents): 58 1 59 2021-12-15 Chris Dumez <cdumez@apple.com> 2 60 -
trunk/Source/WebCore/SourcesCocoa.txt
r287015 r287079 338 338 platform/graphics/ca/cocoa/PlatformCAFiltersCocoa.mm 339 339 platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm 340 platform/graphics/ca/cocoa/PlatformCALayerContentsDelayedReleaser.mm 340 341 platform/graphics/ca/cocoa/WebSystemBackdropLayer.mm 341 342 platform/graphics/ca/cocoa/WebTiledBackingLayer.mm -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r287015 r287079 6395 6395 0FA24D77162DF91900A3F4C0 /* GraphicsLayerUpdater.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GraphicsLayerUpdater.cpp; sourceTree = "<group>"; }; 6396 6396 0FA24D78162DF91900A3F4C0 /* GraphicsLayerUpdater.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsLayerUpdater.h; sourceTree = "<group>"; }; 6397 0FA2B233276817540020C7C1 /* PlatformCALayerContentsDelayedReleaser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PlatformCALayerContentsDelayedReleaser.h; sourceTree = "<group>"; }; 6398 0FA2B235276817550020C7C1 /* PlatformCALayerContentsDelayedReleaser.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = PlatformCALayerContentsDelayedReleaser.mm; sourceTree = "<group>"; }; 6397 6399 0FA61B0C26F43212001AADB6 /* ScrollAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScrollAnimation.h; sourceTree = "<group>"; }; 6398 6400 0FB0689425243B90001E8E75 /* DisplayTextBox.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DisplayTextBox.cpp; sourceTree = "<group>"; }; … … 21672 21674 2D70BA1218074DDF0001908A /* PlatformCALayerCocoa.h */, 21673 21675 4958782012A57DDF007238AC /* PlatformCALayerCocoa.mm */, 21676 0FA2B233276817540020C7C1 /* PlatformCALayerContentsDelayedReleaser.h */, 21677 0FA2B235276817550020C7C1 /* PlatformCALayerContentsDelayedReleaser.mm */, 21674 21678 31DEA4541B39F4D900F77178 /* WebSystemBackdropLayer.h */, 21675 21679 31DEA4531B39F4D900F77178 /* WebSystemBackdropLayer.mm */, … … 33122 33126 buildActionMask = 2147483647; 33123 33127 files = ( 33124 7B582DD82716F55B004B92D0 /* (null) in Headers */,33125 33128 7CD0E2B81F80A4820016A4CE /* AbortController.h in Headers */, 33126 33129 7CD0E2BF1F80A56E0016A4CE /* AbortSignal.h in Headers */, -
trunk/Source/WebCore/page/scrolling/ScrollingTree.h
r286351 r287079 246 246 std::optional<FramesPerSecond> nominalFramesPerSecond(); 247 247 248 void applyLayerPositionsInternal() WTF_REQUIRES_LOCK(m_treeLock);248 WEBCORE_EXPORT virtual void applyLayerPositionsInternal() WTF_REQUIRES_LOCK(m_treeLock); 249 249 void removeAllNodes() WTF_REQUIRES_LOCK(m_treeLock); 250 250 -
trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.h
r286932 r287079 109 109 110 110 void storeScrollPositionsAtLastDisplayRefresh() WTF_REQUIRES_LOCK(m_treeLock); 111 111 112 112 void serviceScrollAnimations(MonotonicTime) WTF_REQUIRES_LOCK(m_treeLock); 113 113 -
trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.h
r286905 r287079 54 54 void didCompleteRenderingUpdate() final; 55 55 56 void willStartPlatformRenderingUpdate() final; 56 57 void didCompletePlatformRenderingUpdate() final; 57 58 -
trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm
r286905 r287079 34 34 #import "Logging.h" 35 35 #import "Page.h" 36 #import "PlatformCALayerContentsDelayedReleaser.h" 36 37 #import "PlatformWheelEvent.h" 37 38 #import "Region.h" … … 143 144 } 144 145 146 void ScrollingCoordinatorMac::willStartPlatformRenderingUpdate() 147 { 148 PlatformCALayerContentsDelayedReleaser::singleton().mainThreadCommitWillStart(); 149 } 150 145 151 void ScrollingCoordinatorMac::didCompletePlatformRenderingUpdate() 146 152 { 147 153 downcast<ThreadedScrollingTree>(scrollingTree())->didCompletePlatformRenderingUpdate(); 154 PlatformCALayerContentsDelayedReleaser::singleton().mainThreadCommitDidEnd(); 148 155 } 149 156 -
trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeMac.h
r277943 r287079 56 56 void removeWheelEventTestCompletionDeferralForReason(WheelEventTestMonitor::ScrollableAreaIdentifier, WheelEventTestMonitor::DeferReason) final; 57 57 58 void registerForPlatformRenderingUpdateCallback(); 59 void applyLayerPositionsInternal() final WTF_REQUIRES_LOCK(m_treeLock); 60 58 61 void lockLayersForHitTesting() final WTF_ACQUIRES_LOCK(m_layerHitTestMutex); 59 62 void unlockLayersForHitTesting() final WTF_RELEASES_LOCK(m_layerHitTestMutex); -
trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeMac.mm
r284920 r287079 29 29 #import "Logging.h" 30 30 #import "PlatformCALayer.h" 31 #import "PlatformCALayerContentsDelayedReleaser.h" 31 32 #import "ScrollingTreeFixedNode.h" 32 33 #import "ScrollingTreeFrameHostingNode.h" … … 39 40 #import "WebLayer.h" 40 41 #import "WheelEventTestMonitor.h" 42 #import <pal/spi/cocoa/QuartzCoreSPI.h> 41 43 #import <wtf/text/TextStream.h> 42 44 … … 241 243 } 242 244 245 void ScrollingTreeMac::applyLayerPositionsInternal() 246 { 247 if (ScrollingThread::isCurrentThread()) 248 registerForPlatformRenderingUpdateCallback(); 249 250 ThreadedScrollingTree::applyLayerPositionsInternal(); 251 } 252 253 void ScrollingTreeMac::registerForPlatformRenderingUpdateCallback() 254 { 255 [CATransaction addCommitHandler:[] { 256 PlatformCALayerContentsDelayedReleaser::singleton().scrollingThreadCommitWillStart(); 257 } forPhase:kCATransactionPhasePreLayout]; 258 259 [CATransaction addCommitHandler:[] { 260 PlatformCALayerContentsDelayedReleaser::singleton().scrollingThreadCommitDidEnd(); 261 } forPhase:kCATransactionPhasePostCommit]; 262 } 263 243 264 void ScrollingTreeMac::setWheelEventTestMonitor(RefPtr<WheelEventTestMonitor>&& monitor) 244 265 { -
trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
r286943 r287079 2352 2352 m_backdropLayer->setHidden(false); 2353 2353 } else { 2354 m_layer-> setContents(nullptr);2354 m_layer->clearContents(); 2355 2355 2356 2356 if (m_layerClones) { … … 2675 2675 m_hasEverPainted = false; 2676 2676 } else { 2677 m_layer-> setContents(nullptr);2677 m_layer->clearContents(); 2678 2678 if (m_layerClones) { 2679 2679 for (auto& layer : m_layerClones->primaryLayerClones.values()) -
trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.cpp
r284453 r287079 200 200 } 201 201 202 void PlatformCALayer::clearContents() 203 { 204 setContents(nullptr); 205 } 206 202 207 void PlatformCALayer::dumpAdditionalProperties(TextStream&, OptionSet<PlatformLayerTreeAsTextFlags>) 203 208 { -
trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h
r286943 r287079 200 200 virtual CFTypeRef contents() const = 0; 201 201 virtual void setContents(CFTypeRef) = 0; 202 virtual void clearContents(); 202 203 203 204 #if HAVE(IOSURFACE) -
trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.h
r286943 r287079 121 121 CFTypeRef contents() const override; 122 122 void setContents(CFTypeRef) override; 123 void clearContents() override; 123 124 #if HAVE(IOSURFACE) 124 125 void setContents(const WebCore::IOSurface&) override; -
trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm
r286943 r287079 36 36 #import "PlatformCAAnimationCocoa.h" 37 37 #import "PlatformCAFilters.h" 38 #import "PlatformCALayerContentsDelayedReleaser.h" 38 39 #import "ScrollbarThemeMac.h" 39 40 #import "TileController.h" … … 679 680 setNeedsDisplay(); 680 681 else 681 setContents(nullptr);682 clearContents(); 682 683 } 683 684 … … 783 784 { 784 785 return (__bridge CFTypeRef)[m_layer contents]; 786 } 787 788 void PlatformCALayerCocoa::clearContents() 789 { 790 #if PLATFORM(MAC) 791 PlatformCALayerContentsDelayedReleaser::singleton().takeLayerContents(*this); 792 #else 793 setContents(nullptr); 794 #endif 785 795 } 786 796
Note:
See TracChangeset
for help on using the changeset viewer.