zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
45.66k stars 2.51k forks source link

gpui macOS: blurry background broken shadow #10993

Open Congyuwang opened 4 months ago

Congyuwang commented 4 months ago

Check for existing issues

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 commented 4 months ago

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

截圖 2024-04-26 05 38 33

jansol commented 4 months ago

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.

Congyuwang commented 4 months ago

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.

jansol commented 4 months ago

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.

Congyuwang commented 4 months ago

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.

jansol commented 4 months ago

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.

Congyuwang commented 4 months ago

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