Changeset 243607 in webkit
- Timestamp:
- Mar 28, 2019, 9:44:27 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/scrollingcoordinator/mac/fixed-scrolled-body-expected.html (added)
-
LayoutTests/scrollingcoordinator/mac/fixed-scrolled-body.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/page/scrolling/ScrollingTree.cpp (modified) (3 diffs)
-
Source/WebCore/page/scrolling/ScrollingTree.h (modified) (2 diffs)
-
Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp (modified) (2 diffs)
-
Source/WebCore/page/scrolling/ThreadedScrollingTree.h (modified) (3 diffs)
-
Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r243605 r243607 1 2019-03-28 Simon Fraser <simon.fraser@apple.com> 2 3 [macOS WK2] Overlays on instagram.com are shifted if you click on a photo after scrolling 4 https://bugs.webkit.org/show_bug.cgi?id=196330 5 rdar://problem/49100304 6 7 Reviewed by Antti Koivisto. 8 9 * scrollingcoordinator/mac/fixed-scrolled-body-expected.html: Added. 10 * scrollingcoordinator/mac/fixed-scrolled-body.html: Added. 11 1 12 2019-03-28 Zalan Bujtas <zalan@apple.com> 2 13 -
trunk/Source/WebCore/ChangeLog
r243605 r243607 1 2019-03-28 Simon Fraser <simon.fraser@apple.com> 2 3 [macOS WK2] Overlays on instagram.com are shifted if you click on a photo after scrolling 4 https://bugs.webkit.org/show_bug.cgi?id=196330 5 rdar://problem/49100304 6 7 Reviewed by Antti Koivisto. 8 9 When we call ScrollingTree::applyLayerPositions() on the main thread after a flush, 10 we need to ensure that the most recent version of the scrolling tree has been committed, 11 because it has to have state (like requested scroll position and layout viewport rect) 12 that match the layer flush. 13 14 To fix this we have to have the main thread wait for the commit to complete, so 15 ThreadedScrollingTree keeps track of a pending commit count, and uses a condition 16 variable to allow the main thread to safely wait for it to reach zero. 17 18 Tracing shows that this works as expected, and the main thread is never blocked for 19 more than a few tens of microseconds. 20 21 Also lock the tree mutex in ScrollingTree::handleWheelEvent(), since we enter the 22 scrolling tree here and we don't want that racing with applyLayerPositions() on the 23 main thread. 24 25 Test: scrollingcoordinator/mac/fixed-scrolled-body.html 26 27 * page/scrolling/ScrollingTree.cpp: 28 (WebCore::ScrollingTree::handleWheelEvent): 29 (WebCore::ScrollingTree::applyLayerPositions): 30 * page/scrolling/ScrollingTree.h: 31 * page/scrolling/ThreadedScrollingTree.cpp: 32 (WebCore::ThreadedScrollingTree::commitTreeState): 33 (WebCore::ThreadedScrollingTree::incrementPendingCommitCount): 34 (WebCore::ThreadedScrollingTree::decrementPendingCommitCount): 35 (WebCore::ThreadedScrollingTree::waitForPendingCommits): 36 (WebCore::ThreadedScrollingTree::applyLayerPositions): 37 * page/scrolling/ThreadedScrollingTree.h: 38 * page/scrolling/mac/ScrollingCoordinatorMac.mm: 39 (WebCore::ScrollingCoordinatorMac::commitTreeState): 40 1 41 2019-03-28 Zalan Bujtas <zalan@apple.com> 2 42 -
trunk/Source/WebCore/page/scrolling/ScrollingTree.cpp
r243380 r243607 94 94 LOG_WITH_STREAM(Scrolling, stream << "ScrollingTree " << this << " handleWheelEvent (async scrolling enabled: " << asyncFrameOrOverflowScrollingEnabled() << ")"); 95 95 96 LockHolder locker(m_treeMutex); 97 96 98 if (!asyncFrameOrOverflowScrollingEnabled()) { 97 99 if (m_rootNode) … … 107 109 } 108 110 109 LockHolder locker(m_treeMutex);110 111 if (m_rootNode) { 111 112 auto& frameScrollingNode = downcast<ScrollingTreeFrameScrollingNode>(*m_rootNode); … … 261 262 } 262 263 263 // Called from the main thread.264 264 void ScrollingTree::applyLayerPositions() 265 265 { 266 ASSERT(isMainThread()); 266 267 LockHolder locker(m_treeMutex); 267 268 -
trunk/Source/WebCore/page/scrolling/ScrollingTree.h
r243380 r243607 70 70 WEBCORE_EXPORT virtual void commitTreeState(std::unique_ptr<ScrollingStateTree>); 71 71 72 WEBCORE_EXPORT v oid applyLayerPositions();72 WEBCORE_EXPORT virtual void applyLayerPositions(); 73 73 74 74 virtual Ref<ScrollingTreeNode> createScrollingTreeNode(ScrollingNodeType, ScrollingNodeID) = 0; … … 154 154 155 155 WEBCORE_EXPORT String scrollingTreeAsText(ScrollingStateTreeAsTextBehavior = ScrollingStateTreeAsTextBehaviorNormal); 156 156 157 157 protected: 158 158 void setMainFrameScrollPosition(FloatPoint); -
trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp
r242132 r243607 90 90 ASSERT(ScrollingThread::isCurrentThread()); 91 91 ScrollingTree::commitTreeState(WTFMove(scrollingStateTree)); 92 93 decrementPendingCommitCount(); 92 94 } 93 95 … … 125 127 } 126 128 129 void ThreadedScrollingTree::incrementPendingCommitCount() 130 { 131 LockHolder commitLocker(m_pendingCommitCountMutex); 132 ++m_pendingCommitCount; 133 } 134 135 void ThreadedScrollingTree::decrementPendingCommitCount() 136 { 137 LockHolder commitLocker(m_pendingCommitCountMutex); 138 ASSERT(m_pendingCommitCount > 0); 139 if (!--m_pendingCommitCount) 140 m_commitCondition.notifyOne(); 141 } 142 143 void ThreadedScrollingTree::waitForPendingCommits() 144 { 145 ASSERT(isMainThread()); 146 147 LockHolder commitLocker(m_pendingCommitCountMutex); 148 while (m_pendingCommitCount) 149 m_commitCondition.wait(m_pendingCommitCountMutex); 150 } 151 152 void ThreadedScrollingTree::applyLayerPositions() 153 { 154 waitForPendingCommits(); 155 ScrollingTree::applyLayerPositions(); 156 } 157 127 158 #if PLATFORM(COCOA) 128 159 void ThreadedScrollingTree::currentSnapPointIndicesDidChange(ScrollingNodeID nodeID, unsigned horizontal, unsigned vertical) -
trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.h
r242132 r243607 30 30 #include "ScrollingStateTree.h" 31 31 #include "ScrollingTree.h" 32 #include <wtf/Condition.h> 32 33 #include <wtf/RefPtr.h> 33 34 … … 55 56 void invalidate() override; 56 57 58 void incrementPendingCommitCount(); 59 void decrementPendingCommitCount(); 60 57 61 protected: 58 62 explicit ThreadedScrollingTree(AsyncScrollingCoordinator&); … … 75 79 private: 76 80 bool isThreadedScrollingTree() const override { return true; } 81 void applyLayerPositions() override; 77 82 78 83 RefPtr<AsyncScrollingCoordinator> m_scrollingCoordinator; 84 85 void waitForPendingCommits(); 86 87 Lock m_pendingCommitCountMutex; 88 unsigned m_pendingCommitCount { 0 }; 89 Condition m_commitCondition; 79 90 }; 80 91 -
trunk/Source/WebCore/page/scrolling/mac/ScrollingCoordinatorMac.mm
r240787 r243607 123 123 ScrollingStateTree* unprotectedTreeState = scrollingStateTree()->commit(LayerRepresentation::PlatformLayerRepresentation).release(); 124 124 125 threadedScrollingTree->incrementPendingCommitCount(); 126 125 127 ScrollingThread::dispatch([threadedScrollingTree, unprotectedTreeState] { 126 128 std::unique_ptr<ScrollingStateTree> treeState(unprotectedTreeState);
Note:
See TracChangeset
for help on using the changeset viewer.