From d06b7de00664032a06f99db3a7eba8094e1e306f Mon Sep 17 00:00:00 2001 From: jj Date: Wed, 9 Jul 2025 22:19:31 +0000 Subject: [PATCH] helium: add flag for setting energy saver fps --- .../core/add-low-power-framerate-flag.patch | 68 +++++++++++++++++++ ...ls.patch => add-update-channel-flag.patch} | 48 ++++--------- patches/helium/core/flags-setup.patch | 37 ++++++++++ patches/series | 4 +- 4 files changed, 123 insertions(+), 34 deletions(-) create mode 100644 patches/helium/core/add-low-power-framerate-flag.patch rename patches/helium/core/{add-update-channels.patch => add-update-channel-flag.patch} (66%) create mode 100644 patches/helium/core/flags-setup.patch diff --git a/patches/helium/core/add-low-power-framerate-flag.patch b/patches/helium/core/add-low-power-framerate-flag.patch new file mode 100644 index 00000000..ce2d8e1c --- /dev/null +++ b/patches/helium/core/add-low-power-framerate-flag.patch @@ -0,0 +1,68 @@ +--- a/chrome/browser/helium_flag_choices.h ++++ b/chrome/browser/helium_flag_choices.h +@@ -7,6 +7,15 @@ + namespace helium { + using namespace ::helium; + ++ constexpr const char kEnergySaverFrameRateCommandLine[] = "energy-saver-fps-limit"; ++ constexpr const FeatureEntry::Choice kEnergySaverFrameRateChoices[] = { ++ {flags_ui::kGenericExperimentChoiceAutomatic, "", ""}, ++ {"30", kEnergySaverFrameRateCommandLine, "30"}, ++ {"60", kEnergySaverFrameRateCommandLine, "60"}, ++ {"120", kEnergySaverFrameRateCommandLine, "120"}, ++ {"Disabled", kEnergySaverFrameRateCommandLine, "9001"}, ++ }; ++ + } // namespace helium + + #endif /* CHROME_BROWSER_HELIUM_FLAG_CHOICES_H_ */ +--- a/chrome/browser/helium_flag_entries.h ++++ b/chrome/browser/helium_flag_entries.h +@@ -1,3 +1,7 @@ + #ifndef CHROME_BROWSER_HELIUM_FLAG_ENTRIES_H_ + #define CHROME_BROWSER_HELIUM_FLAG_ENTRIES_H_ ++ {helium::kEnergySaverFrameRateCommandLine, ++ "Maximum frame rate for Energy Saver", ++ "Configures the frame rate the browser is throttled to when Energy Saver is enabled. Helium flag", ++ kOsDesktop, MULTI_VALUE_TYPE(helium::kEnergySaverFrameRateChoices)}, + #endif /* CHROME_BROWSER_HELIUM_FLAG_ENTRIES_H_ */ +--- a/chrome/browser/performance_manager/user_tuning/battery_saver_mode_manager.cc ++++ b/chrome/browser/performance_manager/user_tuning/battery_saver_mode_manager.cc +@@ -20,6 +20,7 @@ + #include "base/power_monitor/power_observer.h" + #include "base/run_loop.h" + #include "base/scoped_multi_source_observation.h" ++#include "base/strings/string_number_conversions.h" + #include "base/values.h" + #include "components/performance_manager/freezing/freezing_policy.h" + #include "components/performance_manager/performance_manager_impl.h" +@@ -68,12 +69,28 @@ constexpr int kBatterySaverModeThreshold + constexpr int kBatterySaverModeThresholdAdjustmentForDisplayLevel = 0; + #endif // BUILDFLAG(IS_CHROMEOS) + ++int GetMaxRate() { ++ auto* command_line = base::CommandLine::ForCurrentProcess(); ++ int fps; ++ ++ if (command_line->HasSwitch("energy-saver-fps-limit") && ++ base::StringToInt(command_line->GetSwitchValueASCII( ++ "energy-saver-fps-limit"), &fps) && fps > 0) { ++ return fps; ++ } ++ ++ return 30; ++} ++ + class FrameThrottlingDelegateImpl + : public performance_manager::user_tuning::BatterySaverModeManager:: + FrameThrottlingDelegate { + public: + void StartThrottlingAllFrameSinks() override { +- content::StartThrottlingAllFrameSinks(base::Hertz(30)); ++ static int max_rate = GetMaxRate(); ++ if (max_rate < 9000) { ++ content::StartThrottlingAllFrameSinks(base::Hertz(max_rate)); ++ } + } + + void StopThrottlingAllFrameSinks() override { diff --git a/patches/helium/core/add-update-channels.patch b/patches/helium/core/add-update-channel-flag.patch similarity index 66% rename from patches/helium/core/add-update-channels.patch rename to patches/helium/core/add-update-channel-flag.patch index 687ca1e7..b58406d8 100644 --- a/patches/helium/core/add-update-channels.patch +++ b/patches/helium/core/add-update-channel-flag.patch @@ -8,20 +8,6 @@ #include "chrome/browser/devtools/features.h" #include "chrome/browser/flag_descriptions.h" #include "chrome/browser/ip_protection/ip_protection_switches.h" -@@ -4733,11 +4734,13 @@ const FeatureEntry::FeatureVariation kHi - #include "chrome/browser/bromite_flag_choices.h" - #include "chrome/browser/ungoogled_platform_flag_choices.h" - #include "chrome/browser/existing_switch_flag_choices.h" -+#include "chrome/browser/helium_flag_choices.h" - const FeatureEntry kFeatureEntries[] = { - #include "chrome/browser/ungoogled_flag_entries.h" - #include "chrome/browser/bromite_flag_entries.h" - #include "chrome/browser/ungoogled_platform_flag_entries.h" - #include "chrome/browser/existing_switch_flag_entries.h" -+#include "chrome/browser/helium_flag_entries.h" - // Include generated flags for flag unexpiry; see //docs/flag_expiry.md and - // //tools/flags/generate_unexpire_flags.py. - #include "build/chromeos_buildflags.h" --- /dev/null +++ b/chrome/browser/channel_selection.cc @@ -0,0 +1,25 @@ @@ -68,36 +54,32 @@ + +} // namespace helium +#endif /* CHROME_BROWSER_CHANNEL_SELECTION_H_ */ ---- /dev/null +--- a/chrome/browser/helium_flag_choices.h +++ b/chrome/browser/helium_flag_choices.h -@@ -0,0 +1,18 @@ -+#ifndef CHROME_BROWSER_HELIUM_FLAG_CHOICES_H_ -+#define CHROME_BROWSER_HELIUM_FLAG_CHOICES_H_ -+ -+#include "components/webui/flags/feature_entry.h" -+#include "chrome/browser/channel_selection.h" -+ -+namespace helium { -+ using namespace ::helium; -+ +@@ -16,6 +16,12 @@ namespace helium { + {"Disabled", kEnergySaverFrameRateCommandLine, "9001"}, + }; + + constexpr const FeatureEntry::Choice kChannelChoices[] = { + {flags_ui::kGenericExperimentChoiceAutomatic, "", ""}, + {kChannelStable, kChannelCommandLine, kChannelStable}, + {kChannelBeta, kChannelCommandLine, kChannelBeta}, + }; + -+} // namespace helium -+ -+#endif /* CHROME_BROWSER_HELIUM_FLAG_CHOICES_H_ */ ---- /dev/null + } // namespace helium + + #endif /* CHROME_BROWSER_HELIUM_FLAG_CHOICES_H_ */ +--- a/chrome/browser/helium_flag_entries.h +++ b/chrome/browser/helium_flag_entries.h -@@ -0,0 +1,6 @@ -+#ifndef CHROME_BROWSER_HELIUM_FLAG_ENTRIES_H_ -+#define CHROME_BROWSER_HELIUM_FLAG_ENTRIES_H_ +@@ -1,5 +1,8 @@ + #ifndef CHROME_BROWSER_HELIUM_FLAG_ENTRIES_H_ + #define CHROME_BROWSER_HELIUM_FLAG_ENTRIES_H_ + {helium::kChannelCommandLine, + "Update channel", "Selects which update channel to use for update checking. Helium flag.", + kOsAll, MULTI_VALUE_TYPE(helium::kChannelChoices)}, -+#endif /* CHROME_BROWSER_HELIUM_FLAG_ENTRIES_H_ */ + {helium::kEnergySaverFrameRateCommandLine, + "Maximum frame rate for Energy Saver", + "Configures the frame rate the browser is throttled to when Energy Saver is enabled. Helium flag", --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn @@ -281,6 +281,8 @@ static_library("browser") { diff --git a/patches/helium/core/flags-setup.patch b/patches/helium/core/flags-setup.patch new file mode 100644 index 00000000..78292b49 --- /dev/null +++ b/patches/helium/core/flags-setup.patch @@ -0,0 +1,37 @@ +--- a/chrome/browser/about_flags.cc ++++ b/chrome/browser/about_flags.cc +@@ -4733,11 +4733,13 @@ const FeatureEntry::FeatureVariation kHi + #include "chrome/browser/bromite_flag_choices.h" + #include "chrome/browser/ungoogled_platform_flag_choices.h" + #include "chrome/browser/existing_switch_flag_choices.h" ++#include "chrome/browser/helium_flag_choices.h" + const FeatureEntry kFeatureEntries[] = { + #include "chrome/browser/ungoogled_flag_entries.h" + #include "chrome/browser/bromite_flag_entries.h" + #include "chrome/browser/ungoogled_platform_flag_entries.h" + #include "chrome/browser/existing_switch_flag_entries.h" ++#include "chrome/browser/helium_flag_entries.h" + // Include generated flags for flag unexpiry; see //docs/flag_expiry.md and + // //tools/flags/generate_unexpire_flags.py. + #include "build/chromeos_buildflags.h" +--- /dev/null ++++ b/chrome/browser/helium_flag_choices.h +@@ -0,0 +1,12 @@ ++#ifndef CHROME_BROWSER_HELIUM_FLAG_CHOICES_H_ ++#define CHROME_BROWSER_HELIUM_FLAG_CHOICES_H_ ++ ++#include "components/webui/flags/feature_entry.h" ++#include "chrome/browser/channel_selection.h" ++ ++namespace helium { ++ using namespace ::helium; ++ ++} // namespace helium ++ ++#endif /* CHROME_BROWSER_HELIUM_FLAG_CHOICES_H_ */ +--- /dev/null ++++ b/chrome/browser/helium_flag_entries.h +@@ -0,0 +1,3 @@ ++#ifndef CHROME_BROWSER_HELIUM_FLAG_ENTRIES_H_ ++#define CHROME_BROWSER_HELIUM_FLAG_ENTRIES_H_ ++#endif /* CHROME_BROWSER_HELIUM_FLAG_ENTRIES_H_ */ diff --git a/patches/series b/patches/series index 5751a8a3..3c79adfc 100644 --- a/patches/series +++ b/patches/series @@ -144,7 +144,9 @@ helium/core/hide-extensions-via-toolbar-prefs.patch helium/core/clean-context-menu.patch helium/core/split-view.patch helium/core/fix-tab-sync-unreached-error.patch -helium/core/add-update-channels.patch +helium/core/flags-setup.patch +helium/core/add-low-power-framerate-flag.patch +helium/core/add-update-channel-flag.patch helium/core/add-updater-preference.patch helium/settings/move-search-suggest.patch