Commit 55fc95f6 authored by Eric Seckler's avatar Eric Seckler Committed by Commit Bot

webview: Replace LITTLE-only cmdline flag with base::Feature

Makes it possible to enable LITTLE-cores-only mode via Finch, by
replacing the existing command line flag with a base::Feature.

It can still be enabled locally by passing
--enable-features=WebViewCpuAffinityRestrictToLittleCores or
enabling the feature in WebView DevTools.

Test: Run WV shell with flag above & check chrome://histograms/Power.
Bug: 1111789
Change-Id: I209b132ccd5354e41849a33bb0509773b619fc62
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2502511
Commit-Queue: Eric Seckler <eseckler@chromium.org>
Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821685}
parent bc2d6383
......@@ -421,11 +421,6 @@ void AwContentBrowserClient::AppendExtraCommandLineSwitches(
::switches::kEnableCrashReporterForTesting)) {
command_line->AppendSwitch(::switches::kEnableCrashReporterForTesting);
}
// Pass WebView's force little cores flag to renderer process.
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
::switches::kWebViewForceLittleCores)) {
command_line->AppendSwitch(::switches::kWebViewForceLittleCores);
}
}
}
......
......@@ -18,6 +18,12 @@ const base::Feature kWebViewBrotliSupport{"WebViewBrotliSupport",
const base::Feature kWebViewConnectionlessSafeBrowsing{
"WebViewConnectionlessSafeBrowsing", base::FEATURE_DISABLED_BY_DEFAULT};
// Restricts WebView child processes to use only LITTLE cores on big.LITTLE
// architectures.
const base::Feature kWebViewCpuAffinityRestrictToLittleCores{
"WebViewCpuAffinityRestrictToLittleCores",
base::FEATURE_DISABLED_BY_DEFAULT};
// Enable display cutout support for Android P and above.
const base::Feature kWebViewDisplayCutout{"WebViewDisplayCutout",
base::FEATURE_DISABLED_BY_DEFAULT};
......
......@@ -16,6 +16,7 @@ namespace features {
// Alphabetical:
extern const base::Feature kWebViewBrotliSupport;
extern const base::Feature kWebViewConnectionlessSafeBrowsing;
extern const base::Feature kWebViewCpuAffinityRestrictToLittleCores;
extern const base::Feature kWebViewDisplayCutout;
extern const base::Feature kWebViewExtraHeadersSameDomainOnly;
extern const base::Feature kWebViewExtraHeadersSameOriginOnly;
......
......@@ -46,7 +46,4 @@ const char kFinchSeedMinDownloadPeriod[] = "finch-seed-min-download-period";
// variations seed.
const char kFinchSeedMinUpdatePeriod[] = "finch-seed-min-update-period";
// Force WebView renderer to run in little cores
const char kWebViewForceLittleCores[] = "webview-force-little-cores";
} // namespace switches
......@@ -17,7 +17,6 @@ extern const char kFinchSeedExpirationAge[];
extern const char kFinchSeedIgnorePendingDownload[];
extern const char kFinchSeedMinDownloadPeriod[];
extern const char kFinchSeedMinUpdatePeriod[];
extern const char kWebViewForceLittleCores[];
} // namespace switches
......
......@@ -96,7 +96,7 @@ public final class ProductionSupportedFlagList {
+ "Elements v0, and HTML Imports)."),
Flag.baseFeature(AwFeatures.WEBVIEW_DISPLAY_CUTOUT,
"Enables display cutout (notch) support in WebView for Android P and above."),
Flag.commandLine(AwSwitches.WEBVIEW_FORCE_LITTLE_CORES,
Flag.baseFeature(AwFeatures.WEBVIEW_CPU_AFFINITY_RESTRICT_TO_LITTLE_CORES,
"Forces WebView to do rendering work in little cores"),
Flag.baseFeature(BlinkFeatures.WEBVIEW_ACCELERATE_SMALL_CANVASES,
"Accelerate all canvases in webview."),
......
......@@ -299,10 +299,6 @@ void AwMainDelegate::PreSandboxStartup() {
if (process_type == switches::kRendererProcess) {
InitResourceBundleRendererSide();
if (command_line.HasSwitch(switches::kWebViewForceLittleCores)) {
content::EnforceProcessCpuAffinity(
base::CpuAffinityMode::kLittleCoresOnly);
}
}
EnableCrashReporter(process_type);
......@@ -373,6 +369,15 @@ void AwMainDelegate::PostFieldTrialInitialization() {
ALLOW_UNUSED_LOCAL(is_canary_dev);
ALLOW_UNUSED_LOCAL(is_browser_process);
// Enable LITTLE-cores only mode if the feature is enabled, but only for child
// processes, as the browser process is shared with the hosting app.
if (!is_browser_process &&
base::FeatureList::IsEnabled(
android_webview::features::
kWebViewCpuAffinityRestrictToLittleCores)) {
content::EnforceProcessCpuAffinity(base::CpuAffinityMode::kLittleCoresOnly);
}
#if BUILDFLAG(ENABLE_GWP_ASAN_MALLOC)
gwp_asan::EnableForMalloc(is_canary_dev || is_browser_process,
process_type.c_str());
......
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