Files
cromite/build/patches/Enable-HighEfficiencyMode-by-default.patch
T
Carmelo Messina 12db4054a0 Enable HighEfficiencyMode by default: activation of auto freeze in background tabs with high CPU consumption.
Only valid for desktop platform: activation of auto freeze in
background tabs with high CPU consumption, which is not visible from
the ui and therefore not user controllable.
The feature is controlled by the "freezing-without-battery-saver" flag
active by default.
2024-10-09 17:21:36 +02:00

134 lines
6.9 KiB
Diff

From: uazo <uazo@users.noreply.github.com>
Date: Wed, 28 Dec 2022 15:47:58 +0000
Subject: Enable HighEfficiencyMode by default
Only valid for desktop platform: activation of auto freeze in
background tabs with high CPU consumption, which is not visible from
the ui and therefore not user controllable.
The feature is controlled by the "freezing-without-battery-saver" flag
active by default.
License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html
---
components/performance_manager/features.cc | 6 ++++++
.../performance_manager/freezing/freezing_policy.cc | 4 ++--
components/performance_manager/public/features.h | 3 +++
components/performance_manager/user_tuning/prefs.cc | 6 +++---
.../browser/renderer_host/page_lifecycle_state_manager.cc | 8 ++++++++
.../Enable-freeze-high-cpu-background-usage.inc | 8 ++++++++
6 files changed, 30 insertions(+), 5 deletions(-)
create mode 100644 cromite_flags/chrome/browser/about_flags_cc/Enable-freeze-high-cpu-background-usage.inc
diff --git a/components/performance_manager/features.cc b/components/performance_manager/features.cc
--- a/components/performance_manager/features.cc
+++ b/components/performance_manager/features.cc
@@ -154,6 +154,7 @@ const base::FeatureParam<int> kThresholdChromeCPUPercent{
BASE_FEATURE(kCPUMeasurementInFreezingPolicy,
"CPUMeasurementInFreezingPolicy",
base::FEATURE_DISABLED_BY_DEFAULT);
+SET_CROMITE_FEATURE_ENABLED(kCPUMeasurementInFreezingPolicy);
// Note: This param is associated with `kCPUMeasurementInFreezingPolicy` instead
// of `kFreezingOnBatterySaver`, to allow retrieving the value without
@@ -170,8 +171,13 @@ BASE_FEATURE(kFreezingOnBatterySaverForTesting,
"FreezingOnBatterySaverForTesting",
base::FEATURE_DISABLED_BY_DEFAULT);
+CROMITE_FEATURE(kFreezingWithoutBatterySaver,
+ "FreezingWithoutBatterySaver",
+ base::FEATURE_ENABLED_BY_DEFAULT);
+
BASE_FEATURE(kResourceAttributionIncludeOrigins,
"ResourceAttributionIncludeOrigins",
base::FEATURE_DISABLED_BY_DEFAULT);
+SET_CROMITE_FEATURE_ENABLED(kResourceAttributionIncludeOrigins);
} // namespace performance_manager::features
diff --git a/components/performance_manager/freezing/freezing_policy.cc b/components/performance_manager/freezing/freezing_policy.cc
--- a/components/performance_manager/freezing/freezing_policy.cc
+++ b/components/performance_manager/freezing/freezing_policy.cc
@@ -193,11 +193,11 @@ void FreezingPolicy::UpdateFrozenState(
const BrowsingInstanceState& browsing_instance_state = it->second;
if (browsing_instance_state.cpu_intensive_in_background &&
- is_battery_saver_active_ &&
+ (base::FeatureList::IsEnabled(features::kFreezingWithoutBatterySaver) || (is_battery_saver_active_ &&
// Note: Feature state is checked last so that only clients that
// have a browsing instance that is CPU intensive in background
// while Battery Saver is active are enrolled in the experiment.
- base::FeatureList::IsEnabled(features::kFreezingOnBatterySaver)) {
+ base::FeatureList::IsEnabled(features::kFreezingOnBatterySaver))) ) {
eligible_for_freezing_on_battery_saver = true;
}
diff --git a/components/performance_manager/public/features.h b/components/performance_manager/public/features.h
--- a/components/performance_manager/public/features.h
+++ b/components/performance_manager/public/features.h
@@ -160,6 +160,9 @@ BASE_DECLARE_FEATURE(kFreezingOnBatterySaver);
// - Pretend that all tabs have high CPU usage in background.
BASE_DECLARE_FEATURE(kFreezingOnBatterySaverForTesting);
+// activates freezing of tabs with high background cpu usage
+BASE_DECLARE_FEATURE(kFreezingWithoutBatterySaver);
+
// When enabled, Resource Attribution measurements will include contexts for
// individual origins.
BASE_DECLARE_FEATURE(kResourceAttributionIncludeOrigins);
diff --git a/components/performance_manager/user_tuning/prefs.cc b/components/performance_manager/user_tuning/prefs.cc
--- a/components/performance_manager/user_tuning/prefs.cc
+++ b/components/performance_manager/user_tuning/prefs.cc
@@ -21,18 +21,18 @@
namespace performance_manager::user_tuning::prefs {
void RegisterLocalStatePrefs(PrefRegistrySimple* registry) {
- registry->RegisterBooleanPref(kMemorySaverModeEnabled, false);
+ registry->RegisterBooleanPref(kMemorySaverModeEnabled, true);
registry->RegisterIntegerPref(
kMemorySaverModeTimeBeforeDiscardInMinutes,
kDefaultMemorySaverModeTimeBeforeDiscardInMinutes);
registry->RegisterIntegerPref(
- kMemorySaverModeState, static_cast<int>(MemorySaverModeState::kDisabled));
+ kMemorySaverModeState, static_cast<int>(MemorySaverModeState::kEnabled));
registry->RegisterIntegerPref(
kMemorySaverModeAggressiveness,
static_cast<int>(MemorySaverModeAggressiveness::kMedium));
registry->RegisterIntegerPref(
kBatterySaverModeState,
- static_cast<int>(BatterySaverModeState::kEnabledBelowThreshold));
+ static_cast<int>(BatterySaverModeState::kDisabled));
registry->RegisterTimePref(kLastBatteryUseTimestamp, base::Time());
registry->RegisterBooleanPref(kDiscardRingTreatmentEnabled, true);
registry->RegisterBooleanPref(kPerformanceInterventionNotificationEnabled,
diff --git a/content/browser/renderer_host/page_lifecycle_state_manager.cc b/content/browser/renderer_host/page_lifecycle_state_manager.cc
--- a/content/browser/renderer_host/page_lifecycle_state_manager.cc
+++ b/content/browser/renderer_host/page_lifecycle_state_manager.cc
@@ -77,6 +77,14 @@ void PageLifecycleStateManager::SetFrameTreeVisibility(
return;
frame_tree_visibility_ = visibility;
+ if (visibility == blink::mojom::PageVisibilityState::kVisible) {
+ // Unset `frozen_explicitly_` when the page is shown, to reflect that the
+ // Blink page scheduler unfreezes the page in that situation. This ensures
+ // that the page is frozen if SetIsFrozen(true) is called while the page is
+ // hidden in the future (SetIsFrozen(true) no-ops if `frozen_explicitly_` is
+ // true).
+ is_set_frozen_called_ = false;
+ }
SendUpdatesToRendererIfNeeded(
/*page_restore_params=*/nullptr, base::NullCallback());
// TODO(yuzus): When a page is frozen and made visible, the page should
diff --git a/cromite_flags/chrome/browser/about_flags_cc/Enable-freeze-high-cpu-background-usage.inc b/cromite_flags/chrome/browser/about_flags_cc/Enable-freeze-high-cpu-background-usage.inc
new file mode 100644
--- /dev/null
+++ b/cromite_flags/chrome/browser/about_flags_cc/Enable-freeze-high-cpu-background-usage.inc
@@ -0,0 +1,8 @@
+#ifdef FLAG_SECTION
+
+ {"freezing-without-battery-saver",
+ "Freeze Tab Without Battery Saver enabled",
+ "Activates freezing of tabs with high background cpu usage.", kOsDesktop,
+ FEATURE_VALUE_TYPE(performance_manager::features::kFreezingWithoutBatterySaver)},
+
+#endif
--