Bug 1268379 - Delay WMF checks in GMPParent - r=jesup a=ritu
authorGerald Squelart <gsquelart@mozilla.com>
Mon, 02 May 2016 15:03:11 +1000
changeset 332716 0162b3b3ee740c7a9dbcb05e7d8905034a38090f
parent 332715 2804f926fe774f845bc75a18262efabc3ca35fe8
child 332717 e6ca64925a10f789262cc3a8ef84a0b449187998
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup, ritu
bugs1268379
milestone48.0a2
Bug 1268379 - Delay WMF checks in GMPParent - r=jesup a=ritu The WMF HasAAC/HasH264 checks were done off the main thread, as soon as the plugin was loaded, which was way too soon in the overall startup process, when the WMF subsystem may not have been properly initialized yet, or may be in the middle of it. The solution here is to delay these checks until they are actually needed to respond to a format-support request, as they come later in the process. Note: This may not be the ideal solution yet, as we are still relying on some magic sequencing of events. Other avenues have been explored unsuccessfully yet, but we may want to revisit this issue after this urgent patch has landed. MozReview-Commit-ID: JVgINc5FLFx
dom/media/gmp/GMPParent.cpp
--- a/dom/media/gmp/GMPParent.cpp
+++ b/dom/media/gmp/GMPParent.cpp
@@ -570,16 +570,33 @@ GMPParent::SupportsAPI(const nsCString& 
 {
   for (uint32_t i = 0; i < mCapabilities.Length(); i++) {
     if (!mCapabilities[i].mAPIName.Equals(aAPI)) {
       continue;
     }
     nsTArray<nsCString>& tags = mCapabilities[i].mAPITags;
     for (uint32_t j = 0; j < tags.Length(); j++) {
       if (tags[j].Equals(aTag)) {
+#ifdef XP_WIN
+        // Clearkey on Windows advertises that it can decode in its GMP info
+        // file, but uses Windows Media Foundation to decode. That's not present
+        // on Windows XP, and on some Vista, Windows N, and KN variants without
+        // certain services packs.
+        if (tags[j].EqualsLiteral("org.w3.clearkey")) {
+          if (mCapabilities[i].mAPIName.EqualsLiteral(GMP_API_VIDEO_DECODER)) {
+            if (!WMFDecoderModule::HasH264()) {
+              continue;
+            }
+          } else if (mCapabilities[i].mAPIName.EqualsLiteral(GMP_API_AUDIO_DECODER)) {
+            if (!WMFDecoderModule::HasAAC()) {
+              continue;
+            }
+          }
+        }
+#endif
         return true;
       }
     }
   }
   return false;
 }
 
 bool
@@ -883,35 +900,16 @@ GMPParent::ReadGMPInfoFile(nsIFile* aFil
       // SSE2 isn't supported.
       if (cap.mAPITags.Contains(NS_LITERAL_CSTRING("com.adobe.primetime")) &&
           !mozilla::supports_sse2()) {
         return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
       }
 #endif // XP_WIN
     }
 
-#ifdef XP_WIN
-    // Clearkey on Windows advertises that it can decode in its GMP info
-    // file, but uses Windows Media Foundation to decode. That's not present
-    // on Windows XP, and on some Vista, Windows N, and KN variants without
-    // certain services packs. So don't add the decoding capability to
-    // gmp-clearkey's GMPParent if it's not going to be able to use WMF to
-    // decode.
-    if (cap.mAPIName.EqualsLiteral(GMP_API_VIDEO_DECODER) &&
-        cap.mAPITags.Contains(NS_LITERAL_CSTRING("org.w3.clearkey")) &&
-        !WMFDecoderModule::HasH264()) {
-      continue;
-    }
-    if (cap.mAPIName.EqualsLiteral(GMP_API_AUDIO_DECODER) &&
-        cap.mAPITags.Contains(NS_LITERAL_CSTRING("org.w3.clearkey")) &&
-        !WMFDecoderModule::HasAAC()) {
-      continue;
-    }
-#endif
-
     mCapabilities.AppendElement(Move(cap));
   }
 
   if (mCapabilities.IsEmpty()) {
     return GenericPromise::CreateAndReject(NS_ERROR_FAILURE, __func__);
   }
 
   return GenericPromise::CreateAndResolve(true, __func__);