New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 593835 link

Starred by 5 users

Issue metadata

Status: Fixed
Owner:
Closed: Jul 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug

Blocked on:
issue 590917
issue 681465
issue 681772

Blocking:
issue 654656



Sign in to add a comment

Profile picker blurry after MD redesign.

Project Member Reported by erikc...@chromium.org, Mar 10 2016

Issue description

When there's no theme, the profile picker looks fine. 
 
Screen Shot 2016-03-10 at 10.39.21 AM.png
6.6 KB View Download
Cc: -shrike@chromium.org
Owner: shrike@chromium.org
Status: Assigned (was: Untriaged)
I relaunched without MD, and it looks fine as well.
Screen Shot 2016-03-10 at 10.44.08 AM.png
6.2 KB View Download
Bookmarks bar also looks blurry when there's a theme. This is a non-retina screen.
Screen Shot 2016-03-10 at 10.46.37 AM.png
4.2 KB View Download
Screen Shot 2016-03-10 at 10.46.30 AM.png
3.9 KB View Download
The bookmarks bar case doesn't look so bad when zoomed up, I guess. It looks slightly blurrier on the theme.

Tab strip attached.

Maybe we should turn off subpixel-AA if there's as theme?

Screen Shot 2016-03-10 at 10.53.14 AM.png
11.3 KB View Download
For the image I attached, the second "a" of "Agenda" looks really bad. I guess this isn't surprising, since we're applying a fade-out, and subpixel AA definitely doesn't work well with transparency.

Comment 6 by shrike@chromium.org, Mar 11 2016

There are cls forthcoming for the bookmarks bar and the account button. Thank you for flagging these issues.

Comment 7 by shrike@chromium.org, Mar 22 2016

Blockedon: 590917

Comment 8 by shrike@chromium.org, Mar 22 2016

Components: -UI>Browser UI>Browser>Core
Labels: Proj-MaterialDesign-NativeUI
Labels: M-52
Project Member

Comment 11 by sheriffbot@chromium.org, Jun 1 2016

Labels: -M-52 M-53 MovedFrom-52
Moving this nonessential bug to the next milestone.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Project Member

Comment 12 by sheriffbot@chromium.org, Jul 15 2016

Labels: -M-53 MovedFrom-53
This issue has been moved once and is lower than Pri-1. Removing the milestone.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Ping?
Yeah, hoping to get to this in M54.
This keeps getting worse and worse. Someone is making changes (see the red exclamation point). Can we please raise the priority of this?
Screen Shot 2016-09-13 at 1.10.17 PM.png
7.3 KB View Download
Cc: shrike@chromium.org
Labels: M-55
Owner: spqc...@chromium.org
Is this with the reworked user account button?
chrome version: 55.0.2859.0
Cc: erikc...@chromium.org
This is looking worse because I got rid of the background image for user account button. There haven't been any changes with the text.

Anyway, can you elaborate on "subpixel-AA", Erik? I have no idea what that is
Sub-pixel refers to the red, green, and blue components of a pixel on the screen. Sub-pixel anti-aliasing is an algorithm that makes text smoother by adjusting the sub-pixel values. This is in contrast to plain old anti-aliasing, where you adjust the gray value of a pixel.

So, for example, the SPAA algorithm may determine that by making some edge pixel slightly red, it can create a smoother looking edge. The one catch with SPAA is you need to know the color of the background you're drawing the text on top of. This means text drawn into a transparent layer is generally not going to look good (because the algorithm can't know what that layer will be sitting over).

I assume some root view is setWantsLayer:YES, which causes all descendants to have a layer. If you could setWantsLayer:NO on the button I think that would fix the problem, but I don't think you can have a non-layer backed view that's a subview of a layer-backed view. But you could possibly fake it by making the button opaque and drawing into it the composite of the superviews that sit behind it, then drawing the text. (Hope that makes sense.)


Sub-pixel refers to the red, green, and blue components of a pixel on the screen. Sub-pixel anti-aliasing is an algorithm that makes text smoother by adjusting the sub-pixel values. This is in contrast to plain old anti-aliasing, where you adjust the gray value of a pixel.

