Changeset 148906 in webkit


Ignore:
Timestamp:
Apr 22, 2013 1:02:46 PM (11 years ago)
Author:
jer.noble@apple.com
Message:

Cancelling load may cause deadlock in -[AVPlayerItem release]
https://bugs.webkit.org/show_bug.cgi?id=114962

Reviewed by Eric Carlson.

Work around a bug in AVAssetResourceLoader by using a generic, non-main dispatch queue
to recieve AVAssetResourceLoaderDelegate callbacks, and then marshalling those
callbacks to the main thread asynchronously.

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

(WebCore::globalLoaderDelegateQueue): Added.
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL): Use the new global queue.
(-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]):

Marshall the request to the main queue, and return YES (wait) immediately.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r148903 r148906  
     12013-04-22  Jer Noble  <jer.noble@apple.com>
     2
     3        Cancelling load may cause deadlock in -[AVPlayerItem release]
     4        https://bugs.webkit.org/show_bug.cgi?id=114962
     5
     6        Reviewed by Eric Carlson.
     7
     8        Work around a bug in AVAssetResourceLoader by using a generic, non-main dispatch queue
     9        to recieve AVAssetResourceLoaderDelegate callbacks, and then marshalling those
     10        callbacks to the main thread asynchronously.
     11
     12        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
     13        (WebCore::globalLoaderDelegateQueue): Added.
     14        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL): Use the new global queue.
     15        (-[WebCoreAVFLoaderDelegate resourceLoader:shouldWaitForLoadingOfRequestedResource:]):
     16            Marshall the request to the main queue, and return YES (wait) immediately.
     17
    1182013-04-22  Zan Dobersek  <zdobersek@igalia.com>
    219
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

    r148545 r148906  
    200200#endif
    201201
     202#if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
     203static dispatch_queue_t globalLoaderDelegateQueue()
     204{
     205    static dispatch_queue_t globalQueue;
     206    static dispatch_once_t onceToken;
     207    dispatch_once(&onceToken, ^{
     208        globalQueue = dispatch_queue_create("WebCoreAVFLoaderDelegate queue", DISPATCH_QUEUE_SERIAL);
     209    });
     210    return globalQueue;
     211}
     212#endif
    202213
    203214PassOwnPtr<MediaPlayerPrivateInterface> MediaPlayerPrivateAVFoundationObjC::create(MediaPlayer* player)
     
    412423
    413424#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
    414     [[m_avAsset.get() resourceLoader] setDelegate:m_loaderDelegate.get() queue:dispatch_get_main_queue()];
     425    [[m_avAsset.get() resourceLoader] setDelegate:m_loaderDelegate.get() queue:globalLoaderDelegateQueue()];
    415426#endif
    416427
     
    16131624        return NO;
    16141625
    1615     return m_callback->shouldWaitForLoadingOfResource(loadingRequest);
     1626    dispatch_async(dispatch_get_main_queue(), ^{
     1627        if (!m_callback) {
     1628            [loadingRequest finishLoadingWithError:nil];
     1629            return;
     1630        }
     1631
     1632        if (!m_callback->shouldWaitForLoadingOfResource(loadingRequest))
     1633            [loadingRequest finishLoadingWithError:nil];
     1634    });
     1635
     1636    return YES;
    16161637}
    16171638
Note: See TracChangeset for help on using the changeset viewer.