Commit 954954b5 authored by Philip Rogers's avatar Philip Rogers Committed by Commit Bot

Add a feature for respecting the MacOS LCD text behavior

This patch adds a feature flag for respecting the MacOS subpixel
anti-aliasing setting (called "LCD text" in chromium). MacOS 10.14
(Mojave) disabled LCD text by default and, by respecting this setting,
scrolling performance can be improved. This is because composited
scrolling no longer needs to be avoided for the purposes of maintaining
LCD text, which is lost in the common case where the scrolling contents
layer is not fully opaque (see [1] for details of this).

The MacOS setting for LCD text can be controlled with:
defaults write -g CGFontRenderingFontSmoothingDisabled -bool true
("true" is default, "false" overrides this). This patch uses a private
API, CGFontRenderingGetFontSmoothingDisabled, which is used by Safari
(see: https://trac.webkit.org/changeset/239306/webkit).

Enabling this feature will expose the differences of composited
scrolling which include minor pixel differences, less-minor stacking
differences (the fundamental compositing bug: crbug.com/370604), as well
as a few bugs. These differences are already present on all devices with
device pixel ratios >= 1.5 (50% of MacOS), as well as Android and
ChromeOS platforms which force-enable prefer-compositing-to-lcd-text.
The web_test changes can be seen in the Mac10.14 trybot results at
https://crrev.com/c/2207413/1. These have been triaged and
non-rebaseline differences have been broken out as bugs blocking
crbug.com/1079418. This patch does not enable the feature by default but
a followup will, which will include these baseline updates.

We have UMA data from the PreferCompositingToLCDText experiment that
should match the effect of this feature for users that have not enabled
LCD text via the command line:
Event.Latency.ScrollUpdate.Wheel.TimeToScrollUpdateSwapBegin4
  95th: -5%, 99th: -12%
EventLatency.GestureScrollUpdate.Wheel.TotalLatency
  95th: -6%, 99th: -14%
https://uma.googleplex.com/p/chrome/variations/?sid=a8cb2e0aa29593ad35baa33a2bee3f97

[1] Excellent explanation of why compositing forces greyscale AA:
https://gankra.github.io/blah/text-hates-you/#subpixel-aa-isnt-composable

Bug: 1079418
Change-Id: Ieca837912ec19f7a7b4378b989d86a4242108668
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2207413Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Philip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771858}
parent 683a4328
......@@ -516,6 +516,11 @@ const base::Feature kRequestUnbufferedDispatch{
const base::Feature kResamplingInputEvents{"ResamplingInputEvents",
base::FEATURE_DISABLED_BY_DEFAULT};
// Respect the MacOS system setting for subpixel text anti-aliasing.
// https://crbug.com/1079418.
const base::Feature kRespectMacLCDTextSetting{
"RespectMacLCDTextSetting", base::FEATURE_DISABLED_BY_DEFAULT};
// Run video capture service in the Browser process as opposed to a dedicated
// utility process
const base::Feature kRunVideoCaptureServiceInBrowserProcess{
......
......@@ -112,6 +112,7 @@ CONTENT_EXPORT extern const base::Feature kReloadHiddenTabsWithCrashedSubframes;
CONTENT_EXPORT extern const base::Feature kRenderDocument;
CONTENT_EXPORT extern const base::Feature kRequestUnbufferedDispatch;
CONTENT_EXPORT extern const base::Feature kResamplingInputEvents;
CONTENT_EXPORT extern const base::Feature kRespectMacLCDTextSetting;
CONTENT_EXPORT extern const base::Feature
kRunVideoCaptureServiceInBrowserProcess;
CONTENT_EXPORT extern const base::Feature kSavePageAsWebBundle;
......
......@@ -681,6 +681,11 @@ void RenderThreadImpl::Init() {
} else {
#if defined(OS_ANDROID)
is_lcd_text_enabled_ = false;
#elif defined(OS_MACOSX)
if (base::FeatureList::IsEnabled(features::kRespectMacLCDTextSetting))
is_lcd_text_enabled_ = IsSubpixelAntialiasingAvailable();
else
is_lcd_text_enabled_ = true;
#else
is_lcd_text_enabled_ = true;
#endif
......
......@@ -15,6 +15,10 @@ void SystemColorsDidChange(int aqua_color_variant,
const std::string& highlight_text_color,
const std::string& highlight_color);
// MacOS 10.14 (Mojave) disabled subpixel anti-aliasing by default, but this can
// be overridden with a setting (CGFontRenderingFontSmoothingDisabled).
bool IsSubpixelAntialiasingAvailable();
} // namespace content
#endif // CONTENT_RENDERER_THEME_HELPER_MAC_H_
......@@ -8,6 +8,10 @@
#include "base/strings/sys_string_conversions.h"
extern "C" {
bool CGFontRenderingGetFontSmoothingDisabled(void) API_AVAILABLE(macos(10.14));
}
namespace content {
void SystemColorsDidChange(int aqua_color_variant,
......@@ -52,4 +56,12 @@ void SystemColorsDidChange(int aqua_color_variant,
object:nil];
}
bool IsSubpixelAntialiasingAvailable() {
if (__builtin_available(macOS 10.14, *)) {
// See https://trac.webkit.org/changeset/239306/webkit for more info.
return !CGFontRenderingGetFontSmoothingDisabled();
}
return true;
}
} // namespace content
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment