Set the screen frame rate to 60 Hz: added switch in settings (#2336 #1538)

This commit is contained in:
Carmelo Messina
2025-10-09 11:33:09 +02:00
parent b2824377c3
commit 04ddfbf174
2 changed files with 84 additions and 11 deletions
@@ -8,10 +8,10 @@ License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html
---
chrome/android/chrome_java_resources.gni | 2 +-
.../android/java/res/xml/main_preferences.xml | 4 +-
.../res/xml/privacy_preferences_cromite.xml | 191 ++++++++++++++++++
.../res/xml/privacy_preferences_cromite.xml | 197 ++++++++++++++++++
.../privacy/settings/PrivacySettings.java | 6 +-
.../Cromite-settings-ui.grdp | 15 ++
5 files changed, 213 insertions(+), 5 deletions(-)
5 files changed, 219 insertions(+), 5 deletions(-)
create mode 100644 chrome/android/java/res/xml/privacy_preferences_cromite.xml
create mode 100644 chrome/browser/ui/android/strings/cromite_android_chrome_strings_grd/Cromite-settings-ui.grdp
@@ -52,7 +52,7 @@ diff --git a/chrome/android/java/res/xml/privacy_preferences_cromite.xml b/chrom
new file mode 100644
--- /dev/null
+++ b/chrome/android/java/res/xml/privacy_preferences_cromite.xml
@@ -0,0 +1,191 @@
@@ -0,0 +1,197 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+Copyright 2022 The Chromium Authors
+Use of this source code is governed by a BSD-style license that can be
@@ -108,6 +108,12 @@ new file mode 100644
+ android:key="can_make_payment"
+ android:title="@string/can_make_payment_title"
+ android:summary="@string/settings_can_make_payment_toggle_label" />
+ <org.chromium.components.browser_ui.settings.ChromeSwitchPreference
+ android:key="throttle_main_thread_to_60hz"
+ android:title="@string/throttle_main_thread_to_60hz_title"
+ android:summary="@string/throttle_main_thread_to_60hz_summary"
+ app:featureName="throttle-main-thread-to-60hz"
+ app:needRestart="true" />
+
+ <PreferenceCategory
+ android:title="@string/data_exposed_to_device_section_title"/>
@@ -9,9 +9,12 @@ The feature can be disabled using the throttle-main-thread-to-60hz flag (enabled
License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html
---
cc/base/features.cc | 2 ++
cc/base/features.cc | 5 ++---
cc/scheduler/scheduler_state_machine.cc | 17 +++++++++++++++++
.../java/res/xml/privacy_preferences.xml | 6 ++++++
chrome/browser/about_flags.cc | 6 +++---
.../browser/chrome_content_browser_client.cc | 11 +++++++++++
.../Set-the-screen-frame-rate-to-60-Hz.grdp | 9 +++++++++
components/viz/common/features.cc | 1 +
.../common/frame_sinks/begin_frame_source.cc | 14 +++++++++++++-
.../common/frame_sinks/begin_frame_source.h | 1 +
@@ -19,21 +22,27 @@ License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html
.../external_begin_frame_source_android.cc | 13 +++++++++++++
.../external_begin_frame_source_android.h | 2 ++
.../root_compositor_frame_sink_impl.cc | 10 ++++++++--
.../Set-the-screen-frame-rate-to-60-Hz.inc | 7 +++++++
.../renderer/core/animation/animation_clock.cc | 11 ++++++++---
11 files changed, 92 insertions(+), 8 deletions(-)
15 files changed, 117 insertions(+), 14 deletions(-)
create mode 100644 chrome/browser/ui/android/strings/cromite_android_chrome_strings_grd/Set-the-screen-frame-rate-to-60-Hz.grdp
create mode 100644 cromite_flags/chrome/browser/about_flags_cc/Set-the-screen-frame-rate-to-60-Hz.inc
diff --git a/cc/base/features.cc b/cc/base/features.cc
--- a/cc/base/features.cc
+++ b/cc/base/features.cc
@@ -168,6 +168,7 @@ BASE_FEATURE(kInitImageDecodeLastUseTime,
BASE_FEATURE(kThrottleMainFrameTo60Hz,
"ThrottleMainFrameTo60Hz",
base::FEATURE_DISABLED_BY_DEFAULT);
+SET_CROMITE_FEATURE_ENABLED(kThrottleMainFrameTo60Hz);
@@ -165,9 +165,7 @@ BASE_FEATURE(kInitImageDecodeLastUseTime,
"InitImageDecodeLastUseTime",
base::FEATURE_ENABLED_BY_DEFAULT);
-BASE_FEATURE(kThrottleMainFrameTo60Hz,
- "ThrottleMainFrameTo60Hz",
- base::FEATURE_DISABLED_BY_DEFAULT);
+CROMITE_FEATURE(kThrottleMainFrameTo60Hz, "ThrottleMainFrameTo60Hz", base::FEATURE_ENABLED_BY_DEFAULT);
void SetIsEligibleForThrottleMainFrameTo60Hz(bool is_eligible) {
s_is_eligible_for_throttle_main_frame_to_60hz.store(
@@ -197,6 +198,7 @@ BASE_FEATURE(kRenderThrottleFrameRate,
@@ -197,6 +195,7 @@ BASE_FEATURE(kRenderThrottleFrameRate,
base::FEATURE_ENABLED_BY_DEFAULT);
const base::FeatureParam<int> kRenderThrottledFrameIntervalHz{
&kRenderThrottleFrameRate, "render-throttled-frame-interval-hz", 30};
@@ -75,6 +84,38 @@ diff --git a/cc/scheduler/scheduler_state_machine.cc b/cc/scheduler/scheduler_st
if (!throttle_frame_rate_) {
return main_frame_throttled_interval_;
} else {
diff --git a/chrome/android/java/res/xml/privacy_preferences.xml b/chrome/android/java/res/xml/privacy_preferences.xml
--- a/chrome/android/java/res/xml/privacy_preferences.xml
+++ b/chrome/android/java/res/xml/privacy_preferences.xml
@@ -104,6 +104,12 @@ found in the LICENSE file.
android:summary="@string/tab_switcher_list_mode_summary"
app:featureName="TabSwitcherListMode"
app:needRestart="true" />
+ <org.chromium.components.browser_ui.settings.ChromeSwitchPreference
+ android:key="throttle_main_thread_to_60hz"
+ android:title="@string/throttle_main_thread_to_60hz_title"
+ android:summary="@string/throttle_main_thread_to_60hz_summary"
+ app:featureName="throttle-main-thread-to-60hz"
+ app:needRestart="true" />
<PreferenceCategory
android:key="security_section"
android:title="@string/security_section_title" />
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -12031,9 +12031,9 @@ const FeatureEntry kFeatureEntries[] = {
FEATURE_VALUE_TYPE(::features::kBlockRootWindowAccessibleNameChangeEvent)},
#endif // BUILDFLAG(IS_MAC)
- {"throttle-main-thread-to-60hz", flag_descriptions::kThrottleMainTo60HzName,
- flag_descriptions::kThrottleMainTo60HzDescription, kOsAll,
- FEATURE_VALUE_TYPE(features::kThrottleMainFrameTo60Hz)},
+ // {"throttle-main-thread-to-60hz", flag_descriptions::kThrottleMainTo60HzName,
+ // flag_descriptions::kThrottleMainTo60HzDescription, kOsAll,
+ // FEATURE_VALUE_TYPE(features::kThrottleMainFrameTo60Hz)},
{"client-side-detection-brand-and-page-intent",
flag_descriptions::kClientSideDetectionBrandAndIntentForScamDetectionName,
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -110,6 +151,20 @@ diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/ch
if (process_type == switches::kRendererProcess) {
content::RenderProcessHost* process =
content::RenderProcessHost::FromID(child_process_id);
diff --git a/chrome/browser/ui/android/strings/cromite_android_chrome_strings_grd/Set-the-screen-frame-rate-to-60-Hz.grdp b/chrome/browser/ui/android/strings/cromite_android_chrome_strings_grd/Set-the-screen-frame-rate-to-60-Hz.grdp
new file mode 100644
--- /dev/null
+++ b/chrome/browser/ui/android/strings/cromite_android_chrome_strings_grd/Set-the-screen-frame-rate-to-60-Hz.grdp
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<grit-part>
+ <message name="IDS_THROTTLE_MAIN_THREAD_TO_60HZ_TITLE" desc="Text for 'Allow custom tab intents' settings-privacy option.">
+ Throttle frame rate to 60hz
+ </message>
+ <message name="IDS_THROTTLE_MAIN_THREAD_TO_60HZ_SUMMARY" desc="Summary text for 'Allow custom tab intents' settings-privacy option.">
+ Throttle compositor frame rate to 60fps, even when VSync rate is higher.
+ </message>
+</grit-part>
diff --git a/components/viz/common/features.cc b/components/viz/common/features.cc
--- a/components/viz/common/features.cc
+++ b/components/viz/common/features.cc
@@ -288,6 +343,18 @@ diff --git a/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.
if (decided_display_interval_ == interval) {
return;
}
diff --git a/cromite_flags/chrome/browser/about_flags_cc/Set-the-screen-frame-rate-to-60-Hz.inc b/cromite_flags/chrome/browser/about_flags_cc/Set-the-screen-frame-rate-to-60-Hz.inc
new file mode 100644
--- /dev/null
+++ b/cromite_flags/chrome/browser/about_flags_cc/Set-the-screen-frame-rate-to-60-Hz.inc
@@ -0,0 +1,7 @@
+#ifdef FLAG_SECTION
+
+ {"throttle-main-thread-to-60hz", "Throttle frame rate to 60hz",
+ "Throttle compositor frame rate to 60fps, even when VSync rate is higher.", kOsAll,
+ FEATURE_VALUE_TYPE(features::kThrottleMainFrameTo60Hz)},
+
+#endif
diff --git a/third_party/blink/renderer/core/animation/animation_clock.cc b/third_party/blink/renderer/core/animation/animation_clock.cc
--- a/third_party/blink/renderer/core/animation/animation_clock.cc
+++ b/third_party/blink/renderer/core/animation/animation_clock.cc