Starting GNOME Shell under X11 with ibus already running could cause an hard lock-up
As per commit 8adfc5b1 (and parent commit 8be95b57) shell manages the ibus restarting when X11 server is there already, however we might end up in a race if we were already in connected to a daemon that we spawned on startup or if there was already one in place in the session before launching the shell.
The race is quite bad because the callback in
Keyboard._inputSourcesChanged() might lead to further ibus calls causing it to get the X11 pointer and keyboard grab, which makes impossible to interact with the whole desktop.
We have various random reproducers in Ubuntu, but it can be reproduced with 100% accuracy in the installer (that was starting ibus-daemon before the shell).
This is some interesting logging with debug (some real-scenario logging from an ubuntu session is here):
current session already has an ibus-daemon (gnome-shell:11725): Gjs-WARNING **: 18:42:38.448: JS ERROR: Gio.DBusError: Connection is closed. _setContext@/tmp/js/misc/inputMethod.js:63:25 (gnome-shell:11725): IBUS-CRITICAL **: 18:42:38.482: ibus_bus_call_async: assertion 'ibus_bus_is_connected (bus)' failed == Stack trace for context 0x55ce024d53f0 == #0 55ce027e4dc0 i /tmp/js/misc/ibusManager.js:137 (7fc089a68160 @ 423) #1 7fff152634c0 b self-hosted:979 (7fc08962c1f0 @ 440) (gnome-shell:11725): IBUS-CRITICAL **: 18:42:38.513: ibus_bus_call_async: assertion 'ibus_bus_is_connected (bus)' failed == Stack trace for context 0x55ce024d53f0 == #0 55ce027e50a0 i /tmp/js/misc/ibusManager.js:209 (7fc089a68820 @ 84) #1 55ce027e5008 i /tmp/js/ui/status/keyboard.js:472 (7fc089a64700 @ 175) #2 7fff1525fcd0 b self-hosted:979 (7fc08962c1f0 @ 440) #3 7fff1525fdc0 b resource:///org/gnome/gjs/modules/signals.js:135 (7fc089fc5550 @ 376) #4 55ce027e4f78 i /tmp/js/ui/status/keyboard.js:55 (7fc089a62280 @ 27) #5 7fff15260d40 b /tmp/js/ui/status/keyboard.js:604 (7fc089a648b0 @ 1883) #6 55ce027e4ef8 i /tmp/js/ui/status/keyboard.js:363 (7fc089a643a0 @ 67) #7 7fff15261e20 b self-hosted:979 (7fc08962c1f0 @ 440) #8 7fff15261f10 b resource:///org/gnome/gjs/modules/signals.js:135 (7fc089fc5550 @ 376) #9 55ce027e4e68 i /tmp/js/misc/ibusManager.js:156 (7fc089a68430 @ 76) #10 55ce027e4dc0 i /tmp/js/misc/ibusManager.js:148 (7fc089a68160 @ 439) #11 7fff152634c0 b self-hosted:979 (7fc08962c1f0 @ 440) GNOME Shell-Message: 18:42:39.210: Error looking up permission: GDBus.Error:org.freedesktop.portal.Error.NotFound: No entry for geolocation GNOME Shell-Message: 18:42:41.431: GNOME Shell started at Wed Sep 25 2019 18:42:37 GMT+0000 (UTC)