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

High CPU use when focus is on kitty window under Wayland #5105

Closed
tristpinsm opened this issue May 16, 2022 · 11 comments
Closed

High CPU use when focus is on kitty window under Wayland #5105

tristpinsm opened this issue May 16, 2022 · 11 comments
Labels

Comments

@tristpinsm
Copy link

I've noticed that when a kitty window is focused, the CPU used by the gnome-shell and ibus-daemon processes shoots up to over 100%. It goes back down when the focus moves to any other window. This only happens with kitty as far as I can tell, and it goes away if I set linux_display_server x11 in kitty.conf.

To Reproduce
Steps to reproduce the behavior:

  1. Set the focus to a kitty window under Wayland.
  2. Watch the CPU use of gnome-shell and ibus-daemon go up in top.

Environment details

kitty 0.25.0 created by Kovid Goyal
Linux tristXPS 5.17.7-arch1-1 #1 SMP PREEMPT Thu, 12 May 2022 18:55:54 +0000 x86_64
Arch Linux 5.17.7-arch1-1 (/dev/tty)

DISTRIB_ID="Arch"
DISTRIB_RELEASE="rolling"
DISTRIB_DESCRIPTION="Arch Linux"
Running under: Wayland
Frozen: False
Paths:
  kitty: /usr/bin/kitty
  base dir: /usr/lib/kitty
  extensions dir: /usr/lib/kitty/kitty
  system shell: /bin/zsh
Loaded config files:
  /home/tristan/.config/kitty/kitty.conf

Config options different from defaults:
font_family          Inconsolata Regular
font_size            12.0
shell_integration    frozenset({'no-cursor'})
Added shortcuts:
	shift+page_up → scroll_page_up
	shift+page_down → scroll_page_down
Colors:
	background           #485867   
	color0               #485867   
	color1               #b38686   
	color10              #87b386   
	color11              #aab386   
	color12              #868cb3   
	color13              #b386b2   
	color14              #86b3b3   
	color15              #e3efef   
	color16              #d8bba2   
	color17              #b39f9f   
	color18              #5a6d7a   
	color19              #6d828e   
	color2               #87b386   
	color20              #98afb5   
	color21              #c9dbdc   
	color3               #aab386   
	color4               #868cb3   
	color5               #b386b2   
	color6               #86b3b3   
	color7               #b0c5c8   
	color8               #8299a1   
	color9               #b38686   
	cursor               #c9dbdc   
	foreground           #b0c5c8   
	selection_background #c9dbdc   
	selection_foreground #485867   

Important environment variables seen by the kitty process:
	PATH                                /usr/local/bin:/usr/bin:/var/lib/snapd/snap/bin:/usr/local/sbin:/var/lib/flatpak/exports/bin:/opt/fv:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
	LANG                                en_CA.UTF-8
	SHELL                               /bin/zsh
	DISPLAY                             :0
	WAYLAND_DISPLAY                     wayland-0
	USER                                tristan
	XDG_MENU_PREFIX                     gnome-
	XDG_SESSION_DESKTOP                 gnome
	XDG_SESSION_TYPE                    wayland
	XDG_CURRENT_DESKTOP                 GNOME
	XDG_SESSION_CLASS                   user
	XDG_RUNTIME_DIR                     /run/user/1000
	XDG_DATA_DIRS                       /home/tristan/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop

Additional context
The problem persists with kitty --config NONE.

@tristpinsm tristpinsm added the bug label May 16, 2022
@kovidgoyal
Copy link
Owner

Sigh, more awesomeness from GNOME 42. When I return from travelling I
will investigate if there is something I can do in kitty's Wayland
backend to work around GNOME. At least I can reproduce this one, instead
of it being because of timing issues in mutter.

@fezboy
Copy link

fezboy commented May 17, 2022

This seems to have been introduced in #4855, as it is present at 11343d4, but not 6c628bc

@kovidgoyal
Copy link
Owner

