Title: [176002] trunk/Source/WebCore
Revision
176002
Author
[email protected]
Date
2014-11-11 20:29:54 -0800 (Tue, 11 Nov 2014)

Log Message

[Mac] Add diagnostic logging for per-media-engine load failures
https://bugs.webkit.org/show_bug.cgi?id=138647

Reviewed by Eric Carlson.

Add diagnostic logging fired whenever a media engine fails to load media,
even if another engine subsequentially succeeds. Add a mechanism for retrieving
the platform-specific error code from a given engine.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::parseAttribute):
* html/HTMLMediaElement.h:
* page/DiagnosticLoggingKeys.cpp:
(WebCore::DiagnosticLoggingKeys::engineFailedToLoadKey):
* page/DiagnosticLoggingKeys.h:
* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::networkStateChanged):
(WebCore::MediaPlayer::platformErrorCode):
* platform/graphics/MediaPlayer.h:
(WebCore::MediaPlayerClient::mediaPlayerEngineFailedToLoad):
* platform/graphics/MediaPlayerPrivate.h:
(WebCore::MediaPlayerPrivateInterface::platformErrorCode):
* platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
(WebCore::MediaPlayerPrivateAVFoundation::platformErrorCode):
* platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
(WebCore::MediaPlayerPrivateAVFoundationCF::assetErrorCode):
* platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
* platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
(WebCore::MediaPlayerPrivateAVFoundationObjC::assetErrorCode):
* platform/graphics/mac/MediaPlayerPrivateQTKit.h:
* platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
(WebCore::MediaPlayerPrivateQTKit::platformErrorCode):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (176001 => 176002)


--- trunk/Source/WebCore/ChangeLog	2014-11-12 04:17:18 UTC (rev 176001)
+++ trunk/Source/WebCore/ChangeLog	2014-11-12 04:29:54 UTC (rev 176002)
@@ -1,3 +1,39 @@
+2014-11-11  Jer Noble  <[email protected]>
+
+        [Mac] Add diagnostic logging for per-media-engine load failures
+        https://bugs.webkit.org/show_bug.cgi?id=138647
+
+        Reviewed by Eric Carlson.
+
+        Add diagnostic logging fired whenever a media engine fails to load media,
+        even if another engine subsequentially succeeds. Add a mechanism for retrieving
+        the platform-specific error code from a given engine.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::parseAttribute):
+        * html/HTMLMediaElement.h:
+        * page/DiagnosticLoggingKeys.cpp:
+        (WebCore::DiagnosticLoggingKeys::engineFailedToLoadKey):
+        * page/DiagnosticLoggingKeys.h:
+        * platform/graphics/MediaPlayer.cpp:
+        (WebCore::MediaPlayer::networkStateChanged):
+        (WebCore::MediaPlayer::platformErrorCode):
+        * platform/graphics/MediaPlayer.h:
+        (WebCore::MediaPlayerClient::mediaPlayerEngineFailedToLoad):
+        * platform/graphics/MediaPlayerPrivate.h:
+        (WebCore::MediaPlayerPrivateInterface::platformErrorCode):
+        * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
+        (WebCore::MediaPlayerPrivateAVFoundation::platformErrorCode):
+        * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:
+        (WebCore::MediaPlayerPrivateAVFoundationCF::assetErrorCode):
+        * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
+        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
+        (WebCore::MediaPlayerPrivateAVFoundationObjC::assetErrorCode):
+        * platform/graphics/mac/MediaPlayerPrivateQTKit.h:
+        * platform/graphics/mac/MediaPlayerPrivateQTKit.mm:
+        (WebCore::MediaPlayerPrivateQTKit::platformErrorCode):
+
 2014-11-11  Chris Dumez  <[email protected]>
 
         Mark more virtual functions in HTMLInputElement as final

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (176001 => 176002)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2014-11-12 04:17:18 UTC (rev 176001)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2014-11-12 04:29:54 UTC (rev 176002)
@@ -5762,6 +5762,20 @@
     return document().isMediaDocument();
 }
 