So, for example, the SPAA algorithm may determine that by making some edge pixel slightly red, it can create a smoother looking edge. The one catch with SPAA is you need to know the color of the background you're drawing the text on top of. This means text drawn into a transparent layer is generally not going to look good (because the algorithm can't know what that layer will be sitting over).

I assume some root view is setWantsLayer:YES, which causes all descendants to have a layer. If you could setWantsLayer:NO on the button I think that would fix the problem, but I don't think you can have a non-layer backed view that's a subview of a layer-backed view. But you could possibly fake it by making the button opaque and drawing into it the composite of the superviews that sit behind it, then drawing the text. (Hope that makes sense.)


Subpixel AA works best on a solid color background. It isn't going to work properly when there's a theme, since the background is probably not solid color. I think we should just turn it off when there's a theme.
Yes, perhaps that's the best (and simplest) answer.

Thanks for the explanation! I'm trying to understand how to turn it off. From what I understand, CALayers are using subpixels. As a result, we should turn off subpixel AA by removing the layers if there's a theme. Is that correct?
CALayers don't use subpixels, at least not in the sense of SPAA. The sub-pixels, BTW, are just the individual R-G-B elements that make up each pixel.

I'm not sure you can turn off layers for the button because once an NSView has been set to have a layer, all of its subviews will use layers. I don't think there's an explicit line that turns of layers for the account button so it seems like it must be getting set from a superview.

It looks like you can disable SPAA with the following call before you draw the text:

CGContextSetShouldSmoothFonts(ctx, false);

However that may not work if the button is just using its cell to draw it (which it is?). I guess maybe give it a shot and if it doesn't work we can go from there.
See https://developer.apple.com/reference/quartzcore/catextlayer and https://lists.apple.com/archives/cocoa-dev/2008/Mar/msg02296.html.

If we're drawing text using CoreAnimation, shrike's suggestion should work. I suspect we're drawing text using AppKit's NSTextField, in which case marking the background as non-opaque should work.

[btw, I haven't dug into this, but I suspect that the reason this problem exists is because we do something "wonky" to draw the theme, so that AppKit thinks we've got an opaque, solid color background (the normal top bar).]
I see, thanks. I'll give that a shot and let you know how it goes. Yes, the button is using the cell to draw it. It's drawing the text by using NSAttributedString
erikchen@ is right - the Appkit should disable SPAA when it can't determine the background color (e.g. the control return NO to isOpaque, background color is nil). It's likely we're doing something counter to that.
Actually, the button has a transparent background, and the tabstrip background is itself translucent, so I believe SPAA has to be turned off completely. Here's what the text looks like when the button is in the hover state and there's no theme - I don't think all the light pixels around the glyphs are correct. This is after applying your user account button patch 2347283003.


Screen Shot 2016-09-19 at 3.46.47 PM.png
10.1 KB View Download

Comment 29 by sdy@chromium.org, Sep 20 2016

Cc: sdy@chromium.org
I haven't totally tracked down what's up, but this is triggered by NSVisualEffectView. If I remove it from the window, subpixel AA works fine. You can also make the issue go away by checking "Reduce Transparency" in Accessibility preferences > Display and relaunching Chrome. Screenshots attached.
retina_bad.png
13.9 KB View Download
retina_good.png
11.7 KB View Download
lowdpi_bad.png
7.4 KB View Download
lowdpi_good.png
6.5 KB View Download

Comment 30 by sdy@chromium.org, Sep 20 2016

Actually, it looks like subpixel AA is off in those screenshots, but based on some other tests I think it'll come on in a non-buggy way with a couple of tweaks. I'll post a POC when I have it, probably not until tomorrow.

(Also, the text doesn't exactly look good with this particular theme, but I think that's separate.)

Comment 31 by sdy@chromium.org, Sep 20 2016

Last contribution for tonight. The issue presents when both of the following are true:
- The button is a child of a view that draws a background.
- That view or any of its ancestors have an NSVisualEffectView child with nonzero size.

