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

[Wayland] Urn crashes on launch when global hotkeys are enabled #9

Closed
kimbadim opened this issue Jul 29, 2023 · 9 comments
Closed

[Wayland] Urn crashes on launch when global hotkeys are enabled #9

kimbadim opened this issue Jul 29, 2023 · 9 comments
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers

Comments

@kimbadim
Copy link

When global-hotkeys is set to true, urn segfaults on launch. Setting it to false allows it to start normally.

Backtrace:

              Stack trace of thread 1761672:
              #0  0x00007f61551361bf XkbGetUpdatedMap (libX11.so.6 + 0x931bf)
              #1  0x00007f61551362d6 XkbGetMap (libX11.so.6 + 0x932d6)
              #2  0x0000555911481c7b n/a (urn-gtk + 0x7c7b)
              #3  0x0000555911481f8f n/a (urn-gtk + 0x7f8f)
              #4  0x0000555911482296 n/a (urn-gtk + 0x8296)
              #5  0x000055591147ec7a n/a (urn-gtk + 0x4c7a)
              #6  0x00007f6155e2313b g_type_create_instance (libgobject-2.0.so.0 + 0x3f13b)
              #7  0x00007f6155e08d91 n/a (libgobject-2.0.so.0 + 0x24d91)
              #8  0x00007f6155e0af0b g_object_new_valist (libgobject-2.0.so.0 + 0x26f0b)
              #9  0x00007f6155e0b29e g_object_new (libgobject-2.0.so.0 + 0x2729e)
              #10 0x000055591147f959 n/a (urn-gtk + 0x5959)
              #11 0x00007f6155e17bc9 g_signal_emit_valist (libgobject-2.0.so.0 + 0x33bc9)
              #12 0x00007f6155e17d34 g_signal_emit (libgobject-2.0.so.0 + 0x33d34)
              #13 0x00007f615540ed19 n/a (libgio-2.0.so.0 + 0xddd19)
              #14 0x00007f615540ee6c g_application_run (libgio-2.0.so.0 + 0xdde6c)
              #15 0x00007f6154ecc850 n/a (libc.so.6 + 0x23850)
              #16 0x00007f6154ecc90a __libc_start_main (libc.so.6 + 0x2390a)
              #17 0x000055591147e075 n/a (urn-gtk + 0x4075)
              
              Stack trace of thread 1761676:
              #0  0x00007f6154fac2ed syscall (libc.so.6 + 0x1032ed)
              #1  0x00007f6155296533 g_cond_wait_until (libglib-2.0.so.0 + 0xb0533)
              #2  0x00007f615520b115 n/a (libglib-2.0.so.0 + 0x25115)
              #3  0x00007f6155275dab n/a (libglib-2.0.so.0 + 0x8fdab)
              #4  0x00007f6155272d75 n/a (libglib-2.0.so.0 + 0x8cd75)
              #5  0x00007f6154f3044b n/a (libc.so.6 + 0x8744b)
              #6  0x00007f6154fb3e40 n/a (libc.so.6 + 0x10ae40)
              
              Stack trace of thread 1761677:
              #0  0x00007f6154fa6c0f __poll (libc.so.6 + 0xfdc0f)
              #1  0x00007f615529dc2f n/a (libglib-2.0.so.0 + 0xb7c2f)
              #2  0x00007f615523e0e2 g_main_context_iteration (libglib-2.0.so.0 + 0x580e2)
              #3  0x00007f6155ea3fde n/a (libdconfsettings.so + 0x5fde)
              #4  0x00007f6155272d75 n/a (libglib-2.0.so.0 + 0x8cd75)
              #5  0x00007f6154f3044b n/a (libc.so.6 + 0x8744b)
              #6  0x00007f6154fb3e40 n/a (libc.so.6 + 0x10ae40)
              
              Stack trace of thread 1761673:
              #0  0x00007f6154fac2ed syscall (libc.so.6 + 0x1032ed)
              #1  0x00007f6155295ca7 g_cond_wait (libglib-2.0.so.0 + 0xafca7)
              #2  0x00007f615520b144 n/a (libglib-2.0.so.0 + 0x25144)
              #3  0x00007f61552752fe n/a (libglib-2.0.so.0 + 0x8f2fe)
              #4  0x00007f6155272d75 n/a (libglib-2.0.so.0 + 0x8cd75)
              #5  0x00007f6154f3044b n/a (libc.so.6 + 0x8744b)
              #6  0x00007f6154fb3e40 n/a (libc.so.6 + 0x10ae40)
              
              Stack trace of thread 1761675:
              #0  0x00007f6154fa6c0f __poll (libc.so.6 + 0xfdc0f)
              #1  0x00007f615529dc2f n/a (libglib-2.0.so.0 + 0xb7c2f)
              #2  0x00007f615523ffef g_main_loop_run (libglib-2.0.so.0 + 0x59fef)
              #3  0x00007f615544128c n/a (libgio-2.0.so.0 + 0x11028c)
              #4  0x00007f6155272d75 n/a (libglib-2.0.so.0 + 0x8cd75)
              #5  0x00007f6154f3044b n/a (libc.so.6 + 0x8744b)
              #6  0x00007f6154fb3e40 n/a (libc.so.6 + 0x10ae40)
              
              Stack trace of thread 1761674:
              #0  0x00007f6154fa6c0f __poll (libc.so.6 + 0xfdc0f)
              #1  0x00007f615529dc2f n/a (libglib-2.0.so.0 + 0xb7c2f)
              #2  0x00007f615523e0e2 g_main_context_iteration (libglib-2.0.so.0 + 0x580e2)
              #3  0x00007f615523e132 n/a (libglib-2.0.so.0 + 0x58132)
              #4  0x00007f6155272d75 n/a (libglib-2.0.so.0 + 0x8cd75)
              #5  0x00007f6154f3044b n/a (libc.so.6 + 0x8744b)
              #6  0x00007f6154fb3e40 n/a (libc.so.6 + 0x10ae40)
              ELF object binary architecture: AMD x86-64
