⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 290109 in webkit


Ignore:
Timestamp:
Feb 17, 2022, 7:55:27 PM (5 years ago)
Author:
Simon Fraser
Message:

Crash under ScrollingCoordinatorMac::hasNodeWithAnimatedScrollChanged()
​https://bugs.webkit.org/show_bug.cgi?id=236810
<rdar://89072235>

Reviewed by Dean Jackson.

Crash data suggests that r288933 didn't fix the crash entirely.

Although the code paths I can find appear to hold the lock, there may be an
opportunity for m_scrollingCoordinator to get nulled out after we null-check it
but before the copy for the main thread dispatch.

So make a RefPtr on the stack, null-check it, and then move it into the callback.

  • page/scrolling/ThreadedScrollingTree.cpp:

(WebCore::ThreadedScrollingTree::reportSynchronousScrollingReasonsChanged):
(WebCore::ThreadedScrollingTree::reportExposedUnfilledArea):
(WebCore::ThreadedScrollingTree::currentSnapPointIndicesDidChange):
(WebCore::ThreadedScrollingTree::handleWheelEventPhase):
(WebCore::ThreadedScrollingTree::setActiveScrollSnapIndices):
(WebCore::ThreadedScrollingTree::hasNodeWithAnimatedScrollChanged):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r290108 r290109  
     12022-02-17  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Crash under ScrollingCoordinatorMac::hasNodeWithAnimatedScrollChanged()
     4        https://bugs.webkit.org/show_bug.cgi?id=236810
     5        <rdar://89072235>
     6
     7        Reviewed by Dean Jackson.
     8
     9        Crash data suggests that r288933 didn't fix the crash entirely.
     10
     11        Although the code paths I can find appear to hold the lock, there may be an
     12        opportunity for m_scrollingCoordinator to get nulled out after we null-check it
     13        but before the copy for the main thread dispatch.
     14
     15        So make a RefPtr on the stack, null-check it, and then move it into the callback.
     16
     17        * page/scrolling/ThreadedScrollingTree.cpp:
     18        (WebCore::ThreadedScrollingTree::reportSynchronousScrollingReasonsChanged):
     19        (WebCore::ThreadedScrollingTree::reportExposedUnfilledArea):
     20        (WebCore::ThreadedScrollingTree::currentSnapPointIndicesDidChange):
     21        (WebCore::ThreadedScrollingTree::handleWheelEventPhase):
     22        (WebCore::ThreadedScrollingTree::setActiveScrollSnapIndices):
     23        (WebCore::ThreadedScrollingTree::hasNodeWithAnimatedScrollChanged):
     24
    1252022-02-17  Chris Dumez  <cdumez@apple.com>
    226
  • trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp

    r288933 r290109  
    284284void ThreadedScrollingTree::reportSynchronousScrollingReasonsChanged(MonotonicTime timestamp, OptionSet<SynchronousScrollingReason> reasons)
    285285{
    286     RunLoop::main().dispatch([scrollingCoordinator = m_scrollingCoordinator, timestamp, reasons] {
     286    auto scrollingCoordinator = m_scrollingCoordinator;
     287    if (!scrollingCoordinator)
     288        return;
     289
     290    RunLoop::main().dispatch([scrollingCoordinator = WTFMove(scrollingCoordinator), timestamp, reasons] {
    287291        scrollingCoordinator->reportSynchronousScrollingReasonsChanged(timestamp, reasons);
    288292    });
    … …  
    291295void ThreadedScrollingTree::reportExposedUnfilledArea(MonotonicTime timestamp, unsigned unfilledArea)
    292296{
    293     RunLoop::main().dispatch([scrollingCoordinator = m_scrollingCoordinator, timestamp, unfilledArea] {
     297    auto scrollingCoordinator = m_scrollingCoordinator;
     298    if (!scrollingCoordinator)
     299        return;
     300    RunLoop::main().dispatch([scrollingCoordinator = WTFMove(scrollingCoordinator), timestamp, unfilledArea] {
    294301        scrollingCoordinator->reportExposedUnfilledArea(timestamp, unfilledArea);
    295302    });
    … …  
    299306void ThreadedScrollingTree::currentSnapPointIndicesDidChange(ScrollingNodeID nodeID, std::optional<unsigned> horizontal, std::optional<unsigned> vertical)
    300307{
    301     if (!m_scrollingCoordinator)
    302         return;
    303 
    304     RunLoop::main().dispatch([scrollingCoordinator = m_scrollingCoordinator, nodeID, horizontal, vertical] {
     308    auto scrollingCoordinator = m_scrollingCoordinator;
     309    if (!scrollingCoordinator)
     310        return;
     311
     312    RunLoop::main().dispatch([scrollingCoordinator = WTFMove(scrollingCoordinator), nodeID, horizontal, vertical] {
    305313        scrollingCoordinator->setActiveScrollSnapIndices(nodeID, horizontal, vertical);
    306314    });
    … …  
    311319void ThreadedScrollingTree::handleWheelEventPhase(ScrollingNodeID nodeID, PlatformWheelEventPhase phase)
    312320{
    313     if (!m_scrollingCoordinator)
    314         return;
    315 
    316     RunLoop::main().dispatch([scrollingCoordinator = m_scrollingCoordinator, nodeID, phase] {
     321    auto scrollingCoordinator = m_scrollingCoordinator;
     322    if (!scrollingCoordinator)
     323        return;
     324
     325    RunLoop::main().dispatch([scrollingCoordinator = WTFMove(scrollingCoordinator), nodeID, phase] {
    317326        scrollingCoordinator->handleWheelEventPhase(nodeID, phase);
    318327    });
    … …  
    321330void ThreadedScrollingTree::setActiveScrollSnapIndices(ScrollingNodeID nodeID, std::optional<unsigned> horizontalIndex, std::optional<unsigned> verticalIndex)
    322331{
    323     if (!m_scrollingCoordinator)
     332    auto scrollingCoordinator = m_scrollingCoordinator;
     333    if (!scrollingCoordinator)
    324334        return;
    325335   
    326     RunLoop::main().dispatch([scrollingCoordinator = m_scrollingCoordinator, nodeID, horizontalIndex, verticalIndex] {
     336    RunLoop::main().dispatch([scrollingCoordinator = WTFMove(scrollingCoordinator), nodeID, horizontalIndex, verticalIndex] {
    327337        scrollingCoordinator->setActiveScrollSnapIndices(nodeID, horizontalIndex, verticalIndex);
    328338    });
    … …  
    378388void ThreadedScrollingTree::hasNodeWithAnimatedScrollChanged(bool hasNodeWithAnimatedScroll)
    379389{
    380     if (!m_scrollingCoordinator)
    381         return;
    382 
    383     RunLoop::main().dispatch([scrollingCoordinator = m_scrollingCoordinator, hasNodeWithAnimatedScroll] {
     390    auto scrollingCoordinator = m_scrollingCoordinator;
     391    if (!scrollingCoordinator)
     392        return;
     393
     394    RunLoop::main().dispatch([scrollingCoordinator = WTFMove(scrollingCoordinator), hasNodeWithAnimatedScroll] {
    384395        scrollingCoordinator->hasNodeWithAnimatedScrollChanged(hasNodeWithAnimatedScroll);
    385396    });
Note: See TracChangeset for help on using the changeset viewer.