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

Fail to create GtkApplicationWindow in windows #33

Closed
Rratic opened this issue Jun 28, 2023 · 7 comments
Closed

Fail to create GtkApplicationWindow in windows #33

Rratic opened this issue Jun 28, 2023 · 7 comments

Comments

@Rratic
Copy link

Rratic commented Jun 28, 2023

julia> using Gtk4

julia> function init_window_gtk(app)
           window = GtkApplicationWindow(app, "foo")
           present(window, 0)
       end
init_window_gtk (generic function with 1 method)

julia> application = GtkApplication()
Gtk4.GtkApplicationLeaf(application-id=nothing, flags=G_APPLICATION_FLAGS_NONE, resource-base-path=nothing, is-registered=false, is-remote
(process:8844): GLib-GIO-CRITICAL **: 15:07:23.344: g_application_get_is_remote: assertion 'application->priv->is_registered' failed
=false, inactivity-timeout=0, action-group, is-busy=false, register-session=false, screensaver-active=false, menubar, active-window)

julia> signal_connect(init_window_gtk, application, :activate)
0x00000007

julia> run(application)

(julia.exe:8844): GLib-GIO-WARNING **: 15:07:39.255: C:\Users\anonymous\.julia\artifacts\4f67e82ee394e74ca63b7dc589dcc9218c12b20a\bin\gdbus.exe dbus binary failed to launch bus, maybe incompatible version

then it stuck there

environment:

julia> versioninfo()
Julia Version 1.9.1
Commit 147bdf428c (2023-06-07 08:27 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: 8 × Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, skylake)
  Threads: 1 on 8 virtual cores

(@v1.9) pkg> st Gtk4
Status `C:\Users\anonymous\.julia\environments\v1.9\Project.toml`
  [9db2cae5] Gtk4 v0.4.1
@bilderbuchi
Copy link

bilderbuchi commented Jun 28, 2023

I can reproduce this.

Following this example, I think you need to add both

if isinteractive()
    Gtk4.GLib.stop_main_loop()  # g_application_run will run the loop
end

and

if isinteractive()
    loop()=Gtk4.run(app)
    t = schedule(Task(loop))
else
    Gtk4.run(app)
end

to make this work.

This feels more complicated than needed to me, but I'm sure there are good technical reasons that necessitate this dance.
Maybe the observed "silent" failure can be avoided or detected somehow? I also ran into this issue recently, and the fact that you just get an icon in the Windows taskbar, but no visible window made this frustrating to troubleshoot.

@jwahlstrand
Copy link
Member

Maybe the call to run could by default check if the loop is running and if so, stop it. Alternatively, we could define a default GtkApplication that runs in REPL mode, as mentioned in #26. Users could either attach their windows, actions, etc. to that, or they could stop it and define their own app. I feel like the consequences need to be thought through carefully, and I haven't had the bandwidth lately.

@jwahlstrand
Copy link
Member

The latest version includes a check in run and stoppage of the loop, as mentioned in the previous comment, so that should prevent the silent failure.

@kschertler
Copy link

I can unfortunately reproduce the same GLib-GIO-WARNING and GLib-GIO-CRITICAL messages from the example above under Windows using Julia 1.9.3 and Gtk v0.5.4. Since it's hard to see... the GLib-GIO-CRITICAL message is "hidden" in the GtkApplication() output above and states that g_application_get_is_remote: assertion 'application->priv->is_registered' failed.

@jwahlstrand
Copy link
Member

Does the "foo" Window show up for you? The original issue was about Julia freezing when run was called, and that was fixed, at least for me.

I also see those warnings on Windows, but I think they're harmless. As far as I understand it, GTK is looking for a DBus to register the application with, and that doesn't exist on Windows. But I'll look into whether there's a way to silence the warnings.

@kschertler
Copy link

Yes, the “foo” window properly appears. It’s just a little bit disturbing to see a “critical” message. But it’s good to now they are harmless from your experience.

@jwahlstrand
Copy link
Member

Critical warnings are typically a bad sign, and it's possible there are side effects from having no DBus on Windows. Judging from this discussion, there is no way to stop GTK from looking for DBus: https://gitlab.gnome.org/GNOME/gtk/-/issues/4842

So it looks like fixing this would require building DBus for Windows in Yggdrasil.

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

4 participants