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

GtkWindow doesn't display a new window when Gtk4 is built in a sysimage #26

Closed
cmey opened this issue Apr 5, 2023 · 4 comments
Closed

Comments

@cmey
Copy link

cmey commented Apr 5, 2023

Start in a fresh Julia 1.9-rc2 environment, install Gtk4 and PackageCompiler:

julia +1.9 --project=.
(Gtk4.jl-work) pkg> add Gtk4, PackageCompiler
julia> exit()

Make package compiler scripts:

cat scripts/run_package_compiler.sh
julia +1.9 --project=. scripts/run_package_compiler.jl

---

cat scripts/run_package_compiler.jl
using PackageCompiler

packages = [
    :Gtk4,
]

create_sysimage(
    packages,
    sysimage_path="sysimage.so",
    precompile_execution_file=(@__DIR__) * "/precompile_execution_file.jl")

---

cat scripts/precompile_execution_file.jl
using Gtk4
win = Gtk4.GtkWindow()

Run package compiler:

./scripts/run_package_compiler.sh

Start Julia with the newly built sysimage:

julia +1.9 --project=. --sysimage=sysimage.so

julia> using Gtk4
julia> Gtk4.GtkWindow()

Notice unexpectedly no window appears. When I don't load the sysimage, then the window appears.

This happens on:

julia> versioninfo()
Julia Version 1.9.0-rc2
Commit 72aec423c2a (2023-04-01 10:41 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

(Gtk4.jl-work) pkg> st
Status `~/Code/julia/Gtk4.jl-work/Project.toml`
  [9db2cae5] Gtk4 v0.3.4
  [9b87118b] PackageCompiler v2.1.5
@jwahlstrand
Copy link
Member

jwahlstrand commented Apr 5, 2023

Thanks for the detailed report. It looks like the main loop is not being started automatically. When I call Gtk4.GLib.start_main_loop() before or after creating the window, it appears and subsequent windows do too. Right now the main loop is started by default when isinteractive() == true and I guess it makes sense that this condition isn't satisfied when you create a sysimage.

This behavior deserves some discussion and documentation. The reason I did it this way was to better support GtkApplication, which wants to run the loop itself. I was thinking that GtkApplication, which lets you use actions and enables a few other things, was mainly useful for non-REPL applications. But in GTK4 they really push you to use GtkApplication; I've noticed that on Linux a lot of random warnings are spewn when you use the file chooser dialogs without it. Should we use a default GtkApplication for the REPL?

@tknopp
Copy link
Member

tknopp commented Apr 6, 2023

Should we use a default GtkApplication for the REPL?

I am not sure what the implications would be. If this is invisible to the user, I think this could be a good approach. If one need to explicitly create the GtkApplication and call the blocking run method, we would loose this nice interactivity.

@jwahlstrand
Copy link
Member

Yeah, agreed, I think we could make it invisible to the user. I'll look into it when I have time.

@jwahlstrand
Copy link
Member

There is now a mention in the docs of the need to start the main loop: https://juliagtk.github.io/Gtk4.jl/dev/howto/sysimage/

On the issue of having a default GtkApplication for the REPL, I decided it would be too complicated and would probably cause trouble if multiple applications shared it.

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

No branches or pull requests

3 participants