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

Changeset 284644 in webkit


Ignore:
Timestamp:
Oct 21, 2021, 2:33:01 PM (5 years ago)
Author:
Simon Fraser
Message:

Rare crash under DisplayLink::displayLinkCallback()
https://bugs.webkit.org/show_bug.cgi?id=232101
<rdar://84153991>

Reviewed by Tim Horton.

The crash was a divide by zero under m_currentUpdate.nextUpdate(), indicating that
m_currentUpdate.updatesPerSecond was zero. Previous assumptions that this was caused
by weird display configs were wrong. The actual issue is a race condition where
the callback can fire while we're still inside CVDisplayLinkStart(), or at least
before we've updated m_currentUpdate.

The fix is to initialize m_currentUpdate before we call CVDisplayLinkStart().

  • UIProcess/mac/DisplayLink.cpp:

(WebKit::DisplayLink::addObserver):

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r284641 r284644  
     12021-10-21  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Rare crash under DisplayLink::displayLinkCallback()
     4        https://bugs.webkit.org/show_bug.cgi?id=232101
     5        <rdar://84153991>
     6
     7        Reviewed by Tim Horton.
     8
     9        The crash was a divide by zero under m_currentUpdate.nextUpdate(), indicating that
     10        m_currentUpdate.updatesPerSecond was zero. Previous assumptions that this was caused
     11        by weird display configs were wrong. The actual issue is a race condition where
     12        the callback can fire while we're still inside CVDisplayLinkStart(), or at least
     13        before we've updated m_currentUpdate.
     14
     15        The fix is to initialize m_currentUpdate before we call CVDisplayLinkStart().
     16
     17        * UIProcess/mac/DisplayLink.cpp:
     18        (WebKit::DisplayLink::addObserver):
     19
    1202021-10-21  Per Arne Vollan <pvollan@apple.com>
    221
  • trunk/Source/WebKit/UIProcess/mac/DisplayLink.cpp

    r283209 r284644  
    102102    if (!CVDisplayLinkIsRunning(m_displayLink)) {
    103103        LOG_WITH_STREAM(DisplayLink, stream << "[UI ] DisplayLink for display " << m_displayID << " starting CVDisplayLink with fps " << m_displayNominalFramesPerSecond);
     104
     105        m_currentUpdate = { 0, m_displayNominalFramesPerSecond };
     106
    104107        CVReturn error = CVDisplayLinkStart(m_displayLink);
    105108        if (error)
    106109            RELEASE_LOG_FAULT(DisplayLink, "DisplayLink: Could not start the display link: %d", error);
    107 
    108         if (!m_displayNominalFramesPerSecond) {
    109             RELEASE_LOG_FAULT(DisplayLink, "DisplayLink: displayNominalFramesPerSecond is 0, using %d", WebCore::FullSpeedFramesPerSecond);
    110             m_displayNominalFramesPerSecond = WebCore::FullSpeedFramesPerSecond;
    111         };
    112 
    113         m_currentUpdate = { 0, m_displayNominalFramesPerSecond };
    114110    }
    115111}
Note: See TracChangeset for help on using the changeset viewer.