gpui/mac: Disable shadows on non-opaque windows
The culprit behind ghost images in transparent windows and bad performance with blurred windows turns out to be one and the same: window shadows. The simplest and most popular fix appears to be to simply disable shadows on non-opaque windows so let's just do that.
Disabling shadows on a window that is already visible however leaves the shadow on screen, detached from the window, until a full screen effect such as exposé or a virtual desktop switch wipes it clean. There does not seem to be any known solution to this, and it does not affect windows created after switching to a transparent theme so this is a good enough compromise for now.
Release Notes:
- Fixed ghostly artifacts in transparent window backgrounds.
- Fixed sluggishness with blurred window backgrounds.
CGSSetWindowBackgroundBlurRadius does seem to have some issue with shadow #10993. However, removing the window shadow doesn't produce a nice look. For example, without a window shadow, when using bright themes, the window border just appears almost blended into the bright backgrounds behind it. Don't know if it is possible to use NSVisualEffectView.
Can you post a screenshot demonstrating the issue? I haven't really found it to look bad, but on the other hand I mainly use dark themes.
NSVisualEffectView will alter the tint of the blurred background based on the system appearance, making it impossible to develop themes with a consistent look.
@jansol
Shadow:
No shadow:
It just feels very much like they lack an z-axis to separate from each other. How much does NSVisualEffectView alter the tint of the blurred background based on the system appearance, is there some screenshot or some image?
Also some screenshots here: https://github.com/zed-industries/zed/issues/10993#issuecomment-2078224404. It looks like when the window is shown in desktop thumbnails, it also looks not very blurry (but more like transparent), although it is set to be blurry.
Okay, yeah I see what you mean. That is indeed a very striking difference.
How much does NSVisualEffectView alter the tint of the blurred background based on the system appearance, is there some screenshot or some image?
A lot
(This and more comparisons from: https://nilotic.github.io/2018/09/28/Advanced-Dark-Mode.html)
Plus with NSVisualEffectView you are supposed to use "semantic" styles, which map really badly to GPUI usage.
It does appear to be possible to remove the black/white backdrop (or at least make it completely transparent so it does not affect the Zed theme):
- https://stackoverflow.com/questions/26526726/how-can-i-overlay-a-background-color-over-an-nsvisualeffectview-and-use-vibrant
- https://stackoverflow.com/questions/37231536/adjust-nsvisualeffectview-blur-radius-and-transparency
But this involves poking around in internal structures that a comment in those posts mentions are known to have changed between macOS versions with no warning.
Personally I'm happy with the current solution even without shadows, and since removing shadows removes the artifacting and performance issues I don't intend to spend more time on this any time soon. If you or someone else wants to try out a tweaked NSVisualEffectView, be my guest :)
@jansol @Congyuwang What's the call here?
I'm inclined to merge, as fixing the performance issues seems important, even if the visual style isn't 100% of the way there when using non-opaque backgrounds.
Are the visuals the only concern about this change?
Yeah, my only concern is about visual. I think perhaps this is a good solution before anyone comes up with something better.
Yeah, my only concern is about visual. I think perhaps this is a good solution before anyone comes up with something better.
Thanks for the response!
I think we'll go ahead and merge and then re-assess if there's a way to restore the shadows without causing the performance problems.