After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 670164 - Hangs for 20-30 seconds after tty switch
Hangs for 20-30 seconds after tty switch
Status: RESOLVED FIXED
Product: libgnomekbd
Classification: Core
Component: Config
3.3.x
Other Linux
: Normal normal
: ---
Assigned To: libgnomekbd maintainers
Sergey V. Udaltsov
: 672729 672848 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2012-02-15 20:19 UTC by Mantas Mikulėnas (grawity)
Modified: 2012-03-26 20:05 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
config: plug minor leak (1.16 KB, patch)
2012-03-21 20:54 UTC, Ray Strode [halfline]
committed Details | Review
config: make gkbd_keyboard_config_equals more forgiving (2.41 KB, patch)
2012-03-21 20:54 UTC, Ray Strode [halfline]
reviewed Details | Review
config: make gkbd_keyboard_config_equals more forgiving (2.67 KB, patch)
2012-03-22 20:08 UTC, Ray Strode [halfline]
none Details | Review
Fix up split_items usage (1.28 KB, patch)
2012-03-26 14:46 UTC, Ray Strode [halfline]
none Details | Review

Description Mantas Mikulėnas (grawity) 2012-02-15 20:19:33 UTC
Whenever I switch to a different tty, then back to the graphical session, or if I suspend and resume the system, GNOME Shell freezes for approx. 20 seconds. The cursor still moves around, but windows do not react to clicks.