I attached a test Xcode project and screenshots (but it's tricky to see in the screenshots). It starts in the broken state, and there are spots to uncomment to fix it by moving the button outside of the background-drawing view, and to improve on that by getting the button to do non-broken subpixel AA.

I was talking to shrike@ about changing BackgroundGradientView to be be used as a subview instead of a superclass. Maybe I could do that now? Or there might be a better/more immediate solution.
Buttons.zip
34.0 KB Download
poc_bad.png
87.3 KB View Download
poc_good.png
86.5 KB View Download
poc_best.png
87.2 KB View Download
If the problem is related to the NSVisualEffectView (which means it should also not occur if you set the visual effect state to NSVisualEffectStateInactive), that suggests the issue is vibrancy being applied to the text. Is the button's text color being set explicitly? If not, doing so might disable the vibrancy.

Comment 33 by sdy@chromium.org, Sep 22 2016

(Slightly updated Xcode project and gif attached.)

Unfortunately, setting the NSVisualEffectView's state to .inactive, explicitly setting the window's and/or the button's appearance to NSAppearance(named: NSAppearanceNameAqua), and/or explicitly setting a text color don't help. .inactive temporarily turns off the effect (e.g. to save resources) but keeps the same general appearance.

I was a little bit off in my last comment: the issue has nothing to do with whether a superview of the button draws a background. The antialiasing changes whenever a label *or* any of its superviews (up to an opaque superview) overlaps an NSVisualEffectView!

I'm going to investigate a little more deeply tonight with some help from otool and the slides from this presentation:
https://developer.apple.com/videos/play/wwdc2014/220/
Buttons-draggable.zip
69.4 KB Download

Comment 34 by sdy@chromium.org, Sep 22 2016

Wrong animated gif, this should be the right one.

Also: subpixel AA is on in the demo, and the white square in the middle is an NSVisualEffectView.
unwanted_effects.gif
1.8 MB View Download
Maybe as simple as turning off vibrancy?

https://developer.apple.com/reference/appkit/nsvisualeffectview

Comment 36 by sdy@chromium.org, Sep 22 2016

It's off by default — a view can only be vibrant if it has a vibrant .appearance or inherits one from a superview (and the default appearance is not vibrant). On top of that, like shrike@ hinted at, a text field only allows vibrancy when its .textColor is either NSColor.labelColor or NSColor.secondaryLabelColor (the default is NSColor.controlColor, but the current demo just sets it to black).
Cc: -sdy@chromium.org spqc...@chromium.org
Owner: sdy@chromium.org

Comment 38 by sdy@chromium.org, Dec 9 2016

Cc: sdy@chromium.org
 Issue 670054  has been merged into this issue.

Comment 39 by sdy@chromium.org, Dec 9 2016

Status: Started (was: Assigned)
Sorry for the lag; I have a plan to fix this.
Project Member

Comment 40 by bugdroid1@chromium.org, Jan 13 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/a5fd3c415f3cc4f8813ba9772d838bee41040ae8

commit a5fd3c415f3cc4f8813ba9772d838bee41040ae8
Author: sdy <sdy@chromium.org>
Date: Fri Jan 13 22:51:21 2017

[Mac] Fix rough-looking profile picker text, especially with a dark theme.

 Issue 593835  shows the AvatarButton's text having jagged, rainbow tinted
edges. It turns out that the text cell gets a hint about anti-aliasing
from the NSVisualEffect view below it, but the hint is wrong because the
NSVisualEffectView is itself below the theme background.

This only happens when the NSVisualEffectView's blendingMode is set to
NSVisualEffectBlendingModeBehindWindow (which makes the content behind
the window show through with a blur effect). To create the effect, the
view cuts a hole in the window and generates a mask which the window
server uses to render a translucent material behind the window.

Because the translucent parts of the window are invisible to the app,
the text can't render itself with correct subpixel anti-aliasing, which
needs information about the background. To help, NSVisualEffectView
implements two undocumented methods:
`-shouldSetFontSmoothingBackgroundColor` and
`-_backgroundColorForFontSmoothing`. It provides the base color of the
translucent material, and for the purpose of antialiasing the text cell
pretends that it's over an opaque background of that color. Because the
translucency effect is subtle, it's not obvious that the antialiasing is
done with a fixed color.

NSView implements these methods to first search its immediate subviews
and return the first YES/non-nil answer, or return NO/nil if
`self.opaque == YES`, then tail call the same method on its superview.

A quirk of this strategy is that, to provide a background color to a
text view, an NSVisualEffectView must be either a superview or an
immediate subview of a superview. So, the AvatarButton's text does get a
background color hint with the current hierarchy:

    - NSThemeFrame
       |- NSVisualEffectView
       |  |- TabStripBackgroundView
       |- FullSizeContentView
          |- AvatarButton

…but, if the NSVisualEffectView were wrapped in another view, it doesn't
(because each step of the search just looks at immediate subviews):

    - NSThemeFrame
       |- NSView
       | |- NSVisualEffectView
       | |  |- TabStripBackgroundView
       |- FullSizeContentView
          |- AvatarButton

Anyway, back on topic, our issue is that the text cell accepts the
hinted background color, which is never right since Chrome always
draws a tint over the visual effect view, and in some cases the hint is
drastically wrong.

Ideally, we'd provide a fake background for the text to perform subpixel
anti-aliasing against, but it's unclear how to do that. For now, the
simplest solution is to wrap it in another view.

This CL sucks all of the tab strip background drawing into
TabStripBackgroundView, and makes it so that other views don't need to
know about the NSVisualEffectView at all.

It also only creates the NSVisualEffectView when it's used, and gets rid
of it when it's not used (like in full screen, or when a theme is
installed).

