paperwm / PaperWM

Tiled scrollable window management for Gnome Shell
GNU General Public License v3.0
3.03k stars 127 forks source link

PaperWM settings crash when assigning certain keybindings #964

Open dnlbauer opened 1 week ago

dnlbauer commented 1 week ago

Describe the bug Trying to assign/changing certain keybinding crash the extension for me. It does not happen for all combinations of keybindings and mappings for me, but it is reproducable.

One example is if I try to assign "Switch to window or workspace above", I can successfully assign the unused Super+H to it. However, when trying to assign Super+Home, the settings menu crashes:

Syslog:

2024-10-28T09:20:01.091279+01:00 latitude-sgn gnome-shell[3439]: Window manager warning: Ping serial 4235200 was reused for window W86, previous use was for window W75.
2024-10-28T09:20:07.339477+01:00 latitude-sgn gjs[16533]: AdwToolbarView 0x5c32de834880 exceeds AdwBreakpointBin width: requested 650 px, 640 px available
2024-10-28T09:20:20.913814+01:00 latitude-sgn gjs[16533]: message repeated 68 times: [ AdwToolbarView 0x5c32de834880 exceeds AdwBreakpointBin width: requested 650 px, 640 px available]
2024-10-28T09:20:21.750261+01:00 latitude-sgn gjs[16533]: JS ERROR: TypeError: this.acceleratorParse is undefined#012get keycode@file:///home/dbauer/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/prefsKeybinding.js:247:35#012isValidBinding@file:///home/dbauer/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/prefsKeybinding.js:147:10#012_updateKeybinding@file:///home/dbauer/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/prefsKeybinding.js:795:37#012_onKeyPressed@file:///home/dbauer/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/prefsKeybinding.js:788:14#012_init/<@file:///home/dbauer/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/prefsKeybinding.js:658:18#012_init/GLib.MainLoop.prototype.runAsync/</<@resource:///org/gnome/gjs/modules/core/overrides/GLib.js:266:34
2024-10-28T09:20:22.284362+01:00 latitude-sgn kernel: gjs[16533]: segfault at 7e5a80 ip 00007e5a77db9090 sp 00007ffd45257c88 error 6 likely on CPU 0 (core 0, socket 0)
2024-10-28T09:20:22.284388+01:00 latitude-sgn kernel: Code: 00 00 d0 8b 74 82 5a 7e 00 00 70 80 17 df 32 5c 00 00 40 90 db 77 5a 7e 00 00 40 90 db 77 5a 7e 00 00 51 00 00 00 00 00 00 00 <c0> 8c db 77 5a 7e 00 00 00 8e db 77 5a 7e 00 00 00 0f 1f 80 00 00
2024-10-28T09:20:22.475957+01:00 latitude-sgn gnome-shell[3439]: meta_window_is_focusable: assertion '!window->unmanaging' failed

To Reproduce Steps to reproduce the behavior:

  1. Reset PaperWM config: dconf reset -f /org/gnome/shell/extensions/paperwm/
  2. Disable/Enable PaperWM via the toggle in the extension menu.
  3. Go to PaperWM Extensions->PaperWM->Settings->Keybindings
  4. Assign Super+Home to "Switch to window or workspace above"

Expected behavior The keybinding is correctly assigned.

Screenshots image

System information: PaperWM installed via extensions.gnome.org

Distribution: Ubuntu 24.04.1 LTS (Noble Numbat)
GNOME Shell: 46.0
Display server: Wayland
PaperWM version: 47.1.0
Enabled extensions:
- switcher@landau.fi
- paperwm@paperwm.github.com
- ubuntu-appindicators@ubuntu.com
- ubuntu-dock@ubuntu.com
dnlbauer commented 1 week ago

Small update on this: The issue seems to be related to assigning key bindings that are already assigned to other functions:

Super+C has a default assignment to "Center window horizontally". When I try to assign it to "Center window", the extension settings crash. However, if i first delete the assignment to "Center window horizontally", I can assign it to "Center window" successfully.

Lythenas commented 1 week ago

I can't reproduce this on my Ubuntu 23.10 VM with Gnome Shell 45.2. So this may be a regression with Gnome 46.

For me I can simply set the keybinding and it shows that it has a conflict with another keybinding.

On my arch linux machine with Gnome 47 I was able to reproduce it. But only once. Starting the settings again and doing the same actions works now... But I still get the JS exception:

Oct 29 15:14:32 anarchy gjs[117161]: JS ERROR: TypeError: this.acceleratorParse is undefined
                                     get keycode@file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/prefsKeybinding.js:247:35
                                     isValidBinding@file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/prefsKeybinding.js:147:45
                                     _updateKeybinding@file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/prefsKeybinding.js:795:37
                                     _onKeyPressed@file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/prefsKeybinding.js:788:14
                                     _init/<@file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/prefsKeybinding.js:658:18
                                     _init/GLib.MainLoop.prototype.runAsync/</<@resource:///org/gnome/gjs/modules/core/overrides/GLib.js:263:34

I also see this exception in Gnome 46, so I don't think it is causing the crash.

When it crashed I additionally got this:

Show ``` Oct 29 15:13:35 anarchy gjs[116849]: JS ERROR: TypeError: Object is of type .Keybinding - cannot convert to Combo _init/Gtk.Widget.prototype._init@resource:///org/gnome/gjs/modules/core/overrides/Gtk.js:39:56 _init@file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/prefsKeybinding.js:653:15 ComboRow@file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/prefsKeybinding.js:651:4 _createRow@file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/prefsKeybinding.js:955:21 _init/<@file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/prefsKeybinding.js:922:67 set collisions@file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/prefsKeybinding.js:708:26 _createRow/<@file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/prefsKeybinding.js:963:46 _onCollisionsChanged@file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/prefsKeybinding.js:986:14 _init/<@file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/prefsKeybinding.js:926:26 _updateCollisions@file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/prefsKeybinding.js:604:22 _init/<@file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/prefsKeybinding.js:518:18 _init/<@file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/prefsKeybinding.js:348:18 add@file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/prefsKeybinding.js:407:21 _updateKeybinding@file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/prefsKeybinding.js:801:29 _onKeyPressed@file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/prefsKeybinding.js:788:14 _init/<@file:///home/ms/.local/share/gnome-shell/extensions/paperwm@paperwm.github.com/prefsKeybinding.js:658:18 _init/GLib.MainLoop.prototype.runAsync/

plus a segfault.

I will try to take a look at this.

Lythenas commented 1 week ago

So I'm a bit stumped here. I managed to reproduce this only once and never again. Not even after rebooting...

Only looking at the stacktrace I posted above and the code, I couldn't figure out why this happens. It looks like at some point we try to use a Keybinding object as a Combo object. But in the code I don't see where this could be happening.

So unfortunately I'm not sure where to continue here :(

jtaala commented 1 day ago

Thanks for reporting @dnlbauer.

I'll try reproduce this one over the weekend.

  • Reset PaperWM config: dconf reset -f /org/gnome/shell/extensions/paperwm/
  • Disable/Enable PaperWM via the toggle in the extension menu.

Does this only occur on reset dconf? Given extensions inject into gnome shell itself, generally if you reset paperwm dconf settings it should be followed by a full logout/login (disabling/enabling doesn't actually reload extension extension code and prepare for extension load cycle).

There is some initialisation code in PaperWM that interacts with dconf (and user config files) and expects certain states etc.

Finally, PaperWM itself injects into the gnome shell instance, but extension settings don't (runs in it's own process separate from gnome shell). Prefs interact directly with dconf (and PaperWM, if running, receives signals from via gsettings). Hence, if you reset dconf while PaperWM is running, it will likely cause issues and desynchronisation (can't think of a better word) between settings (and keybindings) and paperwm.

One example is that paperwm will override gnome keybindings, and save (dconf) those original keybindings for restore when paperwm is disabled. Resetting dconf while paperwm is running, and then disabling paperwm will likely impact that and cause issues.

jtaala commented 23 hours ago

Anyways, that might not be to the problem but will have a look this weekend.

dnlbauer commented 23 hours ago

Hi,

Thanks for the details on the internals.

The issue came up before I resetted the config. I only included the config reset because I hoped that this would lead to a more reproduceable example.