Title: [148906] trunk/Source/WebCore
Revision
148906
Author
jer.no...@apple.com
Date
2013-04-22 13:02:46 -0700 (Mon, 22 Apr 2013)

Log 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.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (148905 => 148906)


--- trunk/Source/WebCore/ChangeLog	2013-04-22 20:01:51 UTC (rev 148905)
+++ trunk/Source/WebCore/ChangeLog	2013-04-22 20:02:46 UTC (rev 148906)
@@ -1,3 +1,20 @@
+2013-04-22  Jer Noble  <jer.no...@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  <zdober...@igalia.com>
 
         [GTK] Set up libPlatform.la

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (148905 => 148906)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2013-04-22 20:01:51 UTC (rev 148905)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2013-04-22 20:02:46 UTC (rev 148906)
@@ -199,6 +199,17 @@
 };
 #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 @@
     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 @@
     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
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to