The `mutter` and `metacity -c` window managers are also affected. (However, other compositing WMs such as Compiz and KWin aren't.)

The GDM login screen is not affected by this.

Using gnome-shell 3.2.2.1 (Arch Linux) with ATI Radeon graphics (xf86-video-ati 6.14.3, "Gallium 0.4 on AMD CEDAR") on Linux 3.2.6-1-ARCH.
Comment 1 Jasper St. Pierre (not reading bugmail) 2012-02-16 01:19:39 UTC
I see this too. Interestingly, if I have a hung gnome-shell, and then try to replace with metacity, it takes about 10-20 seconds before I can interact with any windows again.
Comment 2 Ray Strode [halfline] 2012-02-16 16:59:47 UTC
(also see bug 653833 comment 13 and related for some earlier discussion about this problem)
Comment 3 Jasper St. Pierre (not reading bugmail) 2012-02-16 17:02:30 UTC
As a quick hack workaround (thanks Ray!):

  $ gsettings set org.gnome.settings-daemon.plugins.keyboard active false
  $ sudo mv /usr/bin/xkbcomp{,.bak}
  $ sudo ln -s /bin/true /usr/bin/xkbcomp

Note that this disables the GNOME code for manipulating keyboard stuff, so things like Alt-<Above_Tab> may break.
Comment 4 Ray Strode [halfline] 2012-02-24 02:30:58 UTC
I dug into this briefly on the 15th/16th and started to get a picture on what was going on, but didn't quite figure out all the details before I put it down.  I haven't picked it back up since, and I don't know if I'll get back to it for a while, so I thought I should post details now before I forget them.

It seems like gnome-settings-daemon and gnome-shell are in a bit of fight, mucking with the keyboard settings. I think gnome-shell is doing it's alt-above-tab thing, and gnome-settings-daemon is doing it's layout options (like where compose key is).

I my case, the fight was because libgnomekbd didn't think the two options were equal, since one had the name "compose" and one had the name "Compose Key".

running 

gnome-control-center region
Clicking "Layouts"
Clicking "Options"
and then unchecking all the bold entries so there no bold entries

makes the problem go away for me.  It shouldn't be too hard to figure out what's going on from here, and I'll look at some point.
Comment 5 Owen Taylor 2012-02-27 15:02:10 UTC
(In reply to comment #4)
> I dug into this briefly on the 15th/16th and started to get a picture on what
> was going on, but didn't quite figure out all the details before I put it down.
>  I haven't picked it back up since, and I don't know if I'll get back to it for
> a while, so I thought I should post details now before I forget them.
> 
> It seems like gnome-settings-daemon and gnome-shell are in a bit of fight,
> mucking with the keyboard settings. I think gnome-shell is doing it's
> alt-above-tab thing, and gnome-settings-daemon is doing it's layout options
> (like where compose key is).

Mutter simply passively reads layout information, so it's hard to see how it would "fight" with gnome-settings-daemon; the only thing I can think of is that somehow the layout is being changed many times, and reading geometry information each time makes that more expensive.
Comment 6 Ray Strode [halfline] 2012-02-28 00:23:37 UTC
I'll have to dig back into it before i can give any sort of clear answer, but it was calling XkbGetKeyboard() which under the hood made the X server run xkbcomp which woke up gnome-settings-daemon which made libxklavier (or something) wake up and do something that made gnome-shell wake up again, etc etc
Comment 7 Ray Strode [halfline] 2012-03-21 20:49:09 UTC
okay, i looked into this a little more.  Here's what happening (as far as I understand it):

- On VT switch the keyboard gets hotplugged back into action
- gsd wakes up with the "X-new-device" signal in libxklavier
- It looks at gsettings and tries to figure out what modifications to apply to 
  the device (such as the compose key).  They come from gsettings in the form 
  "Compose key\tcompose:ralt".  The "Compose key" part is an id shipped in 
  xkeyboard-config that the control-center region panel options dialog uses 
  enumerating and identifying options. libgnomekbd calls that part the 
  "option group" and the other part the "option".
- gnome-settings-daemon asks libgnomekbd if the proposed modifications are 
  different from the current configuration. libgnomekbd completes the request 
  by:
   - first loading up the current configuration from the _XKB_RULES_NAMES root 
     window property.
   - comparing it to the proposed configuration 1 by 1.  In order for the 
     function to succeed, the configuration items from the current config 
     and the proposed config need to be in the same order,
     and have the same options with the same option group names.  Note 
     the _XKB_RULES_NAMES property doesn't ever have a copy of the stored
     option group names in it, it only has the options themselves.  So the
     current configuration will never match equal to a proposed configuration
     that contains option group names. For reference, an example of the
     _XKB_RULES_NAMES property is something like:

     _XKB_RULES_NAMES(STRING) = <layout stuff here>,
                                "compose:ralt,terminate:ctrl_alt_bksp"

- Since the current configuration and proposed configuration won't show up equal, libgnomekbd uses libxklavier to apply the new configuration.  This causes all sorts of stuff to happen including forking a call to xkbcomp, which makes all the machinery start over and wake up again. Thus the tight loop.  I don't know why the loop eventually stops after 30-45 seconds.
- All the while, gnome-shell is waking up in a loop trying to refind where the the key above tab is each time the keyboard is mucked with.

moving to libgnomekbd
Comment 8 Ray Strode [halfline] 2012-03-21 20:54:34 UTC
Created attachment 210291 [details] [review]
config: plug minor leak

gkbd_keyboard_config_split_items allocates its out args, but
those allocations aren't getting cleaned up in
gkbd_keyboard_config_copy_to_xkl_config

This commit plugs that leak.
Comment 9 Ray Strode [halfline] 2012-03-21 20:54:37 UTC
Created attachment 210292 [details] [review]
config: make gkbd_keyboard_config_equals more forgiving

options should be able to appear in different orders,
or have different group names and still appear as equal.

This commit makes gkbd_keyboard_config_equals more
forgiving.
Comment 10 Ray Strode [halfline] 2012-03-21 20:59:48 UTC
attachment 210292 [details] [review] breaks the cycle by making the equality check by e.g. considering "Compose key\tcompose:ralt" and "compose:ralt" equal .
Comment 11 Matthias Clasen 2012-03-22 02:19:11 UTC
Review of attachment 210291 [details] [review]:

Looks correct to me
Comment 12 Matthias Clasen 2012-03-22 02:22:39 UTC
Review of attachment 210292 [details] [review]:

Might make sense to factor that out as a compare_options() function ?
Comment 13 Ray Strode [halfline] 2012-03-22 20:08:15 UTC
Created attachment 210378 [details] [review]
config: make gkbd_keyboard_config_equals more forgiving

options should be able to appear in different orders,
or have different group names and still appear as equal.

This commit makes gkbd_keyboard_config_equals more
forgiving.
Comment 14 Ray Strode [halfline] 2012-03-22 20:20:00 UTC
Comment on attachment 210291 [details] [review]
config: plug minor leak

looks like svu already pushed this one, so marking it as so.
Comment 15 Sergey V. Udaltsov 2012-03-23 09:49:30 UTC
Thank you! All commited.
Comment 16 Gert Kulyk 2012-03-25 17:53:59 UTC
Seems like the commited memleak fix is crashing g-s-d, see bug #672729
Comment 17 Sergey V. Udaltsov 2012-03-25 18:13:14 UTC
Damnit! Stupid me. The split function does not allocate the memory! It is using the static buffers. That is why the first patch should be reverted. I will do release libgnomekbd 3.4.0.1
Comment 18 Sergey V. Udaltsov 2012-03-25 22:11:56 UTC
The patch is reverted.
Comment 19 Ray Strode [halfline] 2012-03-26 14:44:30 UTC
my fault, I should have went back and double checked that assumption.  We're going to need fixes in the other commit as well, since it also calls split_items.
Comment 20 Ray Strode [halfline] 2012-03-26 14:46:07 UTC
Created attachment 210626 [details] [review]
Fix up split_items usage

commit c9d3c0e939c21230d6088aaf915d9b7d965d97d8 introduced a couple
of calls to gkbd_keyboard_config_split_items with the incorrect
assumption that those calls return newly allocated memory.

This commit drops the wrong free calls.
Comment 21 Sergey V. Udaltsov 2012-03-26 14:56:49 UTC
Will commit tonight and release 3.4.0.2
Comment 22 Ray Strode [halfline] 2012-03-26 15:04:26 UTC
*** Bug 672848 has been marked as a duplicate of this bug. ***
Comment 23 Ray Strode [halfline] 2012-03-26 15:05:10 UTC
Thanks, svu.
Comment 24 Sergey V. Udaltsov 2012-03-26 19:27:36 UTC
*** Bug 672729 has been marked as a duplicate of this bug. ***
Comment 25 Sergey V. Udaltsov 2012-03-26 20:05:50 UTC
3.4.0.2 is available