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

REPL is unresponsive after using Gtk4 #23

Closed
cmey opened this issue Mar 9, 2023 · 6 comments · Fixed by #24
Closed

REPL is unresponsive after using Gtk4 #23

cmey opened this issue Mar 9, 2023 · 6 comments · Fixed by #24

Comments

@cmey
Copy link

cmey commented Mar 9, 2023

Hi!

Just using Gtk4 and waiting for a minute, makes the julia REPL unresponsive / super slow.

This is on julia 1.8.5 and also on 1.9-rc1 on a mac Intel, macOS Ventura 13.2.1.

I've tried 3 terminal apps: the Terminal app that comes with macOs, Warp, and the REPL in vscode - they all show the same behevior.

Detailed infos:

I start julia with julia +1.9 --project=. (from juliaup).

(Winston-work) pkg> st
Status `~/Code/julia/Winston-work/Project.toml`
  [9db2cae5] Gtk4 v0.3.2

julia> versioninfo()
Julia Version 1.9.0-rc1
Commit 3b2e0d8fbc1 (2023-03-07 07:51 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin21.4.0)
  CPU: 16 × Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, skylake)
  Threads: 1 on 16 virtual cores

(Side note: I've seen it happen on Windows too. And on Linux all is fine.)

@tknopp
Copy link
Member

tknopp commented Mar 9, 2023

I am on Julia 1.8.0 and macOS 12.3.1 and have not seen this so far.

@jwahlstrand
Copy link
Member

I have seen it on my Mac and it makes the REPL unusable after a minute or two, like @cmey said. I have not noticed this on Windows, which I use a lot more. The same thing happens for me with Gtk.jl, but only after you open a window, which starts the GLib main loop, and wait a few minutes. I noticed it goes away if I revert JuliaGraphics/Gtk.jl#630. But doing that unfortunately brings back slowdown issues with multithreading.

We could add some functions that allow you to turn uv_backend_fd integration on and off. I'd be inclined to enable it by default on Mac and Windows if isinteractive() is true. We could add a warning in the documentation that multithread performance is impacted.

@tknopp
Copy link
Member

tknopp commented Mar 10, 2023

Hm, I have used Gtk4 on Mac quite intensively when porting a larger app and have not seen it so far. But anyways, the suggestion to make in configurable and enabling it on Mac/Windows sounds good.

@jwahlstrand
Copy link
Member

See if what I just pushed fixes the REPL issue. It does for me.

This re-enables the uv_backend polling on a Mac if you're in an interactive session. To go back to how it was before (to prevent Gtk4 from interfering with multithreading), you can call Gtk4.set_uv_loop_integration("disabled") and then restart Julia. It uses Preferences.jl to save this setting. There are docstrings but I'll try to add some useful information about this to the documentation soon. BTW as I was working on this I realized that it's not going to fix the Windows issue, because this uv_backend polling isn't used for that platform. Not sure how to fix it there.

As I mentioned, I had seen this on my own computer (which is pretty old and slow) but figured that it wasn't an issue for everyone, since I knew @tknopp has been using Gtk4.jl on a Mac and hadn't complained.

@cmey
Copy link
Author

cmey commented Mar 13, 2023

@jwahlstrand Thanks a lot for the fix, I can confirm that your latest change fixes it!

I added Gtk4#main and saw no lag after playing with it for a few minutes.
I reverted to Gtk4 and got a laggy REPL almost immediately.

Can you please tag a new release with this fix? 🙏

@jwahlstrand
Copy link
Member

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants