Bug 1527811 - Ensure we write the ABI of the GMP we expect to have installed. r=Gijs
authorChris Pearce <cpearce@mozilla.com>
Tue, 12 Feb 2019 15:56:08 +1300
changeset 461691 ad0dfa4133e60c498598f52b8a9307e8f2307584
parent 461690 aae2bb67624e50f6628306cbd3a2099928161bca
child 461692 4afca6b3252ee9a327eaf3c2ecfdaaf432025621
push id35626
push usercsabou@mozilla.com
push dateThu, 28 Feb 2019 11:31:08 +0000
treeherdermozilla-central@2ea0c1db7e60 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1527811
milestone67.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 1527811 - Ensure we write the ABI of the GMP we expect to have installed. r=Gijs We write the ABI of the plugin we installed to preferences so that if the ABI stored in the profile of a previously installed plugin differs to the ABI of the Firefox build we're runnning, we can uninstall the plugin and re-install one with the correct ABI. Since we're downloading a plugin of a different ABI than the parent process, we need to modify the ABI written to preferences here. This mechanism was added to handle Firefox profiles transitioning from running in an x86 Firefox to an x64 Firefox on Windows. We can use the same mechanism to handle transitioning from an x86 to aarch64 Widevine here. When we eventually get an aarch64 version of Widevine, we can rollback this changeset, and the ABI mismatch will be detected, and we'll uninstall the x86 CDM, and download the new aarch64 CDM. Differential Revision: https://phabricator.services.mozilla.com/D19901
toolkit/modules/GMPInstallManager.jsm
toolkit/modules/GMPUtils.jsm
toolkit/mozapps/extensions/internal/GMPProvider.jsm
--- a/toolkit/modules/GMPInstallManager.jsm
+++ b/toolkit/modules/GMPInstallManager.jsm
@@ -425,17 +425,19 @@ GMPDownloader.prototype = {
       let installPromise = gmpInstaller.install();
       return installPromise.then(extractedPaths => {
         // Success, set the prefs
         let now = Math.round(Date.now() / 1000);
         GMPPrefs.setInt(GMPPrefs.KEY_PLUGIN_LAST_UPDATE, now, gmpAddon.id);
         // Remember our ABI, so that if the profile is migrated to another
         // platform or from 32 -> 64 bit, we notice and don't try to load the
         // unexecutable plugin library.
-        GMPPrefs.setString(GMPPrefs.KEY_PLUGIN_ABI, UpdateUtils.ABI, gmpAddon.id);
+        let abi = GMPUtils._expectedABI(gmpAddon);
+        log.info("Setting ABI to '" + abi + "' for " + gmpAddon.id);
+        GMPPrefs.setString(GMPPrefs.KEY_PLUGIN_ABI, abi, gmpAddon.id);
         // Setting the version pref signals installation completion to consumers,
         // if you need to set other prefs etc. do it before this.
         GMPPrefs.setString(GMPPrefs.KEY_PLUGIN_VERSION, gmpAddon.version,
                            gmpAddon.id);
         return extractedPaths;
       });
     });
   },
--- a/toolkit/modules/GMPUtils.jsm
+++ b/toolkit/modules/GMPUtils.jsm
@@ -95,16 +95,26 @@ var GMPUtils = {
    */
   _isPluginForceSupported(aPlugin) {
     return GMPPrefs.getBool(GMPPrefs.KEY_PLUGIN_FORCE_SUPPORTED, false, aPlugin.id);
   },
 
   _isWindowsOnARM64() {
     return AppConstants.platform == "win" && UpdateUtils.ABI.match(/aarch64/);
   },
+
+  _expectedABI(aPlugin) {
+    let defaultABI = UpdateUtils.ABI;
+    if (aPlugin.id == WIDEVINE_ID && this._isWindowsOnARM64()) {
+      // On Windows on aarch64, we need the x86 plugin,
+      // as there's no native aarch64 plugins yet.
+      defaultABI = defaultABI.replace(/aarch64/g, "x86");
+    }
+    return defaultABI;
+  },
 };
 
 /**
  * Manages preferences for GMP addons
  */
 var GMPPrefs = {
   KEY_EME_ENABLED:              "media.eme.enabled",
   KEY_PLUGIN_ENABLED:           "media.{0}.enabled",
--- a/toolkit/mozapps/extensions/internal/GMPProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/GMPProvider.jsm
@@ -11,19 +11,17 @@ const {AddonManager, AddonManagerPrivate
 /* globals AddonManagerPrivate*/
 const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 const {OS} = ChromeUtils.import("resource://gre/modules/osfile.jsm");
 /* globals OS*/
 const {Log} = ChromeUtils.import("resource://gre/modules/Log.jsm");
 // These symbols are, unfortunately, accessed via the module global from
 // tests, and therefore cannot be lexical definitions.
 var {GMPPrefs, GMPUtils, OPEN_H264_ID, WIDEVINE_ID} = ChromeUtils.import("resource://gre/modules/GMPUtils.jsm");
-/* globals GMP_PLUGIN_IDS, GMPPrefs, GMPUtils, OPEN_H264_ID, WIDEVINE_ID */
 const {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
-const {UpdateUtils} = ChromeUtils.import("resource://gre/modules/UpdateUtils.jsm");
 
 ChromeUtils.defineModuleGetter(
   this, "GMPInstallManager", "resource://gre/modules/GMPInstallManager.jsm");
 ChromeUtils.defineModuleGetter(
   this, "setTimeout", "resource://gre/modules/Timer.jsm");
 
 const URI_EXTENSION_STRINGS  = "chrome://mozapps/locale/extensions/extensions.properties";
 
@@ -525,19 +523,20 @@ GMPWrapper.prototype = {
     if (!this.isInstalled) {
       // Not installed -> Valid.
       return {
         installed: false,
         valid: true,
       };
     }
 
-    let abi = GMPPrefs.getString(GMPPrefs.KEY_PLUGIN_ABI, UpdateUtils.ABI,
+    let expectedABI = GMPUtils._expectedABI(this._plugin);
+    let abi = GMPPrefs.getString(GMPPrefs.KEY_PLUGIN_ABI, expectedABI,
                                  this._plugin.id);
-    if (abi != UpdateUtils.ABI) {
+    if (abi != expectedABI) {
       // ABI doesn't match. Possibly this is a profile migrated across platforms
       // or from 32 -> 64 bit.
       return {
         installed: true,
         mismatchedABI: true,
         valid: false,
       };
     }