@paoloose
Copy link
Owner

paoloose commented Jul 29, 2023

Thanks for reporting. I'm unable to reproduce this issue (Debian 12 x86_64). It seems it is related to your x11 shared libraries rather than urn itself

Stack trace of thread 1761672:
#0  0x00007f61551361bf XkbGetUpdatedMap (libX11.so.6 + 0x931bf)
#1  0x00007f61551362d6 XkbGetMap (libX11.so.6 + 0x932d6)

Try updating your system packages/drivers, and if doesn't work, can you share the environment information on which you are running the application?

@kimbadim
Copy link
Author

kimbadim commented Jul 29, 2023

This may be wayland-related, apparently this only happens when using plasma-wayland-session and not on the default Plasma X11 session.

@paoloose paoloose changed the title Urn crashes on launch when global hotkeys are enabled [Wayland] Urn crashes on launch when global hotkeys are enabled Jul 29, 2023
@paoloose
Copy link
Owner

Not very familiar with the wayland ecosystem, but it might be a good idea if you report the problem on the Wayland Plasma forums, because GTK should be compatible with it. I'd appreciate some guidance as to whether this issue can be addressed on this side somehow. Also see the GDK_BACKEND=x11 env variable.

Here is the relevant block of code that is triggered when global hotkeys are enable

urn/urn-gtk.c

Lines 503 to 539 in 70cc5bf

if (win->global_hotkeys) {
keybinder_init();
keybinder_bind(
g_settings_get_string(settings, "keybind-start-split"),
(KeybinderHandler)keybind_start_split,
win
);
keybinder_bind(
g_settings_get_string(settings, "keybind-stop-reset"),
(KeybinderHandler)keybind_stop_reset,
win
);
keybinder_bind(
g_settings_get_string(settings, "keybind-cancel"),
(KeybinderHandler)keybind_cancel,
win
);
keybinder_bind(
g_settings_get_string(settings, "keybind-unsplit"),
(KeybinderHandler)keybind_unsplit,
win
);
keybinder_bind(
g_settings_get_string(settings, "keybind-skip-split"),
(KeybinderHandler)keybind_skip,
win
);
keybinder_bind(
g_settings_get_string(settings, "keybind-toggle-decorations"),
(KeybinderHandler)keybind_toggle_decorations,
win
);
keybinder_bind(
g_settings_get_string(settings, "keybind-toggle-win-on-top"),
(KeybinderHandler)keybind_toggle_win_on_top,
win
);

@kimbadim
Copy link
Author

Setting GDK_BACKEND to x11 does indeed allow urn to start but then global hotkeys don't work (so it's just like launching it with global-hotkeys set to false)

@paoloose
Copy link
Owner

So I found this issue from another GTK3 based project, the same what you described:

Basically, not much can be done on this side. Wayland seems to not support global hotkeys. Currently how global hotkeys are managed will depend on the desktop environment you are using. This issue from tauri links relevant discussions for some popular desktop environments, including KDE.

Also see this blog entry from a KDE dev about KDE Plasma 6

We already have global shortcuts working using the newer KGlobalAccel system, and we’d already hidden the KHotkeys config UI from System Settings on Wayland in Plasma 5. So we made the decision to double down on KGlobalAccel and just finally delete KHotkeys once and for all for Plasma 6, rather than awkwardly ship two parallel global shortcut systems, which was always very odd and really not justifiable at all. Mouse gestures can eventually be added to KGlobalAccel if someone takes an interest in doing so. No one’s opposed to it!

@paoloose
Copy link
Owner

paoloose commented Jul 30, 2023

So users dealing with this issue should rely on the workarounds of their desktop environments. I'll need to write a warning on the readme linking this issue for future wayland users, and maybe print some warning logs when running urn on wayland because global hotkeys won't work for them.

About the crash, I couldn't find something conclusive about what I should do, so I think I'll be forcing the GDK_BACKEND variable to x11 for now, maybe later, you can send a pull request if you wish to.

@paoloose paoloose added documentation Improvements or additions to documentation good first issue Good for newcomers labels Jul 30, 2023
@alterNERDtive
Copy link

The way to do global hotkeys in Wayland is … not to do global hotkeys. Instead, have command line options for the stuff you would usually hotkey; e.g. urn --start for starting the timer of an already running application instance. That can then be assigned as a “global hotkey” through the window manager / desktop environment.

Reason being that, by design and for quite basic security reasons, applications cannot receive keyboard input if they are not in focus.

@CodeWithMa
Copy link

Starting on Wayland with global hotkeys enabled should not crash. Maybe add a check if the program is running on Wayland and don't enable the global hotkey feature if Wayland is detected.

@paoloose
Copy link
Owner

paoloose commented Mar 5, 2024

Thanks for the insights @alterNERDtive. #19 was created to address this need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants