Bug 1270968 - Add mechanism to clear GMP storage when its version changes. r?gerald draft
authorChris Pearce <cpearce@mozilla.com>
Sat, 07 May 2016 09:19:15 +1200
changeset 364553 b66a162ca51371d1bc8088c8a3890312c47f30cc
parent 364352 19a1743ceb2e035e571012e88d25275ce627b925
child 520316 4b85518e09053de126889536afb70563a0ec388d
push id17489
push usercpearce@mozilla.com
push dateFri, 06 May 2016 21:20:18 +0000
reviewersgerald
bugs1270968, 1264497
milestone49.0a1
Bug 1270968 - Add mechanism to clear GMP storage when its version changes. r?gerald In bug 1264497 we discovered that Netflix was broken because we'd made a change to not send the Adobe GMP the device bound nodeId, which it stored in GMP storage. When the GMP was comparing the nodeId it had stored against what it was passed (nothing) the comparison was failing. Users could have worked around this problem by clearing their GMP storage, whereupon the Adobe GMP will have stored "nothing" as its nodeId. When bug 1264497 was fixed, users who'd cleared their storage will see Netflix fail again, as their stored nodeId of "nothing" will again not match what we pass in. So to fix Netflix for these users, we need to clear GMP storage. This is another instance of a more general problem that we have occasionally encountered, namely that sometimes GMP storage becomes incompatible, and we need to clear it. Having a general mechanism that we can use to clear storage remotely will be helpful, so this patch adds one, and triggers it to fire. This mechanism is pref controlled, so that we can issue a hotfix if necessary to clear GMP storage. MozReview-Commit-ID: GzSyBj0P2JG
dom/media/gmp/GMPServiceParent.cpp
modules/libpref/init/all.js
--- a/dom/media/gmp/GMPServiceParent.cpp
+++ b/dom/media/gmp/GMPServiceParent.cpp
@@ -141,17 +141,30 @@ GeckoMediaPluginServiceParent::Init()
 
   nsresult rv = InitStorage();
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   // Kick off scanning for plugins
   nsCOMPtr<nsIThread> thread;
-  return GetThread(getter_AddRefs(thread));
+  rv = GetThread(getter_AddRefs(thread));
+  if (NS_FAILED(rv)) {
+    return rv;
+  }
+
+  // Detect if GMP storage has an incompatible version, and if so nuke it.
+  int32_t version = Preferences::GetInt("media.gmp.storage.version.observed", 0);
+  int32_t expected = Preferences::GetInt("media.gmp.storage.version.expected", 0);
+  if (version != expected) {
+    Preferences::SetInt("media.gmp.storage.version.observed", expected);
+    return GMPDispatch(NewRunnableMethod(
+      this, &GeckoMediaPluginServiceParent::ClearStorage));
+  }
+  return NS_OK;
 }
 
 already_AddRefed<nsIFile>
 CloneAndAppend(nsIFile* aFile, const nsAString& aDir)
 {
   nsCOMPtr<nsIFile> f;
   nsresult rv = aFile->Clone(getter_AddRefs(f));
   if (NS_WARN_IF(NS_FAILED(rv))) {
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -347,16 +347,23 @@ pref("media.webm.intel_decoder.enabled",
 #ifdef MOZ_APPLEMEDIA
 #ifdef MOZ_WIDGET_UIKIT
 pref("media.mp3.enabled", true);
 #endif
 pref("media.apple.mp3.enabled", true);
 pref("media.apple.mp4.enabled", true);
 #endif
 
+// GMP storage version number. At startup we check the version against
+// media.gmp.storage.version.observed, and if the versions don't match,
+// we clear storage and set media.gmp.storage.version.observed=expected.
+// This provides a mechanism to clear GMP storage when non-compatible
+// changes are made.
+pref("media.gmp.storage.version.expected", 1);
+
 // Filter what triggers user notifications.
 // See DecoderDoctorDocumentWatcher::ReportAnalysis for details.
 pref("media.decoder-doctor.notifications-allowed", "MediaWidevineNoWMFNoSilverlight");
 // Whether we report partial failures.
 pref("media.decoder-doctor.verbose", false);
 
 #ifdef MOZ_WEBRTC
 pref("media.navigator.enabled", true);