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

ghostly text artifacts after clearing screen on macos with transparency enabled #310

Closed
erf opened this issue Oct 28, 2020 · 20 comments
Closed
Labels
bug Something isn't working macOS Issue applies to Apple macOS

Comments

@erf
Copy link
Contributor

erf commented Oct 28, 2020

Describe the bug

When window_background_opacity is less than 1.0, e.g. 0.3, and i list some text in the terminal, then resize the window, sometimes the text (buffer?) is not cleared. I also noticed this some times when using the Kitty terminal some time ago. This might be an error with some macOS spesific code.

I noticed when i open Wezterm from the terminal i get this ERROR message, not sure if it has to do with anything but i thought i mention it.

% wezterm
 2020-10-28T09:25:59.204Z ERROR wezterm_gui::gui::termwindow > OpenGL initialized! ANGLE (Metal Renderer: Intel(R) Iris(TM) Plus Graphics 640) OpenGL ES 3.0.0 (ANGLE 2.1.0.8230df39a500) is_context_loss_possible=false
^C

Environment (please complete the following information):

  • OS: macOS
  • Version: 20200909-002054-4c9af461-240-g3808cf3f

To Reproduce

  1. enable transparency by setting window_background_opacity=0.3
  2. ls some text in the terminal window
  3. resize the window, make it larger
  4. now clear the window with Ctrl-L
  5. notice the text is remained in the window, although with slight less opacity
  6. resize the window again to make the text go away

Configuration

Only set window_background_opacity=0.3

Expected behavior

I would expect the text to always clear on Ctrl-L

Screenshots

Screenshot 2020-10-28 at 10 36 32
Screenshot 2020-10-28 at 10 25 13

@erf erf added the bug Something isn't working label Oct 28, 2020
@erf erf changed the title Buffer text hangs after it should be cleared Buffer text hangs after it should be cleared ( with transparency enabled ) Oct 28, 2020
@erf erf changed the title Buffer text hangs after it should be cleared ( with transparency enabled ) Text hangs after it should be cleared ( with transparency enabled ) Oct 28, 2020
@wez wez added the macOS Issue applies to Apple macOS label Oct 28, 2020
@wez wez changed the title Text hangs after it should be cleared ( with transparency enabled ) ghostly text artifacts after clearing screen on macos with transparency enabled Oct 28, 2020
@wez
Copy link
Owner

wez commented Oct 28, 2020

Seems to be specific to macOS. Neither Windows nor Linux have a similar issue.

This also appears whether Metal (via EGL) is used or the older CGL is used (you can use prefer_egl=false to force CGL if you want to compare this for yourself, but it appears the same).

@erf
Copy link
Contributor Author

erf commented Oct 28, 2020

Did you manage to recreate it? Do you think it's worth looking into?

@wez
Copy link
Owner

wez commented Oct 28, 2020

Yeah, I can reproduce it. I'm not sure what can be done about it; wezterm does clear the sufaces (because otherwise we'd have the same problem on all systems, with or without opacity), so I'm not sure how to make macos properly respect that.
If kitty had the same problem, there may be evidence of an issue/PR over there (or in the underlying glfw library that it uses).

@erf
Copy link
Contributor Author

erf commented Oct 28, 2020

Here are some issues which might be related (a couple added by me):

It might be a glfw issue on macOS, but not sure if you use it or create a macOS window "from scratch"?

..it seem you build it from scratch ?

kovidgoyal/kitty#1207

kovidgoyal/kitty#941

glfw/glfw#1251

emoon/rust_minifb#194

microsoft/vscode#49438

wez added a commit that referenced this issue Oct 28, 2020
Not 100% sure that this is it, but it seems much less likely that
artifacts will appear in conjunction with transparency when the window
shadow effect is disabled; I didn't see the ghosting with this disabled,
but I sometimes dididn't see it with it enabled, so I'm not sure that we
have a 100% reliable reproduction, and thus am not sure that this is a
fix.

I found mention of disabling the shadow in some example code on
stackoverflow when I was first researching this, but it wasn't supplied
with an explanation. Perhaps this is why?

Longer term we might want to be smarter about turning off the shadow
only when the opacity is != 1.0, but at the moment the window layer
can't see the config, so let's just default it off for the moment
until we see if it does the trick.

refs: #310
@wez
Copy link
Owner

wez commented Oct 28, 2020

It seems like turning off the shadow effect around the window helps with this; I pushed a commit with that and would appreciate you feedback on whether it does the trick for you! While I didn't see the ghosting in that commit, I sometimes didn't see it without that change, so I don't know if I had a guaranteed repro or whether it really worked.

@wez
Copy link
Owner

wez commented Oct 28, 2020

May ultimately be this same root cause: https://stackoverflow.com/questions/20744936/drawing-to-transparent-destination-causes-drawing-artifacts/20746261#20746261 and the "best" fix may be to invalidate the shadow after a resize or whatever the trigger circumstance may be

@erf
Copy link
Contributor Author

erf commented Oct 28, 2020

Sounds promising! Looking forward to try it. Do you know if it would be possible to trigger a new build after each commit, so we could test nightly faster?

@wez
Copy link
Owner

wez commented Oct 28, 2020

It does get built on each commit: you can download the mac build from that commit here: https://github.com/wez/wezterm/runs/1323247067

Screen Shot 2020-10-28 at 14 43 12

@wez
Copy link
Owner

wez commented Oct 28, 2020

(dark mode screenshots due to Dark Reader browser extension!)

@wez
Copy link
Owner

wez commented Oct 28, 2020

You can then click on the artifacts on the build page:

Screen Shot 2020-10-28 at 14 46 49

@erf
Copy link
Contributor Author

erf commented Oct 28, 2020

Great, maybe you could add that link to the web page (if it's not there). Do you know when it's available on brew?

@wez
Copy link
Owner

wez commented Oct 28, 2020

the "nightly" download will update within the next hour, if that last build didn't already pick it up:
https://github.com/wez/wezterm/actions?query=workflow%3Amacos_continuous
Once it is in the nightly, you can do a brew rm wezterm ; brew install --HEAD wezterm to pick it up.

@erf
Copy link
Contributor Author

erf commented Oct 28, 2020

I think that fixed it! No more ghosts! Nice!

@erf erf closed this as completed Oct 28, 2020
@erf
Copy link
Contributor Author

erf commented Oct 28, 2020

Doing that resizing, reminded me off the #138 issue. If you can fix that, your terminal is in my humble opinion superior to all other terminals!

wez added a commit that referenced this issue Oct 28, 2020
This one invalidates the shadow when we invalidate the window,
so we should get to keep the shadow and lose the ghosts.

refs: #310
@wez
Copy link
Owner

wez commented Oct 28, 2020

I pushed an alternative resolution that should let us keep the default shadow. Seemed to work for me with limited testing. If that doesn't also work for you we can always go back to turning off the shadow.

@erf
Copy link
Contributor Author

erf commented Oct 28, 2020

Cool, will check it out once the build is ready. Btw, not sure, but there might be a slight performance increase with shadows off and a cleaner look..? Maybe make it an setting?

@erf
Copy link
Contributor Author

erf commented Oct 29, 2020

Ok, i've tested the latest version now, and i only saw the ghost effect a couple of times and then it went away fast as i started typing ..but it did seem ALOT more slugish the the previous version and does some weird text scaling stuff when resizing.

I did a comparison between the previous no-shadows version and the latest and the no-shadows version is ALOT faster when resizing and in general use. I would much prefer the no-shadow version.

@wez
Copy link
Owner

wez commented Oct 29, 2020

OK, that's sold me. I'll revert that last commit a little later this evening.

wez added a commit that referenced this issue Oct 29, 2020
This reverts commit f2b504e;
we prefer the overall snappier perf from not having a shadow.

refs: #310
@fanzeyi
Copy link
Contributor

fanzeyi commented Jan 30, 2021

it is a little bothering me that WezTerm doesn't give me a drop shadow for the Window. Would it be okay if I make it only disable shadow when transparency is set to non 1.0?

wez added a commit that referenced this issue Feb 1, 2023
Evidence:
* #310 (comment)
* #2669 (comment)
* #2669 (comment)

seems to suggest that window shadows hurt performance,
so add a way to disable them independently from window opacity.

You may use:

```
config.window_decorations = "TITLE|RESIZE|MACOS_FORCE_DISABLE_SHADOW"
```

for this.

refs: #2669
@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2023

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working macOS Issue applies to Apple macOS
Projects
None yet
Development

No branches or pull requests

3 participants