Bug 1288976 - Only retry MediaKeySystemAccess requests on 'gmp-changed' notification if the CDM is now installed. r=gerald
authorChris Pearce <cpearce@mozilla.com>
Mon, 25 Jul 2016 13:38:08 +1200
changeset 346315 05b9ca6b58ec97e6e73941831fe7a881cb70bcd3
parent 346314 9f4d0adc2e73d0e631383934712fd80a0926fd12
child 346316 a735cdff3c900219b00cd7a683e363be9d6562bc
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1288976
milestone50.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1288976 - Only retry MediaKeySystemAccess requests on 'gmp-changed' notification if the CDM is now installed. r=gerald This ensures we'll only retry requests if we know the install operation has completed for a given GMP. This means if (say) OpenH264 happens to install while we have a Widevine request pending, we won't retry the Widevine request, as that would fail. The Widevine request will retry once the Widevine CDM has downloaded and in turn fires its gmp-changed notification. MozReview-Commit-ID: E3CV9uID4pS
dom/media/eme/MediaKeySystemAccessManager.cpp
--- a/dom/media/eme/MediaKeySystemAccessManager.cpp
+++ b/dom/media/eme/MediaKeySystemAccessManager.cpp
@@ -259,17 +259,40 @@ MediaKeySystemAccessManager::RetryReques
 nsresult
 MediaKeySystemAccessManager::Observe(nsISupports* aSubject,
                                      const char* aTopic,
                                      const char16_t* aData)
 {
   EME_LOG("MediaKeySystemAccessManager::Observe %s", aTopic);
 
   if (!strcmp(aTopic, "gmp-changed")) {
-    nsTArray<PendingRequest> requests(Move(mRequests));
+    // Filter out the requests where the CDM's install-status is no longer
+    // "unavailable". This will be the CDMs which have downloaded since the
+    // initial request.
+    // Note: We don't have a way to communicate from chrome that the CDM has
+    // failed to download, so we'll just let the timeout fail us in that case.
+    nsTArray<PendingRequest> requests;
+    for (size_t i = mRequests.Length(); i > 0; i--) {
+      const size_t index = i - i;
+      PendingRequest& request = mRequests[index];
+      nsAutoCString message;
+      nsAutoCString cdmVersion;
+      MediaKeySystemStatus status =
+        MediaKeySystemAccess::GetKeySystemStatus(request.mKeySystem,
+                                                 NO_CDM_VERSION,
+                                                 message,
+                                                 cdmVersion);
+      if (status == MediaKeySystemStatus::Cdm_not_installed) {
+        // Not yet installed, don't retry. Keep waiting until timeout.
+        continue;
+      }
+      // Status has changed, retry request.
+      requests.AppendElement(Move(request));
+      mRequests.RemoveElementAt(index);
+    }
     // Retry all pending requests, but this time fail if the CDM is not installed.
     for (PendingRequest& request : requests) {
       RetryRequest(request);
     }
   } else if (!strcmp(aTopic, "timer-callback")) {
     // Find the timer that expired and re-run the request for it.
     nsCOMPtr<nsITimer> timer(do_QueryInterface(aSubject));
     for (size_t i = 0; i < mRequests.Length(); i++) {