+void HTMLMediaElement::mediaPlayerEngineFailedToLoad() const
+{
+    if (!m_player)
+        return;
+
+    Page* page = document().page();
+    if (!page || !page->settings().diagnosticLoggingEnabled())
+        return;
+
+    String engine = m_player->engineDescription();
+    String message = String::number(m_player->platformErrorCode());
+    page->chrome().client().logDiagnosticMessage(DiagnosticLoggingKeys::engineFailedToLoadKey(), engine, message);
+}
+
 void HTMLMediaElement::removeBehaviorsRestrictionsAfterFirstUserGesture()
 {
     m_mediaSession->removeBehaviorRestriction(HTMLMediaSession::RequireUserGestureForLoad);

Modified: trunk/Source/WebCore/html/HTMLMediaElement.h (176001 => 176002)


--- trunk/Source/WebCore/html/HTMLMediaElement.h	2014-11-12 04:17:18 UTC (rev 176001)
+++ trunk/Source/WebCore/html/HTMLMediaElement.h	2014-11-12 04:29:54 UTC (rev 176002)
@@ -592,6 +592,7 @@
 #endif
 
     virtual bool mediaPlayerIsInMediaDocument() const override final;
+    virtual void mediaPlayerEngineFailedToLoad() const override final;
 
     void loadTimerFired(Timer&);
     void progressEventTimerFired(Timer&);

Modified: trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp (176001 => 176002)


--- trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp	2014-11-12 04:17:18 UTC (rev 176001)
+++ trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp	2014-11-12 04:29:54 UTC (rev 176002)
@@ -88,4 +88,10 @@
     return WTF::ASCIILiteral("pageLoaded");
 }
 
+String DiagnosticLoggingKeys::engineFailedToLoadKey()
+{
+    return WTF::ASCIILiteral("engineFailedToLoad");
 }
+
+}
+

Modified: trunk/Source/WebCore/page/DiagnosticLoggingKeys.h (176001 => 176002)


--- trunk/Source/WebCore/page/DiagnosticLoggingKeys.h	2014-11-12 04:17:18 UTC (rev 176001)
+++ trunk/Source/WebCore/page/DiagnosticLoggingKeys.h	2014-11-12 04:29:54 UTC (rev 176002)
@@ -42,6 +42,7 @@
     static String pageContainsMediaEngineKey();
     static String pageContainsAtLeastOneMediaEngineKey();
     static String pageLoadedKey();
