Bug 1271483 - p15. Check if issues have been solved - r=cpearce draft
authorGerald Squelart <gsquelart@mozilla.com>
Wed, 25 May 2016 00:41:53 +1000
changeset 372051 da70f4f8d7bf917e28c2bc2c935b2cab9dbfb8f5
parent 372050 47bc43db2a14836ae8f138adac8dfc0d612aff37
child 372052 18aec8010f6233078b2bfd81b2554756fd76d505
push id19423
push usergsquelart@mozilla.com
push dateFri, 27 May 2016 09:31:44 +0000
reviewerscpearce
bugs1271483
milestone49.0a1
Bug 1271483 - p15. Check if issues have been solved - r=cpearce To determine if an issue has been solved, go through the possible prefs that would have been saved by the front-end, to see if any previously-unplayable formats/key systems are now playable, in which case we notify the frontend, to record the issue-solved telemetry. MozReview-Commit-ID: DmU50i6FtG8
dom/media/DecoderDoctorDiagnostics.cpp
--- a/dom/media/DecoderDoctorDiagnostics.cpp
+++ b/dom/media/DecoderDoctorDiagnostics.cpp
@@ -366,16 +366,26 @@ static const NotificationAndReportString
     "MediaPlatformDecoderNotFound" };
 static const NotificationAndReportStringId sMediaCannotPlayNoDecoders =
   { dom::DecoderDoctorNotificationType::Cannot_play,
     "MediaCannotPlayNoDecoders" };
 static const NotificationAndReportStringId sMediaNoDecoders =
   { dom::DecoderDoctorNotificationType::Can_play_but_some_missing_decoders,
     "MediaNoDecoders" };
 
+static const NotificationAndReportStringId*
+sAllNotificationsAndReportStringIds[] =
+{
+  &sMediaWidevineNoWMFNoSilverlight,
+  &sMediaWMFNeeded,
+  &sMediaPlatformDecoderNotFound,
+  &sMediaCannotPlayNoDecoders,
+  &sMediaNoDecoders
+};
+
 static void
 DispatchNotification(nsISupports* aSubject,
                      const NotificationAndReportStringId& aNotification,
                      bool aIsSolved,
                      const nsAString& aFormats)
 {
   if (!aSubject) {
     return;
@@ -561,24 +571,76 @@ DecoderDoctorDocumentWatcher::Synthesize
         MOZ_ASSERT(diag.mDecoderDoctorDiagnostics.Type()
                      == DecoderDoctorDiagnostics::eFormatSupportCheck
                    || diag.mDecoderDoctorDiagnostics.Type()
                         == DecoderDoctorDiagnostics::eMediaKeySystemAccessRequest);
         break;
     }
   }
 