Yes, quite likely, maybe @page-down wants to take a look, otherwise I will investigate when I return.

@v-ji
Copy link

v-ji commented May 19, 2022

At least for me, running kitty with --debug-keyboard shows a flood of events that don’t appear with X11:

...
text-input: enter event
text-input: done event: serial: 11 current_commit_serial: 11
on_key_input: glfw key: 0x0 native_code: 0x0 action: RELEASE mods: none text: '' state: 1 
text-input: updating cursor position: left=16 top=16 width=9 height=19
updated pre-edit text: ''
text-input: done event: serial: 12 current_commit_serial: 12
on_key_input: glfw key: 0x0 native_code: 0x0 action: RELEASE mods: none text: '' state: 1 
text-input: updating cursor position: left=16 top=16 width=9 height=19
updated pre-edit text: ''
text-input: done event: serial: 13 current_commit_serial: 13
on_key_input: glfw key: 0x0 native_code: 0x0 action: RELEASE mods: none text: '' state: 1 
text-input: updating cursor position: left=16 top=16 width=9 height=19
updated pre-edit text: ''
text-input: done event: serial: 14 current_commit_serial: 14
on_key_input: glfw key: 0x0 native_code: 0x0 action: RELEASE mods: none text: '' state: 1 
text-input: updating cursor position: left=16 top=16 width=9 height=19
updated pre-edit text: ''
...

There’s multiple hundreds of these per second.

@page-down
Copy link
Contributor

Sorry for introducing this issue. However in the meantime I am also temporarily unable to access the test environment and I may need more time to come back.

If I remember correctly, the send_text mentioned in the association above is just a request to kitty to clear the pre-edit text, not sure why it would affect other processes and lead to a higher cpu usage. I may have missed something.

@kovidgoyal
Copy link
Owner

Seems like kitty is clearing pre-edit text, reporting it to gnome, gnome is telling it to clear the pre-edit text again in an endless loop. Probably just ignore the request to clear pre-edit text if it is already cleared, but I have to look at it in more detail when I have some time

@mo8it
Copy link

mo8it commented May 21, 2022

I am on Fedora Silverblue, the problem did only appear after the upgrade today to Gnome 42.1.
I did boot into the last image to verify that the issue is only on Gnome 42.1 and this is the case.
The upgrade that did cause this is the following:

Upgraded:
  gnome-classic-session 42.0-1.fc36 -> 42.1-2.fc36
  gnome-shell 42.0-3.fc36 -> 42.1-2.fc36
  gnome-shell-extension-apps-menu 42.0-1.fc36 -> 42.1-2.fc36
  gnome-shell-extension-common 42.0-1.fc36 -> 42.1-2.fc36
  gnome-shell-extension-launch-new-instance 42.0-1.fc36 -> 42.1-2.fc36
  gnome-shell-extension-places-menu 42.0-1.fc36 -> 42.1-2.fc36
  gnome-shell-extension-window-list 42.0-1.fc36 -> 42.1-2.fc36
  gtk-update-icon-cache 3.24.33-1.fc36 -> 3.24.34-1.fc36
  gtk3 3.24.33-1.fc36 -> 3.24.34-1.fc36
  mutter 42.0-6.fc36 -> 42.1-2.fc36

I hope that this is somehow helpful :)

@Gabriel-Alves-Cunha
Copy link

Hi, I'm on Fedora Linux 36 (Workstation Edition) with GNOME 42.1 on Wayland.
I also just had this problem when I noticed it was only when kitty was on focus.
I was using the most updated version and then I downgraded to 0.24.4 and the problem was gone.
Just came here to file a bug and saw this one :)

@mo8it
Copy link

mo8it commented May 23, 2022

@kovidgoyal

I don't want to put any pressure, but can you please make a release with the fix soon? Thanks :)

@kovidgoyal
Copy link
Owner

Just use the nightly builds

@gitaarik
Copy link

Thanks, the issue disappeared with the nightly build :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants