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

Changeset 279500 in webkit


Ignore:
Timestamp:
Jul 2, 2021, 12:09:52 AM (5 years ago)
Author:
youenn@apple.com
Message:

Make LocalSampleBufferDisplayLayer::requestNotificationWhenReadyForVideoData hop to main thread before hopping to processing thread
​https://bugs.webkit.org/show_bug.cgi?id=227444
<rdar://79413368>

Reviewed by Chris Dumez.

It is safer to hop to main thread in requestNotificationWhenReadyForVideoData callback so that we can check weakThis safely.
When in main thread, hop to processing thread if LocalSampleBufferDisplayLayer is alive.

  • platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.mm:

(WebCore::LocalSampleBufferDisplayLayer::~LocalSampleBufferDisplayLayer):
(WebCore::LocalSampleBufferDisplayLayer::requestNotificationWhenReadyForVideoData):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r279498 r279500  
     12021-07-02  Youenn Fablet  <youenn@apple.com>
     2
     3        Make LocalSampleBufferDisplayLayer::requestNotificationWhenReadyForVideoData hop to main thread before hopping to processing thread
     4        https://bugs.webkit.org/show_bug.cgi?id=227444
     5        <rdar://79413368>
     6
     7        Reviewed by Chris Dumez.
     8
     9        It is safer to hop to main thread in requestNotificationWhenReadyForVideoData callback so that we can check weakThis safely.
     10        When in main thread, hop to processing thread if LocalSampleBufferDisplayLayer is alive.
     11
     12        * platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.mm:
     13        (WebCore::LocalSampleBufferDisplayLayer::~LocalSampleBufferDisplayLayer):
     14        (WebCore::LocalSampleBufferDisplayLayer::requestNotificationWhenReadyForVideoData):
     15
    1162021-06-30  Darin Adler  <darin@apple.com>
    217
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.mm

    r276497 r279500  
    157157#endif
    158158{
     159    ASSERT(isMainThread());
    159160}
    160161
    … …  
    187188LocalSampleBufferDisplayLayer::~LocalSampleBufferDisplayLayer()
    188189{
     190    ASSERT(isMainThread());
     191
    189192    m_processingQueue->dispatchSync([] { });
    190193
    … …  
    392395{
    393396    auto weakThis = makeWeakPtr(*this);
    394     [m_sampleBufferDisplayLayer requestMediaDataWhenReadyOnQueue:m_processingQueue->dispatchQueue() usingBlock:^{
     397    [m_sampleBufferDisplayLayer requestMediaDataWhenReadyOnQueue:dispatch_get_main_queue() usingBlock:^{
    395398        if (!weakThis)
    396399            return;
    397400
    398         [m_sampleBufferDisplayLayer stopRequestingMediaData];
    399 
    400         while (!m_pendingVideoSampleQueue.isEmpty()) {
    401             if (![m_sampleBufferDisplayLayer isReadyForMoreMediaData]) {
    402                 requestNotificationWhenReadyForVideoData();
    403                 return;
     401        m_processingQueue->dispatch([this] {
     402            [m_sampleBufferDisplayLayer stopRequestingMediaData];
     403
     404            while (!m_pendingVideoSampleQueue.isEmpty()) {
     405                if (![m_sampleBufferDisplayLayer isReadyForMoreMediaData]) {
     406                    requestNotificationWhenReadyForVideoData();
     407                    return;
     408                }
     409                auto sample = m_pendingVideoSampleQueue.takeFirst();
     410                enqueueSampleBuffer(sample);
    404411            }
    405             auto sample = m_pendingVideoSampleQueue.takeFirst();
    406             enqueueSampleBuffer(sample);
    407         }
     412        });
    408413    }];
    409414}
Note: See TracChangeset for help on using the changeset viewer.