Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS: background bleeds/flicker when resizing splits, creating tabs #4516

Closed
mitchellh opened this issue Jan 3, 2025 · 6 comments · Fixed by #5083
Closed

macOS: background bleeds/flicker when resizing splits, creating tabs #4516

mitchellh opened this issue Jan 3, 2025 · 6 comments · Fixed by #5083
Labels
gui GUI or app issue regardless of platform (i.e. Swift, GTK) os/macos
Milestone

Comments

@mitchellh
Copy link
Contributor

Discussion: #4182, #4181, #4180, #3508

I'm not sure what is causing this yet but it'd be great to nail this down and clean this up.

Screenshot.2024-12-31.at.04.40.20.AM.mp4
@mitchellh mitchellh added gui GUI or app issue regardless of platform (i.e. Swift, GTK) os/macos labels Jan 3, 2025
@andrewcrook
Copy link

andrewcrook commented Jan 5, 2025

I get this as well. the title bar and main window area resize at different rates.

Image

@dmehala
Copy link
Collaborator

dmehala commented Jan 5, 2025

I suspect what we're observing is the latency between the surface redraw and the window resize with a transparent background. Since fa83140 the background is fully transparent and made this more noticeable for users with background-opacity = 1.

Here's a video, top is without fa83140 and bottom 1.01+f4a9b65f:

Screen.Recording.2025-01-05.at.21.36.57.mp4

Unfortunately, the solution isn't as simple as reverting fa83140, because the issue will persist when using background-opacity = 0.x.

@andrewcrook
Copy link

andrewcrook commented Jan 5, 2025

I find its not as bad having background-opacity < 1 like 0.9 than having it as 1.

It doesn’t get rid of the issue but I wonder if there could be or is an option to turn off redrawing during resizing and dragging?
Just have the overlay and redraw after such an action is completed?

I know this can be done on macOS via an OS wide setting, however, can it be done per app i.e Ghostty’s configuration?

Cannot unsee it now 🙁

@andreafspeziale
Copy link

Hello everyone, sorry to jump in the conversation. I was looking for an existing "flickering" issue and I found this one. I'm experiencing something similar, not while resizing but while downloading smth.

Here is a quick video:

ghostty.mov

Let me know if it can be related to the current issue of if I should fill a new one.

TY for your hard work 🤗

@andreafspeziale
Copy link

andreafspeziale commented Jan 12, 2025

I also recently noticed that opening a new tab with cmd+t has some kind of flickering too

Registrazione.schermo.2025-01-12.alle.02.10.56.mov

I'm on the latest version, 1.0.1

@edrozenberg
Copy link

In case it's somehow relevant, I tested Alacritty also: opening windows/tabs no flicker, but there is a very brief flicker sometimes when closing windows or tabs.

mitchellh added a commit that referenced this issue Jan 13, 2025
This PR addresses #2125 for the Metal renderer. Both options are
available: "Apple-style" blending where colors are blended in a wide
gamut color space, which reduces but does not eliminate artifacts; and
linear blending where colors are blended in linear RGB.

Because this doesn't add support for linear blending on Linux, I don't
know whether the issue should be closed or not.

### List of changes in no particular order
- We now set the layer's color space in the renderer not in the apprt
- We always set the layer to Display P3 color spaces
- If the user hasn't configured their `window-colorspace` to
`display-p3` then terminal colors are automatically converted from sRGB
to the corresponding Display P3 color in the shader
- Background color is not set with the clear color anymore, instead we
explicitly set all bg cell colors since this is needed for minimum
contrast to not break with dark text on the default bg color (try it
out, it forces it fully white right now), and we just draw the
background as a part of the bg cells shader. Note: We may want to move
the main background color to be the `backgroundColor` property on the
`CAMetalLayer`, because this should fix the flash of transparency during
startup (#4516) and the weirdness at the edge of the window when
resizing. I didn't make that a part of this PR because it requires
further changes and my changes are already pretty significant, but I can
make it a follow-up.
- Added a config option for changing alpha blending between "native"
blending, where colors are just blended directly in sRGB (or Display P3)
and linear blending, where colors are blended in linear space.
- Added a config option for an experimental technique that I think works
pretty well which compensates for the perceptual thinning and thickening
of dark and light text respectively when using linear blending.
- Custom shaders can now be hot reloaded with config reloads.
- Fixed a bug that was revealed when I changed how we handle
backgrounds, page widths weren't being set while cloning the screen.

### Main takeaways
Color blending now matches nearly identically to Apple apps like
Terminal.app and TextEdit, not *quite* identical in worst case
scenarios, off by the tiniest bit, because the default color space is
*slightly* different than Display P3.

Linear alpha blending is now available for mac users who prefer more
accurate color reproduction, and personally I think it looks very nice
with the alpha correction turned on, I will be daily driving that
configuration.

### Future work
- Handle primary background color with `CALayer.backgroundColor` instead
of in shader, to avoid issues around edges when resizing.
- Parse color space info directly from ICC profiles and compute the
color conversion matrix dynamically, and pass it as a uniform to the
shaders.
- Port linear blending option to OpenGL.
- Maybe support wide gamut images (right now all images are assumed to
be sRGB).
mitchellh added a commit that referenced this issue Jan 15, 2025
#5083)

Fixes #4516

By using the `CAMetalLayer`'s `backgroundColor` property instead of
drawing the background color in our shader, it is always stretched to
cover the full surface, even when live-resizing, and it doesn't require
us to draw a frame for it to be initialized so there's no transparent
flash when a new surface is created (as in a new split/tab).

This commit also allows for hot reload of `background-opacity`,
`window-vsync`, and `window-colorspace`.
@github-actions github-actions bot added this to the 1.1.0 milestone Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gui GUI or app issue regardless of platform (i.e. Swift, GTK) os/macos
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants