Skip to content

Commit

Permalink
[M102 merge] mac: adds experiment to use 60hz on 120hz devices
Browse files Browse the repository at this point in the history
This will be used to collect data to understand the cost of this.
This includes an about:flag option to disable it.

BUG=1323358

(cherry picked from commit 8073e2d)

Change-Id: Ib6c86ccaa561ebf854a076adf795df860c4b6519
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3632908
Reviewed-by: ccameron chromium <ccameron@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1001199}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3647318
Auto-Submit: Scott Violet <sky@chromium.org>
Commit-Queue: ccameron chromium <ccameron@chromium.org>
Cr-Commit-Position: refs/branch-heads/5005@{#736}
Cr-Branched-From: 5b4d945-refs/heads/main@{#992738}
  • Loading branch information
Scott Violet authored and Chromium LUCI CQ committed May 13, 2022
1 parent 4f7c728 commit 478a76a
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 5 deletions.
7 changes: 6 additions & 1 deletion chrome/browser/about_flags.cc
Expand Up @@ -4284,7 +4284,6 @@ const FeatureEntry kFeatureEntries[] = {
kOsLinux | kOsLacros | kOsMac,
FEATURE_VALUE_TYPE(
password_manager::features::kSkipUndecryptablePasswords)},

#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_MAC)

#if BUILDFLAG(ENABLE_VR)
Expand Down Expand Up @@ -8524,6 +8523,12 @@ const FeatureEntry kFeatureEntries[] = {
FEATURE_VALUE_TYPE(
autofill::features::kAutofillEnableVirtualCardFidoEnrollment)},

#if BUILDFLAG(IS_MAC)
{"force-60hz", flag_descriptions::kForce60HzName,
flag_descriptions::kForce60HzDescription, kOsMac,
FEATURE_VALUE_TYPE(display::features::kForce60Hz)},
#endif // BUILDFLAG(IS_MAC)

// NOTE: Adding a new flag requires adding a corresponding entry to enum
// "LoginCustomFlags" in tools/metrics/histograms/enums.xml. See "Flag
// Histograms" in tools/metrics/histograms/README.md (run the
Expand Down
5 changes: 5 additions & 0 deletions chrome/browser/flag-metadata.json
Expand Up @@ -3287,6 +3287,11 @@
"owners": [ "cmp", "pwnall" ],
"expiry_milestone": 102
},
{
"name": "force-60hz",
"owners": [ "sky" ],
"expiry_milestone": 106
},
{
"name": "force-color-profile",
"owners": [ "ccameron" ],
Expand Down
6 changes: 6 additions & 0 deletions chrome/browser/flag_descriptions.cc
Expand Up @@ -5706,6 +5706,12 @@ const char kSkipUndecryptablePasswordsDescription[] =
"there are undecryptable ones.";
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_MAC)

#if BUILDFLAG(IS_MAC)
const char kForce60HzName[] = "Use 60hz instead of 120hz";
const char kForce60HzDescription[] =
"If enabled, on devices with a refresh rate of 120hz, 60hz is used.";
#endif // BUILDFLAG(IS_MAC)

// Feature flags --------------------------------------------------------------

#if BUILDFLAG(CHROME_WIDE_ECHO_CANCELLATION)
Expand Down
5 changes: 5 additions & 0 deletions chrome/browser/flag_descriptions.h
Expand Up @@ -3288,6 +3288,11 @@ extern const char kSkipUndecryptablePasswordsName[];
extern const char kSkipUndecryptablePasswordsDescription[];
#endif // BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_MAC)

#if BUILDFLAG(IS_MAC)
extern const char kForce60HzName[];
extern const char kForce60HzDescription[];
#endif // BUILDFLAG(IS_MAC)

// Feature flags --------------------------------------------------------------

#if BUILDFLAG(CHROME_WIDE_ECHO_CANCELLATION)
Expand Down
2 changes: 2 additions & 0 deletions tools/metrics/histograms/enums.xml
Expand Up @@ -55359,6 +55359,7 @@ from previous Chrome versions.
<int value="7444737" label="NTPSuggestionsStandaloneUI:disabled"/>
<int value="7533886" label="disable-offer-store-unmasked-wallet-cards"/>
<int value="7642326" label="hdrnet-override"/>
<int value="7804608" label="Force60Hz:enabled"/>
<int value="8891567" label="CaptionSettings:enabled"/>
<int value="9609535" label="BrowsingDataLifetimeManager:disabled"/>
<int value="10405060" label="BluetoothSessionizedMetrics:disabled"/>
Expand Down Expand Up @@ -57713,6 +57714,7 @@ from previous Chrome versions.
label="AutofillAlwaysReturnCloudTokenizedCard:enabled"/>
<int value="1634897915" label="password-import-export:enabled"/>
<int value="1634980726" label="VrShellExperimentalRendering:disabled"/>
<int value="1635519293" label="Force60Hz:disabled"/>
<int value="1635695770" label="CSSContainerQueries:disabled"/>
<int value="1635755615" label="ScanAppMultiPageScan:disabled"/>
<int value="1635986352" label="ContextMenuSearchWithGoogleLens:enabled"/>
Expand Down
4 changes: 4 additions & 0 deletions ui/display/display_features.cc
Expand Up @@ -43,5 +43,9 @@ bool IsHardwareMirrorModeEnabled() {
return base::FeatureList::IsEnabled(kEnableHardwareMirrorMode);
}

#if BUILDFLAG(IS_MAC)
const base::Feature kForce60Hz{"Force60Hz", base::FEATURE_DISABLED_BY_DEFAULT};
#endif

} // namespace features
} // namespace display
5 changes: 5 additions & 0 deletions ui/display/display_features.h
Expand Up @@ -24,6 +24,11 @@ DISPLAY_EXPORT extern const base::Feature kEnableHardwareMirrorMode;

DISPLAY_EXPORT bool IsHardwareMirrorModeEnabled();

#if BUILDFLAG(IS_MAC)
// If enabled, vsync of 120 is forced to 60.
DISPLAY_EXPORT extern const base::Feature kForce60Hz;
#endif

} // namespace features
} // namespace display

Expand Down
11 changes: 7 additions & 4 deletions ui/display/mac/display_link_mac.cc
Expand Up @@ -15,6 +15,7 @@
#include "base/task/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h"
#include "ui/display/display_features.h"

namespace base {

Expand Down Expand Up @@ -163,8 +164,7 @@ DisplayLinkMac::DisplayLinkMac(
base::ScopedTypeRef<CVDisplayLinkRef> display_link)
: display_id_(display_id),
display_link_(display_link),
force_60hz_(
base::CommandLine::ForCurrentProcess()->HasSwitch("force-60hz")) {
force_60hz_(base::FeatureList::IsEnabled(display::features::kForce60Hz)) {
DisplayLinkMap& all_display_links = GetAllDisplayLinks();
DCHECK(all_display_links.find(display_id) == all_display_links.end());
if (all_display_links.empty()) {
Expand Down Expand Up @@ -236,8 +236,11 @@ void DisplayLinkMac::UpdateVSyncParameters(const CVTimeStamp& cv_time) {

timebase_ = base::TimeTicks::FromMachAbsoluteTime(cv_time.hostTime);
interval_ = base::Microseconds(int64_t{interval_us.ValueOrDie()});
if (force_60hz_)
interval_ = std::max(base::Hertz(60), interval_);
// Use a range as interval is not always exactly 120.
if (force_60hz_ && interval_ <= base::Hertz(115) &&
interval_ >= base::Hertz(125)) {
interval_ *= 2;
}
timebase_and_interval_valid_ = true;

// Don't restart the display link for 10 seconds.
Expand Down

0 comments on commit 478a76a

Please sign in to comment.