Changeset 247415 in webkit


Ignore:
Timestamp:
Jul 13, 2019 4:07:41 AM (5 years ago)
Author:
Chris Dumez
Message:

Fix non thread-safe usage of makeWeakPtr() in MediaPlayerPrivateAVFoundation
https://bugs.webkit.org/show_bug.cgi?id=199777

Reviewed by Eric Carlson.

The code was calling makeWeakPtr() on a main-thread object, from a background thread.
This is not thread safe. To address the issue, this patches creates the WeakPtr ahead
of time, on the main thread.

  • platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:

(WebCore::MediaPlayerPrivateAVFoundation::MediaPlayerPrivateAVFoundation):
(WebCore::MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification):
(WebCore::MediaPlayerPrivateAVFoundation::dispatchNotification):

  • platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r247407 r247415  
     12019-07-13  Chris Dumez  <cdumez@apple.com>
     2
     3        Fix non thread-safe usage of makeWeakPtr() in MediaPlayerPrivateAVFoundation
     4        https://bugs.webkit.org/show_bug.cgi?id=199777
     5
     6        Reviewed by Eric Carlson.
     7
     8        The code was calling makeWeakPtr() on a main-thread object, from a background thread.
     9        This is not thread safe. To address the issue, this patches creates the WeakPtr ahead
     10        of time, on the main thread.
     11
     12        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:
     13        (WebCore::MediaPlayerPrivateAVFoundation::MediaPlayerPrivateAVFoundation):
     14        (WebCore::MediaPlayerPrivateAVFoundation::scheduleMainThreadNotification):
     15        (WebCore::MediaPlayerPrivateAVFoundation::dispatchNotification):
     16        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
     17
    1182019-07-12  Thibault Saunier  <tsaunier@igalia.com>
    219
  • trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp

    r245510 r247415  
    5656
    5757MediaPlayerPrivateAVFoundation::MediaPlayerPrivateAVFoundation(MediaPlayer* player)
    58     : m_player(player)
     58    : m_weakThis(makeWeakPtr(*this))
     59    , m_player(player)
    5960    , m_queuedNotifications()
    6061    , m_queueMutex()
     
    775776        m_mainThreadCallPending = true;
    776777
    777         callOnMainThread([weakThis = makeWeakPtr(*this)] {
     778        callOnMainThread([weakThis = m_weakThis] {
    778779            if (!weakThis)
    779780                return;
     
    808809       
    809810        if (!m_queuedNotifications.isEmpty() && !m_mainThreadCallPending) {
    810             callOnMainThread([weakThis = makeWeakPtr(*this)] {
     811            callOnMainThread([weakThis = m_weakThis] {
    811812                if (!weakThis)
    812813                    return;
  • trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h

    r240123 r247415  
    328328
    329329private:
     330    WeakPtr<MediaPlayerPrivateAVFoundation> m_weakThis;
    330331    MediaPlayer* m_player;
    331332
Note: See TracChangeset for help on using the changeset viewer.