+  // Check if issues have been solved, by finding if some now-playable
+  // key systems or formats were previously recorded as having issues.
+  if (!supportedKeySystems.IsEmpty() || !playableFormats.IsEmpty()) {
+    DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - supported key systems '%s', playable formats '%s'; See if they show issues have been solved...",
+             this, mDocument,
+             NS_ConvertUTF16toUTF8(supportedKeySystems).Data(),
+             NS_ConvertUTF16toUTF8(playableFormats).get());
+    const nsAString* workingFormatsArray[] =
+      { &supportedKeySystems, &playableFormats };
+    // For each type of notification, retrieve the pref that contains formats/
+    // key systems with issues.
+    for (const NotificationAndReportStringId* id :
+           sAllNotificationsAndReportStringIds) {
+      nsAutoCString formatsPref("media.decoder-doctor.");
+      formatsPref += id->mReportStringId;
+      formatsPref += ".formats";
+      nsAdoptingString formatsWithIssues =
+        Preferences::GetString(formatsPref.Data());
+      if (formatsWithIssues.IsEmpty()) {
+        continue;
+      }
+      // See if that list of formats-with-issues contains any formats that are
+      // now playable/supported.
+      bool solved = false;
+      for (const nsAString* workingFormats : workingFormatsArray) {
+        for (const auto& workingFormat : MakeStringListRange(*workingFormats)) {
+          if (FormatsListContains(formatsWithIssues, workingFormat)) {
+            // This now-working format used not to work -> Report solved issue.
+            DD_INFO("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - %s solved ('%s' now works, it was in pref(%s)='%s')",
+                    this, mDocument, id->mReportStringId,
+                    NS_ConvertUTF16toUTF8(workingFormat).get(),
+                    formatsPref.Data(),
+                    NS_ConvertUTF16toUTF8(formatsWithIssues).get());
+            ReportAnalysis(*id, true, workingFormat);
+            // This particular Notification&ReportId has been solved, no need
+            // to keep looking at other keysys/formats that might solve it too.
+            solved = true;
+            break;
+          }
+        }
+        if (solved) {
+          break;
+        }
+      }
+      if (!solved) {
+        DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - %s not solved (pref(%s)='%s')",
+                 this, mDocument, id->mReportStringId, formatsPref.Data(),
+                 NS_ConvertUTF16toUTF8(formatsWithIssues).get());
+      }
+    }
+  }
+
   // Look at Key System issues first, as they take precedence over format checks.
   if (!unsupportedKeySystems.IsEmpty() && supportedKeySystems.IsEmpty()) {
     // No supported key systems!
     switch (lastKeySystemIssue) {
       case DecoderDoctorDiagnostics::eWidevineWithNoWMF:
         if (CheckSilverlight() != eSilverlightEnabled) {
-          DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - unsupported key systems: %s, widevine without WMF nor Silverlight",
-                   this, mDocument, NS_ConvertUTF16toUTF8(unsupportedKeySystems).get());
+          DD_INFO("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - unsupported key systems: %s, widevine without WMF nor Silverlight",
+                  this, mDocument, NS_ConvertUTF16toUTF8(unsupportedKeySystems).get());
           ReportAnalysis(
             sMediaWidevineNoWMFNoSilverlight, false, unsupportedKeySystems);
           return;
         }
         break;
       default:
         break;
     }
@@ -587,32 +649,32 @@ DecoderDoctorDocumentWatcher::Synthesize
   // Next, check playability of requested formats.
   if (!unplayableFormats.IsEmpty()) {
     // Some requested formats cannot be played.
     if (playableFormats.IsEmpty()) {
       // No requested formats can be played. See if we can help the user, by
       // going through expected decoders from most to least desirable.
 #if defined(XP_WIN)
       if (!formatsRequiringWMF.IsEmpty()) {
-        DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - unplayable formats: %s -> Cannot play media because WMF was not found",
-                 this, mDocument, NS_ConvertUTF16toUTF8(formatsRequiringWMF).get());
+        DD_INFO("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - unplayable formats: %s -> Cannot play media because WMF was not found",
+                this, mDocument, NS_ConvertUTF16toUTF8(formatsRequiringWMF).get());
         ReportAnalysis(sMediaWMFNeeded, false, formatsRequiringWMF);
         return;
       }
 #endif
 #if defined(MOZ_FFMPEG)
       if (!formatsRequiringFFMpeg.IsEmpty()) {
-        DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - unplayable formats: %s -> Cannot play media because platform decoder was not found",
-                 this, mDocument, NS_ConvertUTF16toUTF8(formatsRequiringFFMpeg).get());
+        DD_INFO("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - unplayable formats: %s -> Cannot play media because platform decoder was not found",
+                this, mDocument, NS_ConvertUTF16toUTF8(formatsRequiringFFMpeg).get());
         ReportAnalysis(sMediaPlatformDecoderNotFound,
                        false, formatsRequiringFFMpeg);
         return;
       }
 #endif
-      DD_WARN("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - Cannot play media, unplayable formats: %s",
+      DD_INFO("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - Cannot play media, unplayable formats: %s",
               this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get());
       ReportAnalysis(sMediaCannotPlayNoDecoders, false, unplayableFormats);
       return;
     }
 
     DD_INFO("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - Can play media, but no decoders for some requested formats: %s",
             this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get());
     if (Preferences::GetBool("media.decoder-doctor.verbose", false)) {