Bug 444536 - Compositor slows down to ~1fps after changing any of the compositor settings or restarting kwin
Summary: Compositor slows down to ~1fps after changing any of the compositor settings ...
Status: CONFIRMED
Alias: None
Product: kwin
Classification: Plasma
Component: compositing (show other bugs)
Version: 5.24.90
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
: 433664 445673 451125 454843 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-10-28 12:04 UTC by Piotr Mitas
Modified: 2023-02-15 11:21 UTC (History)
12 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Display configuration that replicates this bug (46.75 KB, image/png)
2022-06-11 10:13 UTC, Opal
Details
Screen Configuration - my setup could not reproduce the reported issue (161.01 KB, image/png)
2022-08-31 23:39 UTC, Magno Lomardo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Piotr Mitas 2021-10-28 12:04:59 UTC
SUMMARY
Compositor slows down to ~1fps after changing any of the compositor settings. It can also be triggered by running `kwin --replace`. The only way I found of fixing this is to log out and back in. 

STEPS TO REPRODUCE
1. Log in to KDE. The compositor runs smoothly
2. Change compositor settings or restart kwin with `kwin --replace`.
3. Compositor now runs extremely slowly, around 1 fps.


SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: Ubuntu 21.04
(available in About System)
KDE Plasma Version: 5.21.4
KDE Frameworks Version: 5.80.0
Qt Version: 5.12.2

ADDITIONAL INFORMATION
Video demonstrating the issue: https://photos.app.goo.gl/373CiNmyF4MGjUZU6

There is no significant CPU or GPU utilization when the problem is triggered.

The only way I found to make the desktop usable again without logging out is to change the compositor engine to XRender.

kwin --replace prints the following:
 pmitas@pmitas-ThinkPad-T490  ~  kwin --replace &
[1] 54579
 ⚙ pmitas@pmitas-ThinkPad-T490  ~  kwin_xkbcommon: XKB: /usr/share/X11/locale/en_US.UTF-8/Compose:5079:46: this compose sequence is a duplicate of another; skipping line
kwin_xkbcommon: XKB: /usr/share/X11/locale/en_US.UTF-8/Compose:5081:48: this compose sequence is a duplicate of another; skipping line
kwin_xkbcommon: XKB: /usr/share/X11/locale/en_US.UTF-8/Compose:5083:48: this compose sequence is a duplicate of another; skipping line
kwin_xkbcommon: XKB: /usr/share/X11/locale/en_US.UTF-8/Compose:5087:47: this compose sequence is a duplicate of another; skipping line
kwin_xkbcommon: XKB: /usr/share/X11/locale/en_US.UTF-8/Compose:5089:46: this compose sequence is a duplicate of another; skipping line
kwin_xkbcommon: XKB: /usr/share/X11/locale/en_US.UTF-8/Compose:5097:48: this compose sequence is a duplicate of another; skipping line
kwin_xkbcommon: XKB: /usr/share/X11/locale/en_US.UTF-8/Compose:5101:46: this compose sequence is a duplicate of another; skipping line
kwin_xkbcommon: XKB: /usr/share/X11/locale/en_US.UTF-8/Compose:5103:46: this compose sequence is a duplicate of another; skipping line
kwin_xkbcommon: XKB: /usr/share/X11/locale/en_US.UTF-8/Compose:5107:45: this compose sequence is a duplicate of another; skipping line
kwin_xkbcommon: XKB: /usr/share/X11/locale/en_US.UTF-8/Compose:5110:46: this compose sequence is a duplicate of another; skipping line
 ⚙ pmitas@pmitas-ThinkPad-T490  ~  OpenGL vendor string:                   Intel
OpenGL renderer string:                 Mesa Intel(R) UHD Graphics 620 (WHL GT2)
OpenGL version string:                  4.6 (Compatibility Profile) Mesa 21.0.3
OpenGL shading language version string: 4.60
Driver:                                 Intel
GPU class:                              Unknown
OpenGL version:                         4.6
GLSL version:                           4.60
Mesa version:                           21.0.3
X server version:                       1.20.11
Linux kernel version:                   5.11
Requires strict binding:                yes
GLSL shaders:                           yes
Texture NPOT support:                   yes
Virtual Machine:                        no
kwin_core: XCB error: 10 (BadAccess), sequence: 3883, resource id: 1998, major code: 142 (Composite), minor code: 2 (RedirectSubwindows)
Comment 1 Alex Dănilă 2022-01-07 21:47:03 UTC
I can reproduce this exactly as reported, here is my relevant part of the reporter's log:

OpenGL vendor string:                   Intel Open Source Technology Center
OpenGL renderer string:                 Mesa DRI Intel(R) HD Graphics 4600 (HSW GT2)
OpenGL version string:                  4.5 (Core Profile) Mesa 21.3.3
OpenGL shading language version string: 4.50
Driver:                                 Intel
GPU class:                              Haswell
OpenGL version:                         4.5
GLSL version:                           4.50
Mesa version:                           21.3.3
X server version:                       1.20.13
Linux kernel version:                   5.15
Requires strict binding:                yes
GLSL shaders:                           yes
Texture NPOT support:                   yes
Virtual Machine:                        no
kwin_core: XCB error: 10 (BadAccess), sequence: 6512, resource id: 408, major code: 142 (Composite), minor code: 2 (RedirectSubwindows)
Comment 2 Bohdan Tymkiv 2022-01-17 14:16:33 UTC
I am facing exactly the same issue. 

* System information:

Operating System: Kubuntu 21.10
KDE Plasma Version: 5.23.5
KDE Frameworks Version: 5.90.0
Qt Version: 5.15.2
Kernel Version: 5.13.0-25-generic (64-bit)
Graphics Platform: X11
Processors: 16 × Intel® Core™ i7-10700K CPU @ 3.80GHz
Memory: 15,5 GiB of RAM
Graphics Processor: Mesa Intel® UHD Graphics 630

* Relevant log:

void@i7:~$ kwin --replace &
[1] 8638
void@i7:~$ Warning: Setting a new default format with a different version or profile after the global shared context is created may cause issues with context sharing.
kwin_xkbcommon: XKB: /usr/share/X11/locale/en_US.UTF-8/Compose:5089:46: this compose sequence is a duplicate of another; skipping line
kwin_xkbcommon: XKB: /usr/share/X11/locale/en_US.UTF-8/Compose:5091:48: this compose sequence is a duplicate of another; skipping line
kwin_xkbcommon: XKB: /usr/share/X11/locale/en_US.UTF-8/Compose:5093:48: this compose sequence is a duplicate of another; skipping line
kwin_xkbcommon: XKB: /usr/share/X11/locale/en_US.UTF-8/Compose:5097:47: this compose sequence is a duplicate of another; skipping line
kwin_xkbcommon: XKB: /usr/share/X11/locale/en_US.UTF-8/Compose:5099:46: this compose sequence is a duplicate of another; skipping line
kwin_xkbcommon: XKB: /usr/share/X11/locale/en_US.UTF-8/Compose:5107:48: this compose sequence is a duplicate of another; skipping line
kwin_xkbcommon: XKB: /usr/share/X11/locale/en_US.UTF-8/Compose:5111:46: this compose sequence is a duplicate of another; skipping line
kwin_xkbcommon: XKB: /usr/share/X11/locale/en_US.UTF-8/Compose:5113:46: this compose sequence is a duplicate of another; skipping line
kwin_xkbcommon: XKB: /usr/share/X11/locale/en_US.UTF-8/Compose:5117:45: this compose sequence is a duplicate of another; skipping line
kwin_xkbcommon: XKB: /usr/share/X11/locale/en_US.UTF-8/Compose:5120:46: this compose sequence is a duplicate of another; skipping line
OpenGL vendor string:                   Intel
OpenGL renderer string:                 Mesa Intel(R) UHD Graphics 630 (CML GT2)
OpenGL version string:                  4.6 (Compatibility Profile) Mesa 21.2.2
OpenGL shading language version string: 4.60
Driver:                                 Intel
GPU class:                              Comet Lake
OpenGL version:                         4.6
GLSL version:                           4.60
Mesa version:                           21.2.2
X server version:                       1.20.13
Linux kernel version:                   5.13
Requires strict binding:                yes
GLSL shaders:                           yes
Texture NPOT support:                   yes
Virtual Machine:                        no
kwin_core: XCB error: 10 (BadAccess), sequence: 2129, resource id: 1901, major code: 142 (Composite), minor code: 2 (RedirectSubwindows)
Comment 3 Marco 2022-03-07 11:50:08 UTC
I am also facing the same issue, and I would say it is quite severe. Anything that tries to do something with the compositor will cause the problem. Even running an emulator like PPSSPP, and then closing it will cause the issue.

This problem makes kwin and thus the whole plasma desktop essentially unusable for most use cases.
Comment 4 David Edmundson 2022-03-24 16:32:47 UTC
*** Bug 433664 has been marked as a duplicate of this bug. ***
Comment 5 David Edmundson 2022-03-24 16:37:47 UTC
*** Bug 445673 has been marked as a duplicate of this bug. ***
Comment 6 David Edmundson 2022-03-24 16:38:06 UTC
*** Bug 451125 has been marked as a duplicate of this bug. ***
Comment 7 Opal 2022-06-10 18:51:56 UTC
I had the same problem. Figured out it only happened when one of my monitors (34 inch 2k) was connected (using Thunderbolt). When it's just my laptop screen or my 1080p HDMI screen everything was fine. Couldn't replicate it on a different user so I gathered it had to be config related.
So, deleting monitor configurations fixed it:
rm -rf ~/.local/share/kscreen
Hope this helps someone :)
Comment 8 Zamundaaa 2022-06-11 01:02:55 UTC
*** Bug 454843 has been marked as a duplicate of this bug. ***
Comment 9 Opal 2022-06-11 10:12:14 UTC
(In reply to Opal from comment #7)
> I had the same problem. Figured out it only happened when one of my monitors
> (34 inch 2k) was connected (using Thunderbolt). When it's just my laptop
> screen or my 1080p HDMI screen everything was fine. Couldn't replicate it on
> a different user so I gathered it had to be config related.
> So, deleting monitor configurations fixed it:
> rm -rf ~/.local/share/kscreen
> Hope this helps someone :)

Sadly, that didn't actually solve it as it kept coming back, 
but I've found the setting that does it, at least for me: I have my 1080p laptop screen on the left of my 2k monitor. By default, the laptop monitor in aligned to the top of the 2k one, if I change that to the middle or bottom position and restart KWin, this replicates the issue. And vice versa reverting that change and restarting KWin solves it.
A couple more things:
1. I can also replicate this with my external 1080p monitor instead of the laptop one.
2. I've replicated this both with a dual monitor and a triple monitor setup, however it only happens when the realigned 1080p monitor is on the left, changing the alignment for the screen on the right doesn't replicate this issue.

I'll attach a screenshot to demonstrate this setting. Curious if others experiencing this have the same cause as me?
Comment 10 Opal 2022-06-11 10:13:42 UTC
Created attachment 149614 [details]
Display configuration that replicates this bug
Comment 11 TrianguloY 2022-06-19 22:05:01 UTC
Another solution is to use the environment variable KWIN_X11_REFRESH_RATE and set your own refresh rate, which also solves the issue (but forces you to choose the refresh rate and it won't adapt dynamically).

As other pointed in a different thread, the issue seems to happen if the top-left corner of the whole desktop (the minimal rectangle which encloses/contains the screen sub-rectangles) doesn't correspond to any screen. What I mean is: if you set a screen at the top left, you are good. But if you move it slightly down or put another at the right and upper, it will fail.

Maybe the code needs a default screen to check some properties, and tries to fetch the top-left one (probably the 0,0 coordinate?) So when nothing is there it simply fails and sets 1fps as a result?
Comment 12 Magno Lomardo 2022-08-31 23:39:47 UTC
Created attachment 151747 [details]
Screen Configuration - my setup could not reproduce the reported issue

I could not reproduce the issue on my setup.
I did run "kwin_x11 --replace" since I don't use wayland, but the behaviour was the same as before.
The only noted difference is when I try to record my screen using OBS (flatpak version), then it will add a black square around the pointer.
I attached a screenshot of my settings, if I can provide more info to help I would need guidance in what info and how to get that.
Hope it helps!
Comment 13 Alex Dănilă 2022-10-06 19:10:51 UTC
For me this used to reproduce every time, now it cannot reproduce anymore. Up to date Debian Unstable.
Comment 14 Nate Graham 2022-10-07 07:09:36 UTC
Thanks for the info, folks. What about you, Piotr?
Comment 15 Marco 2023-02-15 11:21:26 UTC
For me, the issue still appears. If I have my 1080p monitor connected to my laptop, changing essentially anything related to kwin, like window decorations, everything slows down. Even when running a Game (which I guess disables and then re-enables the compositing) will then make everything sluggish.
If I have no monitor connected, the issue cannot be reproduced. I am on Plasma 5.26.5, with NVIDIA proprietary drivers (although I believe this does not matter, as also with my integrated Intel GPU I have the same issue).