[Mac] Hang when calling -[AVAsset resolvedURL].
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Dec 2014 18:01:32 +0000 (18:01 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Dec 2014 18:01:32 +0000 (18:01 +0000)
https://bugs.webkit.org/show_bug.cgi?id=139223

Reviewed by Eric Carlson.

On a particularly slow-loading site, a call to -[AVAsset resolvedURL] can take an arbitrarily long
time. Treat this AVAsset property similar to other "metadata" properties, and check the load status
of the property before requesting it.

* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::hasSingleSecurityOrigin): Check the load state of -resolvedURL.
(WebCore::MediaPlayerPrivateAVFoundationObjC::resolvedURL): Ditto.
(WebCore::assetMetadataKeyNames): Add @"resolvedURL".

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176725 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

index 60575ae..49a3a84 100644 (file)
@@ -1,3 +1,19 @@
+2014-12-03  Jer Noble  <jer.noble@apple.com>
+
+        [Mac] Hang when calling -[AVAsset resolvedURL].
+        https://bugs.webkit.org/show_bug.cgi?id=139223
+
+        Reviewed by Eric Carlson.
+
+        On a particularly slow-loading site, a call to -[AVAsset resolvedURL] can take an arbitrarily long
+        time. Treat this AVAsset property similar to other "metadata" properties, and check the load status
+        of the property before requesting it.
+
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::hasSingleSecurityOrigin): Check the load state of -resolvedURL.
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::resolvedURL): Ditto.
+        (WebCore::assetMetadataKeyNames): Add @"resolvedURL".
+
 2014-12-03  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         URTBF after r176721 to fix ENABLE(CSS_DEVICE_ADAPTATION) build.
index c5906d9..698a2fb 100644 (file)
@@ -2005,10 +2005,10 @@ void MediaPlayerPrivateAVFoundationObjC::sizeChanged()
     
 bool MediaPlayerPrivateAVFoundationObjC::hasSingleSecurityOrigin() const 
 {
-    if (!m_avAsset)
+    if (!m_avAsset || [m_avAsset statusOfValueForKey:@"resolvedURL" error:nullptr] != AVKeyValueStatusLoaded)
         return false;
     
-    RefPtr<SecurityOrigin> resolvedOrigin = SecurityOrigin::create(URL([m_avAsset resolvedURL]));
+    RefPtr<SecurityOrigin> resolvedOrigin = SecurityOrigin::create(resolvedURL());
     RefPtr<SecurityOrigin> requestedOrigin = SecurityOrigin::createFromString(assetURL());
     return resolvedOrigin->isSameSchemeHostPort(requestedOrigin.get());
 }
@@ -2851,7 +2851,7 @@ void MediaPlayerPrivateAVFoundationObjC::canPlayFastReverseDidChange(bool newVal
 
 URL MediaPlayerPrivateAVFoundationObjC::resolvedURL() const
 {
-    if (!m_avAsset)
+    if (!m_avAsset || [m_avAsset statusOfValueForKey:@"resolvedURL" error:nullptr] != AVKeyValueStatusLoaded)
         return MediaPlayerPrivateAVFoundation::resolvedURL();
 
     return URL([m_avAsset resolvedURL]);
@@ -2867,6 +2867,7 @@ NSArray* assetMetadataKeyNames()
                     @"preferredVolume",
                     @"preferredRate",
                     @"playable",
+                    @"resolvedURL",
                     @"tracks",
                     @"availableMediaCharacteristicsWithMediaSelectionOptions",
                    nil];