Commit d5b432c3 authored by Mark Mentovai's avatar Mark Mentovai Committed by Commit Bot

mac-arm64: Have Rosetta pre-translate modules for Widevine

In order to avoid a delay (15 seconds is typical) the first time the
Widevine CDM is loaded, ask Rosetta to translate the Widevine CDM and
other required modules when Widevine is first registered. This happens
at browser launch, and probably also when Widevine is component-updated.

Bug: 1142017, 1145672, 1145792
Change-Id: If5e52f7e08e987dc5da57dd0b1476d25a467b152
CQ-Include-Trybots: luci.chromium.try:mac-arm64-rel
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2533506
Auto-Submit: Mark Mentovai <mark@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826796}
parent d1c76ab9
......@@ -21,6 +21,7 @@
#include "base/logging.h"
#include "base/memory/ref_counted.h"
#include "base/native_library.h"
#include "base/path_service.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "base/task/thread_pool.h"
......@@ -34,6 +35,7 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/cdm_registry.h"
#include "content/public/common/cdm_info.h"
#include "content/public/common/content_paths.h"
#include "crypto/sha2.h"
#include "third_party/widevine/cdm/buildflags.h"
#include "third_party/widevine/cdm/widevine_cdm_common.h"
......@@ -337,6 +339,38 @@ void WidevineCdmComponentInstallerPolicy::UpdateCdmPath(
// be guaranteed by VerifyInstallation succeeding.
if (launch_x86_64) {
DCHECK(base::mac::IsRosettaInstalled());
// To avoid a long delay (15 seconds observed is typical) when first loading
// the Widevine CDM under Rosetta, submit required modules for ahead-of-time
// translation. The necessary modules are:
// - the helper executable to launch,
// - the framework that contains the vast majority of the code, and
// - the Widevine CDM library itself.
// If Rosetta’s translation cache for these modules is already current, they
// will not be re-translated. If anything requires translation, it will
// still be time-consuming, but it’ll happen on a background thread without
// bothering the user, hopefully before the user needs to use them. If these
// modules are needed before the translation is complete, translation will
// at least have had a head start.
std::vector<base::FilePath> rosetta_translate_paths;
base::FilePath helper_path;
if (base::PathService::Get(content::CHILD_PROCESS_EXE, &helper_path)) {
rosetta_translate_paths.push_back(helper_path);
}
base::FilePath framework_path;
if (base::PathService::Get(base::FILE_MODULE, &framework_path)) {
rosetta_translate_paths.push_back(framework_path);
}
rosetta_translate_paths.push_back(cdm_path);
base::ThreadPool::PostTask(
FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
base::BindOnce(base::IgnoreResult(
&base::mac::RequestRosettaAheadOfTimeTranslation),
std::move(rosetta_translate_paths)));
}
#endif // OS_MAC && ARCH_CPU_ARM64
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment