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.
This commit is contained in:
@@ -9,24 +9,26 @@ 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/scheduler/scheduler_state_machine.cc | 7 +++----
|
||||
chrome/browser/chrome_content_browser_client.cc | 8 ++++++++
|
||||
third_party/blink/common/features.cc | 1 +
|
||||
4 files changed, 14 insertions(+), 4 deletions(-)
|
||||
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,7 @@ BASE_FEATURE(kInitImageDecodeLastUseTime,
|
||||
@@ -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 +210,7 @@ BASE_FEATURE(kRenderThrottleFrameRate,
|
||||
@@ -209,6 +212,7 @@ BASE_FEATURE(kRenderThrottleFrameRate,
|
||||
base::FEATURE_ENABLED_BY_DEFAULT);
|
||||
const base::FeatureParam<int> kRenderThrottledFrameIntervalHz{
|
||||
&kRenderThrottleFrameRate, "render-throttled-frame-interval-hz", 30};
|
||||
@@ -37,32 +39,51 @@ diff --git a/cc/base/features.cc b/cc/base/features.cc
|
||||
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,9 +1535,8 @@ void SchedulerStateMachine::FrameIntervalUpdated(
|
||||
@@ -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.
|
||||
- constexpr float kSlackFactor = .9;
|
||||
+#if BUILDFLAG(IS_ANDROID)
|
||||
constexpr float kSlackFactor = .9;
|
||||
bool fast_vsync_interval =
|
||||
- frame_interval < base::Hertz(120) * (1 / kSlackFactor);
|
||||
+ base::FeatureList::IsEnabled(features::kThrottleMainFrameTo60Hz);
|
||||
if (fast_vsync_interval) {
|
||||
features::SetIsEligibleForThrottleMainFrameTo60Hz(true);
|
||||
}
|
||||
@@ -1549,7 +1548,7 @@ void SchedulerStateMachine::FrameIntervalUpdated(
|
||||
// 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_ = kSlackFactor * frame_interval * 2;
|
||||
+ main_frame_throttled_interval_ = base::Hertz(60);
|
||||
TRACE_EVENT("cc", "ThrottleMainFrame", "interval",
|
||||
main_frame_throttled_interval_);
|
||||
frame_interval < base::Hertz(120) * (1 / kSlackFactor);
|
||||
@@ -1555,6 +1556,27 @@ void SchedulerStateMachine::FrameIntervalUpdated(
|
||||
} else {
|
||||
@@ -1841,7 +1840,7 @@ void SchedulerStateMachine::SetShouldThrottleFrameRate(bool flag) {
|
||||
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 (!throttle_frame_rate_) {
|
||||
+#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 =
|
||||
@@ -85,15 +106,18 @@ diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/ch
|
||||
#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,12 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
|
||||
@@ -2775,6 +2777,15 @@ void ChromeContentBrowserClient::AppendExtraCommandLineSwitches(
|
||||
command_line->AppendSwitchASCII(ash::switches::kHomedir, homedir.value());
|
||||
#endif
|
||||
|
||||
+ if (base::FeatureList::IsEnabled(::features::kThrottleMainFrameTo60Hz)
|
||||
+#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 =
|
||||
|
||||
Reference in New Issue
Block a user