+    static String engineFailedToLoadKey();
 
     // Success keys.
     static String passKey();

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp (176001 => 176002)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp	2014-11-12 04:17:18 UTC (rev 176001)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp	2014-11-12 04:29:54 UTC (rev 176002)
@@ -1014,10 +1014,9 @@
 {
     // If more than one media engine is installed and this one failed before finding metadata,
     // let the next engine try.
-    if (m_private->networkState() >= FormatError
-        && m_private->readyState() < HaveMetadata
-        && installedMediaEngines().size() > 1) {
-        if (m_contentMIMEType.isEmpty() || nextBestMediaEngine(m_currentMediaEngine)) {
+    if (m_private->networkState() >= FormatError && m_private->readyState() < HaveMetadata) {
+        m_client.mediaPlayerEngineFailedToLoad();
+        if (installedMediaEngines().size() > 1 && (m_contentMIMEType.isEmpty() || nextBestMediaEngine(m_currentMediaEngine))) {
             m_reloadTimer.startOneShot(0);
             return;
         }
@@ -1146,6 +1145,14 @@
     return m_private->engineDescription();
 }
 
+long MediaPlayer::platformErrorCode() const
+{
+    if (!m_private)
+        return 0;
+
+    return m_private->platformErrorCode();
+}
+
 #if PLATFORM(WIN) && USE(AVFOUNDATION)
 GraphicsDeviceAdapter* MediaPlayer::graphicsDeviceAdapter() const
 {

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (176001 => 176002)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2014-11-12 04:17:18 UTC (rev 176001)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2014-11-12 04:29:54 UTC (rev 176002)
@@ -261,6 +261,7 @@
     virtual String mediaPlayerSourceApplicationIdentifier() const { return emptyString(); }
 
     virtual bool mediaPlayerIsInMediaDocument() const { return false; }
+    virtual void mediaPlayerEngineFailedToLoad() const { }
 };
 
 class MediaPlayerSupportsTypeClient {
@@ -520,6 +521,7 @@
     String userAgent() const;
 
     String engineDescription() const;
+    long platformErrorCode() const;
 
     CachedResourceLoader* cachedResourceLoader();
     PassRefPtr<PlatformMediaResourceLoader> createResourceLoader(std::unique_ptr<PlatformMediaResourceLoaderClient>);

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h (176001 => 176002)


--- trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h	2014-11-12 04:17:18 UTC (rev 176001)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h	2014-11-12 04:29:54 UTC (rev 176002)
@@ -63,6 +63,7 @@
     virtual String accessLog() const { return emptyString(); }
     virtual String errorLog() const { return emptyString(); }
 #endif
+    virtual long platformErrorCode() const { return 0; }
 
     virtual void play() = 0;
     virtual void pause() = 0;    

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h (176001 => 176002)


--- trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h	2014-11-12 04:17:18 UTC (rev 176001)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h	2014-11-12 04:29:54 UTC (rev 176002)
@@ -225,6 +225,7 @@
         MediaPlayerAVAssetStatusPlayable,
     };
     virtual AssetStatus assetStatus() const = 0;
+    virtual long assetErrorCode() const = 0;
 
     virtual void platformSetVisible(bool) = 0;
     virtual void platformPlay() = 0;
@@ -291,6 +292,7 @@
     MediaPlayer* player() { return m_player; }
 
     virtual String engineDescription() const { return "AVFoundation"; }
+    virtual long platformErrorCode() const { return assetErrorCode(); }
 
     virtual void trackModeChanged() override;
 #if ENABLE(AVF_CAPTIONS)

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp (176001 => 176002)


--- trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp	2014-11-12 04:17:18 UTC (rev 176001)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp	2014-11-12 04:29:54 UTC (rev 176002)
@@ -1133,6 +1133,21 @@
 }
 #endif
 
+long MediaPlayerPrivateAVFoundationCF::assetErrorCode() const
+{
+    if (!avAsset(m_avfWrapper))
+        return 0;
+
+    CFErrorRef error = nullptr;
+    AVCFAssetGetStatusOfValueForProperty(avAsset(m_avfWrapper), AVCFAssetPropertyPlayable, &error);
+    if (!error)
+        return 0;
+
+    long code = CFErrorGetCode(error);
+    CFRelease(error);
+    return code;
+}
+
 #if !HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
 void MediaPlayerPrivateAVFoundationCF::processLegacyClosedCaptionsTracks()
 {

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h (176001 => 176002)


--- trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h	2014-11-12 04:17:18 UTC (rev 176001)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h	2014-11-12 04:29:54 UTC (rev 176002)
@@ -131,6 +131,8 @@
     virtual void setCurrentTextTrack(InbandTextTrackPrivateAVF*) override;
     virtual InbandTextTrackPrivateAVF* currentTextTrack() const override;
 
+    virtual long assetErrorCode() const override final;
+
 #if !HAVE(AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT)
     void processLegacyClosedCaptionsTracks();
 #endif

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (176001 => 176002)


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h	2014-11-12 04:17:18 UTC (rev 176001)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h	2014-11-12 04:29:54 UTC (rev 176002)
@@ -174,6 +174,7 @@
     virtual void createAVAssetForURL(const String& url);
     virtual MediaPlayerPrivateAVFoundation::ItemStatus playerItemStatus() const;
     virtual MediaPlayerPrivateAVFoundation::AssetStatus assetStatus() const;
+    virtual long assetErrorCode() const;
 
     virtual void checkPlayability();
     virtual void updateRate();

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


--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2014-11-12 04:17:18 UTC (rev 176001)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm	2014-11-12 04:29:54 UTC (rev 176002)
@@ -1396,6 +1396,16 @@
     return MediaPlayerAVAssetStatusLoaded;
 }
 
+long MediaPlayerPrivateAVFoundationObjC::assetErrorCode() const
+{
+    if (!m_avAsset)
+        return 0;
+
+    NSError *error = nil;
+    [m_avAsset statusOfValueForKey:@"playable" error:&error];
+    return [error code];
+}
+
 void MediaPlayerPrivateAVFoundationObjC::paintCurrentFrameInContext(GraphicsContext* context, const IntRect& rect)
 {
     if (!metaDataAvailable() || context->paintingDisabled())

Modified: trunk/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h (176001 => 176002)


--- trunk/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h	2014-11-12 04:17:18 UTC (rev 176001)
+++ trunk/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h	2014-11-12 04:29:54 UTC (rev 176002)
@@ -173,6 +173,7 @@
     NSMutableDictionary* commonMovieAttributes();
 
     virtual String engineDescription() const { return "QTKit"; }
+    virtual long platformErrorCode() const;
 
     MediaPlayer* m_player;
     RetainPtr<QTMovie> m_qtMovie;

Modified: trunk/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm (176001 => 176002)


--- trunk/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm	2014-11-12 04:17:18 UTC (rev 176001)
+++ trunk/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm	2014-11-12 04:29:54 UTC (rev 176002)
@@ -67,6 +67,7 @@
 SOFT_LINK_POINTER(QTKit, QTMovieHasAudioAttribute, NSString *)
 SOFT_LINK_POINTER(QTKit, QTMovieIsActiveAttribute, NSString *)
 SOFT_LINK_POINTER(QTKit, QTMovieLoadStateAttribute, NSString *)
+SOFT_LINK_POINTER(QTKit, QTMovieLoadStateErrorAttribute, NSString *)
 SOFT_LINK_POINTER(QTKit, QTMovieLoadStateDidChangeNotification, NSString *)
 SOFT_LINK_POINTER(QTKit, QTMovieNaturalSizeAttribute, NSString *)
 SOFT_LINK_POINTER(QTKit, QTMovieCurrentSizeAttribute, NSString *)
@@ -111,6 +112,7 @@
 #define QTMovieHasAudioAttribute getQTMovieHasAudioAttribute()
 #define QTMovieIsActiveAttribute getQTMovieIsActiveAttribute()
 #define QTMovieLoadStateAttribute getQTMovieLoadStateAttribute()
+#define QTMovieLoadStateErrorAttribute getQTMovieLoadStateErrorAttribute()
 #define QTMovieLoadStateDidChangeNotification getQTMovieLoadStateDidChangeNotification()
 #define QTMovieNaturalSizeAttribute getQTMovieNaturalSizeAttribute()
 #define QTMovieCurrentSizeAttribute getQTMovieCurrentSizeAttribute()
@@ -1053,6 +1055,18 @@
     LOG(Media, "MediaPlayerPrivateQTKit::updateStates(%p) - exiting with networkState = %i, readyState = %i", this, static_cast<int>(m_networkState), static_cast<int>(m_readyState));
 }
 
+long MediaPlayerPrivateQTKit::platformErrorCode() const
+{
+    if (!m_qtMovie)
+        return 0;
+
+    NSError* error = (NSError*)[m_qtMovie attributeForKey:QTMovieLoadStateErrorAttribute];
+    if (!error || ![error isKindOfClass:[NSError class]])
+        return 0;
+
+    return [error code];
+}
+
 void MediaPlayerPrivateQTKit::loadStateChanged()
 {
     LOG(Media, "MediaPlayerPrivateQTKit::loadStateChanged(%p) - loadState = %li", this, [[m_qtMovie.get() attributeForKey:QTMovieLoadStateAttribute] longValue]);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to