zed icon indicating copy to clipboard operation
zed copied to clipboard

gpui macOS: blurry background broken shadow

Open Congyuwang opened this issue 1 year ago • 7 comments

Check for existing issues

  • [X] Completed

Describe the bug / provide steps to reproduce it

On macOS, when the window background is set to blurry, sometimes the shadow flashes, and the shadow can appear only partially, which looks broken:

截圖 2024-04-25 22 48 28

Environment

Zed: v0.133.2 (Zed Preview) OS: macOS 14.4.1 Memory: 16 GiB Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

No response

Congyuwang avatar Apr 25 '24 14:04 Congyuwang

Also has weird thumbnail rendering when swiped up to show all desktops:

  • ghost rectangles on top left: 截圖 2024-04-26 05 38 15

截圖 2024-04-26 05 38 33

  • sometimes no ghost, but it should look blurry. It looks transparent instead (as compared to Safari on the left). 截圖 2024-04-26 05 39 54

Congyuwang avatar Apr 25 '24 21:04 Congyuwang

The ghosts look exactly like ghost text that sometimes appears on transparent windows... Which turns out to be that the non-transparent parts of the window are actually holes in the shadow and the shadow does not get updated unless manually triggered or the window resizes. However updating the shadows on every frame was found in Alacritty to be very slow, so the next best workaround is to disable shadows entirely.

I can repro the non-blurred transparent thumbnail window on macOS 12.7.4 as well. I guess just add it to the list of known problems with CGSSetWindowBackgroundBlurRadius for now.

jansol avatar Apr 25 '24 23:04 jansol

Hi, @jansol, thanks for your reply. I've tried NSVisualEffectView in an empty Xcode Project (not yet in Zed). It certainly can be set as light so as not to follow system appearance: 截圖 2024-04-26 17 19 19

https://github.com/zed-industries/zed/assets/52687642/f18aefd9-5bab-4612-bb0b-993200cece98

I'm not very familiar with Mac app development though. Do you think this might work for blurry background case, or is there still some problems? (i.e., set background to this Appearance: Vibrant Light + Material: Under Window Background, and above which applies Zed themes with their different color tints)?

I'm willing to spend some more time figuring out how to put it into Zed (no idea how to do that just yet), if it could in theory work.

Congyuwang avatar Apr 26 '24 09:04 Congyuwang

Vibrant Light adds a 80% opaque white layer which is the problem I mentioned earlier. (And Vibrant Dark adds a similar black one, both are a problem for themes)

For themes to look consistent, we need to make that "backdrop" layer completely transparent (or remove it), since Zed draws its own backdrop on top of the transparent background.

jansol avatar Apr 26 '24 10:04 jansol

Perhaps the problem isn't about CGSSetWindowBackgroundBlurRadius. After removing its usage completely, the ghost shape and broken shadow still appear in transparent background.

On the other hand, macOS Terminal App doesn't have any ghost image or shadow problem, although it also uses CGSSetWindowBackgroundBlurRadius.

Congyuwang avatar Apr 27 '24 15:04 Congyuwang

Yes, the problems are not directly related to CGSSetWindowBackgroundBlurRadius but to the window shadow, which is why I opened this PR to disable shadows until someone figures out a better solution.

jansol avatar Apr 27 '24 15:04 jansol

Related issue in Alacritty: https://github.com/alacritty/alacritty/issues/6229

Congyuwang avatar Apr 28 '24 10:04 Congyuwang