Files
cromite/build/patches/Set-the-screen-frame-rate-to-60-Hz.patch
T
Carmelo Messina 865e06194d Set the screen frame rate to 60 Hz: temporarily disabled in Android
Due to issues detected in #2336, changes in Android require further investigation. A revert to the Chromium version is performed, but this only works for 120Hz devices.
2025-09-19 17:42:36 +02:00

137 lines
5.8 KiB
Diff

From: uazo <uazo@users.noreply.github.com>
Date: Wed, 10 Sep 2025 07:44:05 +0000
Subject: Set the screen frame rate to 60 Hz
Set the screen refresh rate to 60Hz by default, increasing it if necessary
in cases where the system only supports lower frequencies (such as in RDP
or virtual systems).
The feature can be disabled using the throttle-main-thread-to-60hz flag (enabled by default).
License: GPL-2.0-or-later - https://spdx.org/licenses/GPL-2.0-or-later.html
---
cc/base/features.cc | 4 +++
cc/scheduler/scheduler_state_machine.cc | 26 +++++++++++++++++++
.../browser/chrome_content_browser_client.cc | 11 ++++++++
third_party/blink/common/features.cc | 1 +
4 files changed, 42 insertions(+)
diff --git a/cc/base/features.cc b/cc/base/features.cc
--- a/cc/base/features.cc
+++ b/cc/base/features.cc
@@ -180,6 +180,9 @@ BASE_FEATURE(kInitImageDecodeLastUseTime,
BASE_FEATURE(kThrottleMainFrameTo60Hz,
"ThrottleMainFrameTo60Hz",
base::FEATURE_DISABLED_BY_DEFAULT);
+#if !BUILDFLAG(IS_ANDROID)
+SET_CROMITE_FEATURE_ENABLED(kThrottleMainFrameTo60Hz);
+#endif
void SetIsEligibleForThrottleMainFrameTo60Hz(bool is_eligible) {
s_is_eligible_for_throttle_main_frame_to_60hz.store(
@@ -209,6 +212,7 @@ BASE_FEATURE(kRenderThrottleFrameRate,
base::FEATURE_ENABLED_BY_DEFAULT);
const base::FeatureParam<int> kRenderThrottledFrameIntervalHz{
&kRenderThrottleFrameRate, "render-throttled-frame-interval-hz", 30};
+SET_CROMITE_FEATURE_DISABLED(kRenderThrottleFrameRate);
BASE_FEATURE(kFastPathNoRaster,
"FastPathNoRaster",
diff --git a/cc/scheduler/scheduler_state_machine.cc b/cc/scheduler/scheduler_state_machine.cc
--- a/cc/scheduler/scheduler_state_machine.cc
+++ b/cc/scheduler/scheduler_state_machine.cc
@@ -1535,6 +1535,7 @@ void SchedulerStateMachine::FrameIntervalUpdated(
//
// Apply some slack, so that if for some reason the interval is a bit larger
// than 8.33333333333333ms, then we catch it still.
+#if BUILDFLAG(IS_ANDROID)
constexpr float kSlackFactor = .9;
bool fast_vsync_interval =
frame_interval < base::Hertz(120) * (1 / kSlackFactor);
@@ -1555,6 +1556,27 @@ void SchedulerStateMachine::FrameIntervalUpdated(
} else {
main_frame_throttled_interval_ = base::TimeDelta();
}
+#else
+ bool fast_vsync_interval =
+ base::FeatureList::IsEnabled(features::kThrottleMainFrameTo60Hz);
+ if (fast_vsync_interval) {
+ features::SetIsEligibleForThrottleMainFrameTo60Hz(true);
+ }
+ if (fast_vsync_interval &&
+ base::FeatureList::IsEnabled(features::kThrottleMainFrameTo60Hz)) {
+ // Here as well, use a slack factor, to make sure that small timing
+ // variations don't result in uneven pacing.
+ //
+ // Use interval / 2 rather than an actual interval as refresh rates are
+ // not necessarily 120: it could be something really close, or it could be
+ // 144Hz for instance.
+ main_frame_throttled_interval_ = base::Hertz(60);
+ TRACE_EVENT("cc", "ThrottleMainFrame", "interval",
+ main_frame_throttled_interval_);
+ } else {
+ main_frame_throttled_interval_ = base::TimeDelta();
+ }
+#endif
}
bool SchedulerStateMachine::IsDrawThrottled() const {
@@ -1841,7 +1863,11 @@ void SchedulerStateMachine::SetShouldThrottleFrameRate(bool flag) {
}
base::TimeDelta SchedulerStateMachine::MainFrameThrottledInterval() const {
+#if BUILDFLAG(IS_ANDROID)
if (!throttle_frame_rate_) {
+#else
+ if (!throttle_frame_rate_ || base::FeatureList::IsEnabled(features::kThrottleMainFrameTo60Hz)) {
+#endif
return main_frame_throttled_interval_;
} else {
auto throttled_interval =
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
@@ -49,6 +49,7 @@
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "build/config/chromebox_for_meetings/buildflags.h" // PLATFORM_CFM
+#include "cc/base/features.h"
#include "chrome/browser/after_startup_task_utils.h"
#include "chrome/browser/ai/ai_manager.h"
#include "chrome/browser/app_mode/app_mode_utils.h"
@@ -295,6 +296,7 @@
#include "components/variations/variations_associated_data.h"
#include "components/variations/variations_switches.h"
#include "components/version_info/version_info.h"
+#include "components/viz/common/switches.h"
#include "components/webapps/common/web_app_id.h"
#include "components/webui/chrome_urls/pref_names.h"
#include "content/public/browser/attribution_data_model.h"
@@ -2775,6 +2777,15 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
command_line->AppendSwitchASCII(ash::switches::kHomedir, homedir.value());
#endif
+#if !BUILDFLAG(IS_ANDROID)
+ if (child_process_id != -1
+ && base::FeatureList::IsEnabled(::features::kThrottleMainFrameTo60Hz)
+ && !base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableFrameRateLimit)) {
+ base::CommandLine::ForCurrentProcess()->
+ AppendSwitch(switches::kDisableFrameRateLimit);
+ }
+#endif
+
if (process_type == switches::kRendererProcess) {
content::RenderProcessHost* process =
content::RenderProcessHost::FromID(child_process_id);
diff --git a/third_party/blink/common/features.cc b/third_party/blink/common/features.cc
--- a/third_party/blink/common/features.cc
+++ b/third_party/blink/common/features.cc
@@ -2639,6 +2639,7 @@ BASE_FEATURE(kUnloadBlocklisted,
BASE_FEATURE(kUrgentMainFrameForInput,
"UrgentMainFrameForInput",
base::FEATURE_DISABLED_BY_DEFAULT);
+SET_CROMITE_FEATURE_DISABLED(kUrgentMainFrameForInput);
// Flag guard for changes in how navigation code handles the URL to commit.
// https://crbug.com/422803238
--