Commit 0001b28a authored by jer.noble@apple.com's avatar jer.noble@apple.com

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.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@148906 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 36dcfa09
2013-04-22 Jer Noble <jer.noble@apple.com>
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.
2013-04-22 Zan Dobersek <zdobersek@igalia.com>
[GTK] Set up libPlatform.la
......@@ -199,6 +199,17 @@ static PlayerToPrivateMapType& playerToPrivateMap()
};
#endif
#if ENABLE(ENCRYPTED_MEDIA) || ENABLE(ENCRYPTED_MEDIA_V2)
static dispatch_queue_t globalLoaderDelegateQueue()
{
static dispatch_queue_t globalQueue;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
globalQueue = dispatch_queue_create("WebCoreAVFLoaderDelegate queue", DISPATCH_QUEUE_SERIAL);
});
return globalQueue;
}
#endif
PassOwnPtr<MediaPlayerPrivateInterface> MediaPlayerPrivateAVFoundationObjC::create(MediaPlayer* player)
{
......@@ -411,7 +422,7 @@ void MediaPlayerPrivateAVFoundationObjC::createAVAssetForURL(const String& url)
m_avAsset.adoptNS([[AVURLAsset alloc] initWithURL:cocoaURL options:options.get()]);
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
[[m_avAsset.get() resourceLoader] setDelegate:m_loaderDelegate.get() queue:dispatch_get_main_queue()];
[[m_avAsset.get() resourceLoader] setDelegate:m_loaderDelegate.get() queue:globalLoaderDelegateQueue()];
#endif
m_haveCheckedPlayability = false;
......@@ -1612,7 +1623,17 @@ NSArray* itemKVOProperties()
if (!m_callback)
return NO;
return m_callback->shouldWaitForLoadingOfResource(loadingRequest);
dispatch_async(dispatch_get_main_queue(), ^{
if (!m_callback) {
[loadingRequest finishLoadingWithError:nil];
return;
}
if (!m_callback->shouldWaitForLoadingOfResource(loadingRequest))
[loadingRequest finishLoadingWithError:nil];
});
return YES;
}
- (void)resourceLoader:(AVAssetResourceLoader *)resourceLoader didCancelLoadingRequest:(AVAssetResourceLoadingRequest *)loadingRequest
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment