Bug 1527811 - Execute plugin-container.exe for CDM GMP child process in "i686" subdir on Windows on ARM. r=bobowen
authorChris Pearce <cpearce@mozilla.com>
Tue, 12 Feb 2019 15:45:07 +1300
changeset 519570 c1e05d18c18e26802bfe4818a506d24d054a7c3c
parent 519569 9311a433ea1beecdb14b2a25ba98d60fb83a4d8c
child 519571 83b6c1e3d898fa3019621c54a472f9e53eb50047
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbobowen
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 - Execute plugin-container.exe for CDM GMP child process in "i686" subdir on Windows on ARM. r=bobowen This patch assumes that "the build" places plugin-container.exe, xul.dll, and their dependencies in the "i686" subdirectory of the aarch64 firefox package directory. Differential Revision: https://phabricator.services.mozilla.com/D19898
ipc/glue/GeckoChildProcessHost.cpp
--- a/ipc/glue/GeckoChildProcessHost.cpp
+++ b/ipc/glue/GeckoChildProcessHost.cpp
@@ -675,16 +675,26 @@ AddAppDirToCommandLine(std::vector<std::
         aCmdLine.push_back("-profile");
         aCmdLine.push_back(path.get());
       }
 #endif
     }
   }
 }
 
+#ifdef XP_WIN
+static bool Contains(const std::vector<std::string>& aExtraOpts,
+                     const char* aValue) {
+  return std::any_of(aExtraOpts.begin(), aExtraOpts.end(),
+                     [&](const std::string arg) {
+                       return arg.find(aValue) != std::string::npos;
+                     });
+}
+#endif  // XP_WIN
+
 bool GeckoChildProcessHost::PerformAsyncLaunch(
     std::vector<std::string> aExtraOpts) {
 #ifdef MOZ_GECKO_PROFILER
   GetProfilerEnvVarsForChildProcess([this](const char* key, const char* value) {
     mLaunchOptions->env_map[ENVIRONMENT_STRING(key)] =
         ENVIRONMENT_STRING(value);
   });
 #endif
@@ -1003,16 +1013,28 @@ bool GeckoChildProcessHost::PerformAsync
 #  endif  // MOZ_WIDGET_COCOA
 
 //--------------------------------------------------
 #elif defined(OS_WIN)  // defined(OS_POSIX)
 
   FilePath exePath;
   BinaryPathType pathType = GetPathToBinary(exePath, mProcessType);
 
+  const bool isGMP = mProcessType == GeckoProcessType_GMPlugin;
+  const bool isWidevine = isGMP && Contains(aExtraOpts, "gmp-widevinecdm");
+#  if defined(_ARM64_) && defined(XP_WIN)
+  const bool isClearKey = isGMP && Contains(aExtraOpts, "gmp-clearkey");
+  if (isGMP && (isClearKey || isWidevine)) {
+    // On Windows on ARM64 for ClearKey and Widevine, we want to run the
+    // x86 plugin-container.exe in the "i686" subdirectory, instead of the
+    // aarch64 plugin-container.exe. So insert "i686" into the exePath.
+    exePath = exePath.DirName().AppendASCII("i686").Append(exePath.BaseName());
+  }
+#  endif
+
   CommandLine cmdLine(exePath.ToWStringHack());
 
   if (pathType == BinaryPathType::Self) {
     cmdLine.AppendLooseValue(UTF8ToWide("-contentproc"));
   }
 
   cmdLine.AppendSwitchWithValue(switches::kProcessChannelID, channel_id());
 
@@ -1071,20 +1093,16 @@ bool GeckoChildProcessHost::PerformAsync
       // XXX: We don't sandbox this process type yet
       break;
     case GeckoProcessType_GMPlugin:
       if (!PR_GetEnv("MOZ_DISABLE_GMP_SANDBOX")) {
         // The Widevine CDM on Windows can only load at USER_RESTRICTED,
         // not at USER_LOCKDOWN. So look in the command line arguments
         // to see if we're loading the path to the Widevine CDM, and if
         // so use sandbox level USER_RESTRICTED instead of USER_LOCKDOWN.
-        bool isWidevine = std::any_of(
-            aExtraOpts.begin(), aExtraOpts.end(), [](const std::string arg) {
-              return arg.find("gmp-widevinecdm") != std::string::npos;
-            });
         auto level =
             isWidevine ? SandboxBroker::Restricted : SandboxBroker::LockDown;
         bool ok = mSandboxBroker.SetSecurityLevelForGMPlugin(level);
         if (!ok) {
           return false;
         }
         shouldSandboxCurrentProcess = true;
       }