Delay/freeze/cpu spike when using the function/media keys in Xorg
When I'm using Gnome-shell and I press and multimedia key or the Win a delay may happen. I press multimedia key, the delay happens, if I press it again the delay doesn't happen. But if I change to other key, like the Win key, the delay happen again. I've been observing when the delay happens there is a CPU spike in the gnome-monitor-system CPU usage graphic. Xorg process CPU usage increase to 100% of a CPU core. The problem seems to be with something related to Xorg.
See bellow the images with the CPU usage of Xorg and CPU Spike:
It's showing only 8% but it reached 12%, which is 100% of core in my 8 core system.
When the delay happens I see the following lines in my system-log:
mai 19 19:15:57 watchmen org.gnome.Shell.desktop[3198]: Window manager warning: Overwriting existing binding of keysym 32 with keysym 32 (keycode b).
mai 19 19:15:57 watchmen org.gnome.Shell.desktop[3198]: Window manager warning: Overwriting existing binding of keysym 34 with keysym 34 (keycode d).
mai 19 19:15:57 watchmen org.gnome.Shell.desktop[3198]: Window manager warning: Overwriting existing binding of keysym 35 with keysym 35 (keycode e).
mai 19 19:15:57 watchmen org.gnome.Shell.desktop[3198]: Window manager warning: Overwriting existing binding of keysym 37 with keysym 37 (keycode 10).
mai 19 19:15:57 watchmen org.gnome.Shell.desktop[3198]: Window manager warning: Overwriting existing binding of keysym 31 with keysym 31 (keycode a).
mai 19 19:15:57 watchmen org.gnome.Shell.desktop[3198]: Window manager warning: Overwriting existing binding of keysym 36 with keysym 36 (keycode f).
mai 19 19:15:57 watchmen org.gnome.Shell.desktop[3198]: Window manager warning: Overwriting existing binding of keysym 33 with keysym 33 (keycode c).
mai 19 19:15:57 watchmen org.gnome.Shell.desktop[3198]: Window manager warning: Overwriting existing binding of keysym 39 with keysym 39 (keycode 12).
mai 19 19:15:57 watchmen org.gnome.Shell.desktop[3198]: Window manager warning: Overwriting existing binding of keysym 38 with keysym 38 (keycode 11).
Looking for a way to fix this problem I saw this post: https://askubuntu.com/questions/906723/fn-media-keys-slow-delayed-on-ubuntu-gnome-17-04
And this was the fix https://askubuntu.com/a/1072160
I saw the same fix in other places: https://askbot.fedoraproject.org/en/question/106816/gnome-shell-input-lag-when-using-multimedia-keys/ https://i.reddit.com/r/gnome/comments/84453o/delayfreezecpu_spike_when_using_the_functionmedia/ and https://wiki.archlinux.org/index.php/GNOME/Troubleshooting#Gnome_freezes_for_a_second_after_using_a_Function_(Fn)_key_shortcut
But I'm not using a Brazilian keyboard. I'm using an US Keyboard with Mac variant. See the localectl output:
System Locale: LANG=en_US.UTF-8
LANGUAGE=en_US:en
VC Keymap: n/a
X11 Layout: us
X11 Model: pc105
X11 Variant: mac
There isn't a modifier_map Mod3 { Scroll_Lock };
inside the file /usr/share/X11/xkb/symbols/us. So I'm not able to apply this fix.
Only happens when using Gnome-shell with Xorg. Tested in Ubuntu 19.04 and Fedora Silver Blue 30. It happens with both Nvidia and Nouveau graphic driver. Doesn't happen in KDE Plasma and XFCE4.