BUG= 593835 

Review-Url: https://codereview.chromium.org/2430493002
Cr-Commit-Position: refs/heads/master@{#443707}

[modify] https://crrev.com/a5fd3c415f3cc4f8813ba9772d838bee41040ae8/base/mac/sdk_forward_declarations.h
[modify] https://crrev.com/a5fd3c415f3cc4f8813ba9772d838bee41040ae8/chrome/browser/ui/cocoa/browser_window_controller_private.mm
[modify] https://crrev.com/a5fd3c415f3cc4f8813ba9772d838bee41040ae8/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
[modify] https://crrev.com/a5fd3c415f3cc4f8813ba9772d838bee41040ae8/chrome/browser/ui/cocoa/browser_window_fullscreen_transition.mm
[modify] https://crrev.com/a5fd3c415f3cc4f8813ba9772d838bee41040ae8/chrome/browser/ui/cocoa/floating_bar_backing_view.h
[modify] https://crrev.com/a5fd3c415f3cc4f8813ba9772d838bee41040ae8/chrome/browser/ui/cocoa/floating_bar_backing_view.mm
[modify] https://crrev.com/a5fd3c415f3cc4f8813ba9772d838bee41040ae8/chrome/browser/ui/cocoa/tabs/tab_strip_background_view.h
[modify] https://crrev.com/a5fd3c415f3cc4f8813ba9772d838bee41040ae8/chrome/browser/ui/cocoa/tabs/tab_strip_background_view.mm
[add] https://crrev.com/a5fd3c415f3cc4f8813ba9772d838bee41040ae8/chrome/browser/ui/cocoa/tabs/tab_strip_background_view_unittest.mm
[modify] https://crrev.com/a5fd3c415f3cc4f8813ba9772d838bee41040ae8/chrome/browser/ui/cocoa/tabs/tab_strip_controller.h
[modify] https://crrev.com/a5fd3c415f3cc4f8813ba9772d838bee41040ae8/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
[modify] https://crrev.com/a5fd3c415f3cc4f8813ba9772d838bee41040ae8/chrome/browser/ui/cocoa/tabs/tab_strip_view.h
[modify] https://crrev.com/a5fd3c415f3cc4f8813ba9772d838bee41040ae8/chrome/browser/ui/cocoa/tabs/tab_strip_view.mm
[modify] https://crrev.com/a5fd3c415f3cc4f8813ba9772d838bee41040ae8/chrome/browser/ui/cocoa/tabs/tab_window_controller.h
[modify] https://crrev.com/a5fd3c415f3cc4f8813ba9772d838bee41040ae8/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm
[modify] https://crrev.com/a5fd3c415f3cc4f8813ba9772d838bee41040ae8/chrome/test/BUILD.gn

Comment 41 by sdy@chromium.org, Jan 14 2017

Status: Fixed (was: Started)
Project Member

Comment 42 by bugdroid1@chromium.org, Jan 17 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/23d8cf2f9da96b2e9e3496738688b6e9615ea094

commit 23d8cf2f9da96b2e9e3496738688b6e9615ea094
Author: pkalinnikov <pkalinnikov@chromium.org>
Date: Tue Jan 17 11:38:38 2017

Revert of [Mac] Fix rough-looking profile picker text, especially with a dark theme. (patchset #9 id:180001 of https://codereview.chromium.org/2430493002/ )

Reason for revert:
FullscreenControllerTest.FullscreenOnFileURL from browser_tests flakes chromium.mac/Mac10.10 Tests builder.

Original issue's description:
> [Mac] Fix rough-looking profile picker text, especially with a dark theme.
>
>  Issue 593835  shows the AvatarButton's text having jagged, rainbow tinted
> edges. It turns out that the text cell gets a hint about anti-aliasing
> from the NSVisualEffect view below it, but the hint is wrong because the
> NSVisualEffectView is itself below the theme background.
>
> This only happens when the NSVisualEffectView's blendingMode is set to
> NSVisualEffectBlendingModeBehindWindow (which makes the content behind
> the window show through with a blur effect). To create the effect, the
> view cuts a hole in the window and generates a mask which the window
> server uses to render a translucent material behind the window.
>
> Because the translucent parts of the window are invisible to the app,
> the text can't render itself with correct subpixel anti-aliasing, which
> needs information about the background. To help, NSVisualEffectView
> implements two undocumented methods:
> `-shouldSetFontSmoothingBackgroundColor` and
> `-_backgroundColorForFontSmoothing`. It provides the base color of the
> translucent material, and for the purpose of antialiasing the text cell
> pretends that it's over an opaque background of that color. Because the
> translucency effect is subtle, it's not obvious that the antialiasing is
> done with a fixed color.
>
> NSView implements these methods to first search its immediate subviews
> and return the first YES/non-nil answer, or return NO/nil if
> `self.opaque == YES`, then tail call the same method on its superview.
>
> A quirk of this strategy is that, to provide a background color to a
> text view, an NSVisualEffectView must be either a superview or an
> immediate subview of a superview. So, the AvatarButton's text does get a
> background color hint with the current hierarchy:
>
>     - NSThemeFrame
>        |- NSVisualEffectView
>        |  |- TabStripBackgroundView
>        |- FullSizeContentView
>           |- AvatarButton
>
> …but, if the NSVisualEffectView were wrapped in another view, it doesn't
> (because each step of the search just looks at immediate subviews):
>
>     - NSThemeFrame
>        |- NSView
>        | |- NSVisualEffectView
>        | |  |- TabStripBackgroundView
>        |- FullSizeContentView
>           |- AvatarButton
>
> Anyway, back on topic, our issue is that the text cell accepts the
> hinted background color, which is never right since Chrome always
> draws a tint over the visual effect view, and in some cases the hint is
> drastically wrong.
>
> Ideally, we'd provide a fake background for the text to perform subpixel
> anti-aliasing against, but it's unclear how to do that. For now, the
> simplest solution is to wrap it in another view.
>
> This CL sucks all of the tab strip background drawing into
> TabStripBackgroundView, and makes it so that other views don't need to
> know about the NSVisualEffectView at all.
>
> It also only creates the NSVisualEffectView when it's used, and gets rid
> of it when it's not used (like in full screen, or when a theme is
> installed).
>
> BUG= 593835 
>
> Review-Url: https://codereview.chromium.org/2430493002
> Cr-Commit-Position: refs/heads/master@{#443707}
> Committed: https://chromium.googlesource.com/chromium/src/+/a5fd3c415f3cc4f8813ba9772d838bee41040ae8

TBR=spqchan@chromium.org,avi@chromium.org,rsesek@chromium.org,sdy@chromium.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG= 593835 , 681772 

Review-Url: https://codereview.chromium.org/2638873002
Cr-Commit-Position: refs/heads/master@{#444028}

[modify] https://crrev.com/23d8cf2f9da96b2e9e3496738688b6e9615ea094/base/mac/sdk_forward_declarations.h
[modify] https://crrev.com/23d8cf2f9da96b2e9e3496738688b6e9615ea094/chrome/browser/ui/cocoa/browser_window_controller_private.mm
[modify] https://crrev.com/23d8cf2f9da96b2e9e3496738688b6e9615ea094/chrome/browser/ui/cocoa/browser_window_controller_unittest.mm
[modify] https://crrev.com/23d8cf2f9da96b2e9e3496738688b6e9615ea094/chrome/browser/ui/cocoa/browser_window_fullscreen_transition.mm
[modify] https://crrev.com/23d8cf2f9da96b2e9e3496738688b6e9615ea094/chrome/browser/ui/cocoa/floating_bar_backing_view.h
[modify] https://crrev.com/23d8cf2f9da96b2e9e3496738688b6e9615ea094/chrome/browser/ui/cocoa/floating_bar_backing_view.mm
[modify] https://crrev.com/23d8cf2f9da96b2e9e3496738688b6e9615ea094/chrome/browser/ui/cocoa/tabs/tab_strip_background_view.h
[modify] https://crrev.com/23d8cf2f9da96b2e9e3496738688b6e9615ea094/chrome/browser/ui/cocoa/tabs/tab_strip_background_view.mm
[delete] https://crrev.com/f518baaa99a18fb01196946dafe59218ffbf4285/chrome/browser/ui/cocoa/tabs/tab_strip_background_view_unittest.mm
[modify] https://crrev.com/23d8cf2f9da96b2e9e3496738688b6e9615ea094/chrome/browser/ui/cocoa/tabs/tab_strip_controller.h
[modify] https://crrev.com/23d8cf2f9da96b2e9e3496738688b6e9615ea094/chrome/browser/ui/cocoa/tabs/tab_strip_controller.mm
[modify] https://crrev.com/23d8cf2f9da96b2e9e3496738688b6e9615ea094/chrome/browser/ui/cocoa/tabs/tab_strip_view.h
[modify] https://crrev.com/23d8cf2f9da96b2e9e3496738688b6e9615ea094/chrome/browser/ui/cocoa/tabs/tab_strip_view.mm
[modify] https://crrev.com/23d8cf2f9da96b2e9e3496738688b6e9615ea094/chrome/browser/ui/cocoa/tabs/tab_window_controller.h
[modify] https://crrev.com/23d8cf2f9da96b2e9e3496738688b6e9615ea094/chrome/browser/ui/cocoa/tabs/tab_window_controller.mm
[modify] https://crrev.com/23d8cf2f9da96b2e9e3496738688b6e9615ea094/chrome/test/BUILD.gn

Comment 43 by sdy@chromium.org, Feb 23 2017

Status: Assigned (was: Fixed)

Comment 44 by sdy@chromium.org, Feb 23 2017

Blocking: 654656

Comment 45 by sdy@chromium.org, Feb 23 2017

Blockedon: 681772

Comment 46 by sdy@chromium.org, Feb 23 2017

Blockedon: 681465
Cc: hdodda@chromium.org
Labels: Needs-Feedback
Tested the issue on Mac Os 10.12.5 using chrome dev M61 #61.0.3141.0 and followed below steps to verify :

1. Added morpheon dark theme to chrome.
2. Opened new tab and observed there is no blurry on bookmarks bar and profile picker icons and buttons.

Attached screencast for reference.

@Could someone confirm us if this is the expected result or if we have missed any steps in verifying the issue .

Thanks!
593835.mp4
526 KB View Download

Comment 48 by sdy@chromium.org, Jul 5 2017

Status: Fixed (was: Assigned)
The issue only shows up when the profile has a name, so that the button shows text instead of an icon. But, yes, it should be fixed now. There's currently *no* subpixel AA on the button text — I created  issue 739489  to track fixing that.

Sign in to add a comment