From e2de194bbff5d7c1dd5fe2a068bd016e77a33489 Mon Sep 17 00:00:00 2001 From: Chris Pearce Date: Tue, 12 Feb 2019 15:56:08 +1300 Subject: [PATCH] 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 --HG-- extra : source : b5f5996f7225be2ae56d38f7f8833ca200743acb extra : histedit_source : d831a00887ab8932fd001a511b0559a76fa832b7 --- toolkit/modules/GMPInstallManager.jsm | 4 +++- toolkit/modules/GMPUtils.jsm | 10 ++++++++++ toolkit/mozapps/extensions/internal/GMPProvider.jsm | 7 +++---- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/toolkit/modules/GMPInstallManager.jsm b/toolkit/modules/GMPInstallManager.jsm index b4f36210912b..ab76048f8544 100644 --- a/toolkit/modules/GMPInstallManager.jsm +++ b/toolkit/modules/GMPInstallManager.jsm @@ -430,7 +430,9 @@ GMPDownloader.prototype = { // 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, diff --git a/toolkit/modules/GMPUtils.jsm b/toolkit/modules/GMPUtils.jsm index e81a44c7d300..7dcb046e5513 100644 --- a/toolkit/modules/GMPUtils.jsm +++ b/toolkit/modules/GMPUtils.jsm @@ -100,6 +100,16 @@ var GMPUtils = { _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; + }, }; /** diff --git a/toolkit/mozapps/extensions/internal/GMPProvider.jsm b/toolkit/mozapps/extensions/internal/GMPProvider.jsm index 91582f616f27..ddfaeba824d6 100644 --- a/toolkit/mozapps/extensions/internal/GMPProvider.jsm +++ b/toolkit/mozapps/extensions/internal/GMPProvider.jsm @@ -16,9 +16,7 @@ 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"); @@ -530,9 +528,10 @@ GMPWrapper.prototype = { }; } - 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 {