Changeset 116833 in webkit


Ignore:
Timestamp:
May 11, 2012 7:04:46 PM (12 years ago)
Author:
enne@google.com
Message:

[chromium] Prevent deadlock on CCVideoLayerImpl destruction
https://bugs.webkit.org/show_bug.cgi?id=86258

Reviewed by James Robinson.

~CCVideoLayerImpl had a common deadlock issue where if it got
destroyed before WebMediaPlayerClientImpl, it would take a lock,
call WebMediaPlayerClientImpl::setVideoFrameProviderClient(0),
which in turn would call CCVideoLayerImpl::stopUsingProvider(),
which would try to take the same lock and would deadlock.

CCVideoLayerImpl is only created and destroyed during tree
synchronization in a commit or during synchronous compositor thread
destruction. In either case, the main thread is blocked, and so no
lock needs to be taken at all.

  • platform/graphics/chromium/cc/CCVideoLayerImpl.cpp:

(WebCore::CCVideoLayerImpl::CCVideoLayerImpl):
(WebCore::CCVideoLayerImpl::~CCVideoLayerImpl):
(WebCore::CCVideoLayerImpl::stopUsingProvider):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r116832 r116833  
     12012-05-11  Adrienne Walker  <enne@google.com>
     2
     3        [chromium] Prevent deadlock on CCVideoLayerImpl destruction
     4        https://bugs.webkit.org/show_bug.cgi?id=86258
     5
     6        Reviewed by James Robinson.
     7
     8        ~CCVideoLayerImpl had a common deadlock issue where if it got
     9        destroyed before WebMediaPlayerClientImpl, it would take a lock,
     10        call WebMediaPlayerClientImpl::setVideoFrameProviderClient(0),
     11        which in turn would call CCVideoLayerImpl::stopUsingProvider(),
     12        which would try to take the same lock and would deadlock.
     13
     14        CCVideoLayerImpl is only created and destroyed during tree
     15        synchronization in a commit or during synchronous compositor thread
     16        destruction. In either case, the main thread is blocked, and so no
     17        lock needs to be taken at all.
     18
     19        * platform/graphics/chromium/cc/CCVideoLayerImpl.cpp:
     20        (WebCore::CCVideoLayerImpl::CCVideoLayerImpl):
     21        (WebCore::CCVideoLayerImpl::~CCVideoLayerImpl):
     22        (WebCore::CCVideoLayerImpl::stopUsingProvider):
     23
    1242012-05-11  Jeffrey Pfau  <jpfau@apple.com>
    225
  • trunk/Source/WebCore/platform/graphics/chromium/cc/CCVideoLayerImpl.cpp

    r115281 r116833  
    8181{
    8282    memcpy(m_streamTextureMatrix, flipTransform, sizeof(m_streamTextureMatrix));
    83     provider->setVideoFrameProviderClient(this);
     83
     84    // This only happens during a commit on the compositor thread while the main
     85    // thread is blocked. That makes this a thread-safe call to set the video
     86    // frame provider client that does not require a lock. The same is true of
     87    // the call in the destructor.
     88    m_provider->setVideoFrameProviderClient(this);
    8489}
    8590
    8691CCVideoLayerImpl::~CCVideoLayerImpl()
    8792{
    88     MutexLocker locker(m_providerMutex);
     93    // See comment in constructor for why this doesn't need a lock.
    8994    if (m_provider) {
    9095        m_provider->setVideoFrameProviderClient(0);
     
    97102void CCVideoLayerImpl::stopUsingProvider()
    98103{
     104    // Block the provider from shutting down until this client is done
     105    // using the frame.
    99106    MutexLocker locker(m_providerMutex);
     107    ASSERT(!m_frame);
    100108    m_provider = 0;
    101109}
Note: See TracChangeset for help on using the changeset viewer.