Changeset 128082 in webkit


Ignore:
Timestamp:
Sep 10, 2012 11:22:51 AM (12 years ago)
Author:
enne@google.com
Message:

[chromium] Fix deadlock between WebMediaPlayerClientImpl dtor and PutCurrentFrame
https://bugs.webkit.org/show_bug.cgi?id=96010

Reviewed by James Robinson.

Source/Platform:

Add some additional clarifying comments.

  • chromium/public/WebVideoFrameProvider.h:

(Client):
(WebVideoFrameProvider):

Source/WebKit/chromium:

The key fix here is that the destructor no longer has a mutex.
The m_compositingMutex was supposedly protecting races between
~WebMediaPlayerClientImpl and setVideoFrameProviderClient. The
former is only called from the main thread and the latter is called
from the compositor thread only when the main thread is blocked (and
it already asserts that this is the case).

In addition, the m_providerMutex in CCVideoLayerImpl prevents the
destruction of WebMediaPlayerClientImpl, thus keeping the frame
acquired via getCurrentFrame alive until putCurrentFrame is called.
These functions are only called by the client, and comments are added
to the interface to better document this.

To prevent a race between load() and getCurrentFrame/putCurrentFrame
(which are called from different threads) a new m_webMediaPlayerMutex
to replace part of what the old m_compositingMutex was doing.

  • src/WebMediaPlayerClientImpl.cpp:

(WebKit::WebMediaPlayerClientImpl::~WebMediaPlayerClientImpl):
(WebKit::WebMediaPlayerClientImpl::load):
(WebKit::WebMediaPlayerClientImpl::loadInternal):
(WebKit::WebMediaPlayerClientImpl::setVideoFrameProviderClient):
(WebKit::WebMediaPlayerClientImpl::getCurrentFrame):
(WebKit::WebMediaPlayerClientImpl::putCurrentFrame):

  • src/WebMediaPlayerClientImpl.h:

(WebMediaPlayerClientImpl):

Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/Platform/ChangeLog

    r128064 r128082  
     12012-09-10  Adrienne Walker  <enne@google.com>
     2
     3        [chromium] Fix deadlock between WebMediaPlayerClientImpl dtor and PutCurrentFrame
     4        https://bugs.webkit.org/show_bug.cgi?id=96010
     5
     6        Reviewed by James Robinson.
     7
     8        Add some additional clarifying comments.
     9
     10        * chromium/public/WebVideoFrameProvider.h:
     11        (Client):
     12        (WebVideoFrameProvider):
     13
    1142012-09-10  Tommy Widenflycht  <tommyw@google.com>
    215
  • trunk/Source/Platform/chromium/public/WebVideoFrameProvider.h

    r114335 r128082  
    4747    public:
    4848        // Provider will call this method to tell the client to stop using it.
    49         // stopUsingProvider() may be called from any thread.
     49        // stopUsingProvider() may be called from any thread. The client should
     50        // block until it has putCurrentFrame any outstanding frames.
    5051        virtual void stopUsingProvider() = 0;
    5152
     
    5859    };
    5960
    60     // May be called from any thread.
     61    // May be called from any thread, but there must be some external guarantee
     62    // that the provider is not destroyed before this call returns.
    6163    virtual void setVideoFrameProviderClient(Client*) = 0;
    6264
     
    6466    // Calls to this method should always be followed with a call to putCurrentFrame().
    6567    // The ownership of the object is not transferred to the caller and
    66     // the caller should not free the returned object.
     68    // the caller should not free the returned object. Only the current provider
     69    // client should call this function.
    6770    virtual WebVideoFrame* getCurrentFrame() = 0;
    6871    // This function releases the lock on the video frame in chromium. It should
    6972    // always be called after getCurrentFrame(). Frames passed into this method
    70     // should no longer be referenced after the call is made.
     73    // should no longer be referenced after the call is made. Only the current
     74    // provider client should call this function.
    7175    virtual void putCurrentFrame(WebVideoFrame*) = 0;
    7276};
  • trunk/Source/WebKit/chromium/ChangeLog

    r128058 r128082  
     12012-09-10  Adrienne Walker  <enne@google.com>
     2
     3        [chromium] Fix deadlock between WebMediaPlayerClientImpl dtor and PutCurrentFrame
     4        https://bugs.webkit.org/show_bug.cgi?id=96010
     5
     6        Reviewed by James Robinson.
     7
     8        The key fix here is that the destructor no longer has a mutex.
     9        The m_compositingMutex was supposedly protecting races between
     10        ~WebMediaPlayerClientImpl and setVideoFrameProviderClient. The
     11        former is only called from the main thread and the latter is called
     12        from the compositor thread only when the main thread is blocked (and
     13        it already asserts that this is the case).
     14
     15        In addition, the m_providerMutex in CCVideoLayerImpl prevents the
     16        destruction of WebMediaPlayerClientImpl, thus keeping the frame
     17        acquired via getCurrentFrame alive until putCurrentFrame is called.
     18        These functions are only called by the client, and comments are added
     19        to the interface to better document this.
     20
     21        To prevent a race between load() and getCurrentFrame/putCurrentFrame
     22        (which are called from different threads) a new m_webMediaPlayerMutex
     23        to replace part of what the old m_compositingMutex was doing.
     24
     25        * src/WebMediaPlayerClientImpl.cpp:
     26        (WebKit::WebMediaPlayerClientImpl::~WebMediaPlayerClientImpl):
     27        (WebKit::WebMediaPlayerClientImpl::load):
     28        (WebKit::WebMediaPlayerClientImpl::loadInternal):
     29        (WebKit::WebMediaPlayerClientImpl::setVideoFrameProviderClient):
     30        (WebKit::WebMediaPlayerClientImpl::getCurrentFrame):
     31        (WebKit::WebMediaPlayerClientImpl::putCurrentFrame):
     32        * src/WebMediaPlayerClientImpl.h:
     33        (WebMediaPlayerClientImpl):
     34
    1352012-09-10  Rick Byers  <rbyers@chromium.org>
    236
  • trunk/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp

    r127952 r128082  
    9393{
    9494#if USE(ACCELERATED_COMPOSITING)
    95     MutexLocker locker(m_compositingMutex);
    9695    if (m_videoFrameProviderClient)
    9796        m_videoFrameProviderClient->stopUsingProvider();
     97    // No need for a lock here, as getCurrentFrame/putCurrentFrame can't be
     98    // called now that the client is no longer using this provider. Also, load()
     99    // and this destructor are called from the same thread.
    98100    if (m_webMediaPlayer)
    99101        m_webMediaPlayer->setStreamTextureClient(0);
     
    313315    m_url = url;
    314316
     317    MutexLocker locker(m_webMediaPlayerMutex);
    315318    if (m_preload == MediaPlayer::None) {
    316         MutexLocker locker(m_compositingMutex);
    317319#if ENABLE(WEB_AUDIO)
    318320        m_audioSourceProvider.wrap(0); // Clear weak reference to m_webMediaPlayer's WebAudioSourceProvider.
     
    326328void WebMediaPlayerClientImpl::loadInternal()
    327329{
    328     MutexLocker locker(m_compositingMutex);
    329330#if ENABLE(WEB_AUDIO)
    330331    m_audioSourceProvider.wrap(0); // Clear weak reference to m_webMediaPlayer's WebAudioSourceProvider.
     
    767768void WebMediaPlayerClientImpl::setVideoFrameProviderClient(WebVideoFrameProvider::Client* client)
    768769{
    769     MutexLocker locker(m_compositingMutex);
     770    MutexLocker locker(m_webMediaPlayerMutex);
    770771    if (m_videoFrameProviderClient)
    771772        m_videoFrameProviderClient->stopUsingProvider();
     
    777778WebVideoFrame* WebMediaPlayerClientImpl::getCurrentFrame()
    778779{
    779     MutexLocker locker(m_compositingMutex);
     780    // This function is called only by the client.
     781    MutexLocker locker(m_webMediaPlayerMutex);
    780782    ASSERT(!m_currentVideoFrame);
     783    ASSERT(m_videoFrameProviderClient);
    781784    if (m_webMediaPlayer)
    782785        m_currentVideoFrame = m_webMediaPlayer->getCurrentFrame();
     
    786789void WebMediaPlayerClientImpl::putCurrentFrame(WebVideoFrame* videoFrame)
    787790{
    788     MutexLocker locker(m_compositingMutex);
     791    // This function is called only by the client.
     792    MutexLocker locker(m_webMediaPlayerMutex);
    789793    ASSERT(videoFrame == m_currentVideoFrame);
     794    ASSERT(m_videoFrameProviderClient);
    790795    if (!videoFrame)
    791796        return;
  • trunk/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.h

    r127675 r128082  
    198198#endif
    199199
    200     Mutex m_compositingMutex; // Guards m_currentVideoFrame and m_videoFrameProviderClient.
     200    Mutex m_webMediaPlayerMutex; // Guards the m_webMediaPlayer
    201201    WebCore::MediaPlayer* m_mediaPlayer;
    202202    OwnPtr<WebMediaPlayer> m_webMediaPlayer;
Note: See TracChangeset for help on using the changeset viewer.