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

Wezterm hangs for several seconds after consecutively opening and closing on macOS 11.2 #452

Closed
erf opened this issue Feb 3, 2021 · 20 comments
Labels
bug Something isn't working macOS Issue applies to Apple macOS

Comments

@erf
Copy link
Contributor

erf commented Feb 3, 2021

Describe the bug

If i open Wezterm and close it again. Then open it again shortly (~1 sec) after, it seem to hang for up to ~9 seconds before opening. If i close it and wait for a while (~12 seconds), it opens instantly again.

Environment (please complete the following information):

  • OS: macOS 11.2 (Apple Silicon)
  • wezterm 20201101-103216-403d002d-305-g140bc6e9

To Reproduce

See above.

Configuration

No config file.

Expected behavior

I would expect it to open instantly even though i just had it open.

Additional context

@erf erf added the bug Something isn't working label Feb 3, 2021
@wez
Copy link
Owner

wez commented Feb 4, 2021

I can't reproduce this; what I tried was:

  • CMD-space to pop-up spotlight, type wezterm and hit enter
  • When the window appears, CTRL-D to close it
  • Then quickly go back to the first step and repeat several times

Do you have something in your shell rc files that might be contributing to this? (Perhaps try the same experiment with Terminal.app?)

@erf
Copy link
Contributor Author

erf commented Feb 4, 2021

I did the same thing to reproduce it. Was not able to reproduce it with iTerm2 or Terminal app. I also tried with Notes and Reminder app.

As a side note i noticed "Wezterm update available" showed up now, and it did not go away, is there a way to hide it? I built from source.

@wez
Copy link
Owner

wez commented Feb 4, 2021

As a side note i noticed "Wezterm update available" showed up now, and it did not go away, is there a way to hide it? I built from source.

The update available banner will be injected into new panes/tabs until you are running on a release >= the most recent github release. There isn't a way to dismiss it or stop it from doing that at the moment.

Since you're building from source, you can update and rebuild and it should go away.

Note that the default branch was renamed from master -> main. If you have a local clone from before the switch then the easiest way to adapt to it is to delete the local clone and reclone from github.

@erf
Copy link
Contributor Author

erf commented Feb 4, 2021

Is there some way i can log what is going on?

@wez
Copy link
Owner

wez commented Feb 5, 2021

you can export WEZTERM_LOG=trace and then try repeatedly running /Applications/WezTerm.app/wezterm and see if you get a sense of where the delay is coming from.

@erf
Copy link
Contributor Author

erf commented Feb 5, 2021

where can i read the log file?

@wez
Copy link
Owner

wez commented Feb 5, 2021

it'll log to stderr

@erf
Copy link
Contributor Author

erf commented Feb 5, 2021

log.txt

here is the log file. maybe it could be something with:

 2021-02-05T04:25:08.946Z DEBUG window::os::macos::window      > EGL init failed: with_egl_lib failed: /Applications/WezTerm.app/libEGL.dylib: dlopen(/Applications/WezTerm.app/libEGL.dylib, 2): image not found, libEGL.dylib: dlopen(libEGL.dylib, 2): image not found, /Applications/WezTerm.app/libEGL.dylib: dlopen(/Applications/WezTerm.app/libEGL.dylib, 2): image not found, libEGL.dylib: dlopen(libEGL.dylib, 2): image not found, falling back to CGL

or all the blocking / polling in the beginning..

@wez
Copy link
Owner

wez commented Feb 5, 2021

 2021-02-05T04:25:08.946Z DEBUG window::os::macos::window      > EGL init failed: with_egl_lib failed: /Applications/WezTerm.app/libEGL.dylib: dlopen(/Applications/WezTerm.app/libEGL.dylib, 2): image not found, libEGL.dylib: dlopen(libEGL.dylib, 2): image not found, /Applications/WezTerm.app/libEGL.dylib: dlopen(/Applications/WezTerm.app/libEGL.dylib, 2): image not found, libEGL.dylib: dlopen(libEGL.dylib, 2): image not found, falling back to CGL
 2021-02-05T04:25:18.020Z TRACE wezterm_gui::gui::renderstate  > compiling a prog with version 330

There is a 10 second gap between those two log lines.

You might want to try setting prefer_egl = false to see if that delay relates to attempt to start up EGL, or what happens next. (I suspect that it won't change anything, but it's the closest option to try to see what changes).

Since this seems to relate to GPU setup: do you have other GPU/Metal using apps open? I wonder if there is some contention on your system for the GPU that might contribute to this.

On my M1 mac (still on 11.1) I'm running chrome and wezterm and don't see the same delay, so I'm wondering what's different.

@erf
Copy link
Contributor Author

erf commented Feb 5, 2021

Ah yes off course. Setting prefer_egl = false did not help. Maybe it happened after 11.2, because i can't remember it was like this before. But since it only happens on consecutively open, it does not matter much to me, it was more a curiosity, so feel free to close.

@charliesbot
Copy link

Hi! I'm facing the same issue. Wezterm doesn't open and eventually, I need to force close it :(

@wez
Copy link
Owner

wez commented Feb 12, 2021

@charliesbot Please share some details about your environment and config; right now there no smoking gun, so it would be good to understand more about whether there is a common thread here!

@charliesbot
Copy link

charliesbot commented Feb 12, 2021

It is a fresh restored Macbook Air M1 / MacOS 11.2

Wezterm version: 20210203-095643-70a364eb

My config is

local wezterm = require 'wezterm';

return {
  hide_tab_bar_if_only_one_tab = true,
  color_scheme = "Snazzy",
  font = wezterm.font("MonoLisa"),
  font_size = 14.0,
}

Although I just delete it to see if that was the problem but looks like it is not.

Lemme know if I can provide any more data @wez!

@wez
Copy link
Owner

wez commented Feb 12, 2021

Ok, I just upgraded my M1 to MacOS 11.2 and I can now reproduce this.

@wez
Copy link
Owner

wez commented Feb 12, 2021

I've traced the slowdown to the call that initializes NSOpenGLPixelFormat; it literally takes several seconds some times. I don't think there's anything I can do that would impact its performance; here's where it is called:
https://github.com/wez/wezterm/blob/main/window/src/os/macos/window.rs#L203-L219

This feels like an issue with macOS 11.2 itself.

@charliesbot another issue that might be relevant to you, in case this isn't exactly the issue you're seeing:
#475

@wez wez added the macOS Issue applies to Apple macOS label Feb 12, 2021
@wez wez changed the title Wezterm i hangs for several seconds after consecutively opening and closing Wezterm hangs for several seconds after consecutively opening and closing on macOS 11.2 Feb 12, 2021
@erf
Copy link
Contributor Author

erf commented Feb 12, 2021

Is this something that should be reported to Apple as a bug? Did you try to figure out if it was a specific flag that caused it? Is Metal not used for rendering now on macOS?

@charliesbot
Copy link

@wez omg yeah, that was the issue! I uninstalled Jetbrains font from brew, opened wezterm, and then reinstall it again and it worked.

Thanks! WezTerm is my favorite terminal by far :D

@wez
Copy link
Owner

wez commented Feb 12, 2021

Is this something that should be reported to Apple as a bug?

Yes, however, since CGL is deprecated, and quickly quitting and restarting an app is an edge case, I don't anticipate that apple will do anything about it.

Did you try to figure out if it was a specific flag that caused it?

I did, but those flags are basic things like 8bpc rgba, double buffered. There aren't any options.

Is Metal not used for rendering now on macOS?

CGL uses Metal under the covers in 11.x. I'm looking to see if building an updated MetalANGLE at least gives a consistent start time, but if you recall, that was something that made startup slower for you previously :-/

wez added a commit that referenced this issue Feb 12, 2021
wez added a commit that referenced this issue Apr 4, 2021
This just makes it easier to see when this is slowing things down.

refs: #452
@erf
Copy link
Contributor Author

erf commented May 26, 2021

I just installed 11.4 and the problem seem to be solved. Closing

@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