Bug 490790 - Occasional low-FPS during effect animations since a couple of versions
Summary: Occasional low-FPS during effect animations since a couple of versions
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: performance (show other bugs)
Version: 6.1.3
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-07-24 19:01 UTC by bastimeyer123
Modified: 2024-07-31 17:22 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
grid: second closing and fourth opening anims stutter, rest is smooth (3.80 MB, video/mp4)
2024-07-24 20:57 UTC, bastimeyer123
Details

Note You need to log in before you can comment on or make changes to this bug.
Description bastimeyer123 2024-07-24 19:01:47 UTC
SUMMARY
I've noticed some performance issues for a few weeks now.

Apologies for being super vague here and opening a bug report before asking on other channels first, as I am not 100% certain yet whether it's actually caused by KWin. But considering that I'm seeing it only during specific actions when using the desktop, my guess is that it's caused by some changes in recent KWin versions. I unfortunately don't know when this started to happen, because those performance issues only occur sometimes and you don't always notice them. When you do notice them though, it's a bit annoying and then you notice them every time, which is the reason why I decided to write this bug report.

So what I'm seeing is that the animations during some effects, like the desktop grid for example, sometimes (in about 10-20% of the time, but it varies) have low FPS and are not smooth. I'm using a 3x3 desktop grid with two activities, and when opening or closing the grid, regardless whether there are any windows open on the current or other desktops, the animation stutters. This can even be observed when changing the global animation speed to slow. The stuttering only occurs sometimes at the beginning of the animation, and it lasts for less than half a second. It's still noticable though, because it's obviously not matching the display's refresh rate. When the animation speed is set to default, it lasts for the whole animation duration. I have checked KWin's FPS overlay, but couldn't see any obvious issues. While the FPS overlay is running, the issue also occurs very rarely.

As said, I'm not 100% certain yet where this issue is coming from, so at first I suspected a recent kernel upgrade with AMDGPU changes which caused my Radeon RX 5700XT to maybe stay clocked down for too long after idling on the desktop and then toggling the grid effect, but I could also observe the issue when the GPU was utilized otherwise, so I don't think this is an AMDGPU issue. I've tried recording the issue using OBS, but haven't had much success yet either, maybe for the same reason as with the FPS overlay.

Apparently there were some recent changes in regards to tripple buffering on KWin's 6.1 branch. No idea if this is relevant.
https://invent.kde.org/plasma/kwin/-/commits/Plasma/6.1

Are there any better ways I can reproduce or debug issues like this? I could probably try to bisect the 6.1 branch, but I'd prefer to avoid this, because it's very time consuming.

STEPS TO REPRODUCE
1. Have multiple virtual desktops (e.g. aligned in a 3x3 grid)
2. Toggle the desktop grid a lot of times
3. Wait for some of the opening or closing animations start to stutter

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Arch Linux
KDE Plasma Version: 6.1.3 (Wayland session)
KDE Frameworks Version: 6.4.0
Qt Version: 6.7.2

ADDITIONAL INFORMATION
It's a recent regression, but I don't know when it started to happen and what changed.

It's not a hardware issue either. My system consists of a Ryzen R9 3950X and a Radeon RX 5700XT with two screens, both 1080p60. As said, 9 virtual desktops in a 3x3 grid and 2 desktop activities.
Comment 1 Nate Graham 2024-07-24 19:30:51 UTC
Can you be specific about which exact effects/plugins/etc are sometimes stuttery?
Comment 2 bastimeyer123 2024-07-24 20:57:48 UTC
Created attachment 171968 [details]
grid: second closing and fourth opening anims stutter, rest is smooth

(In reply to Nate Graham from comment #1)
> Can you be specific about which exact effects/plugins/etc are sometimes stuttery?

The ones where I can definitely and reliably see the issue are the desktop grid and cube. That's all I can say for now, sorry.

I've added a video where you can see the issue. The grid's second closing and fourth opening animations stutter, while the rest don't, are smooth and match the refresh rate of my display. No dropped frames according to OBS while recording. I could've spent a bit more time recording a better video, but it should be good enough to demonstrate the problem.
Comment 3 Vlad Zahorodnii 2024-07-25 11:12:47 UTC
Is it better when you set KWIN_DRM_DISABLE_TRIPLE_BUFFERING=0 envvar?
Comment 4 bastimeyer123 2024-07-25 11:36:13 UTC
(In reply to Vlad Zahorodnii from comment #3)
> Is it better when you set KWIN_DRM_DISABLE_TRIPLE_BUFFERING=0 envvar?

Nope, same issue.

```
$ sudo xargs -0 -L1 -a /proc/$(pidof kwin_wayland)/environ | grep KWIN_DRM_DISABLE_TRIPLE_BUFFERING
KWIN_DRM_DISABLE_TRIPLE_BUFFERING=0
```
Comment 5 bastimeyer123 2024-07-25 18:50:57 UTC
Oops, I totally forgot that I wasn't on `v6.1.3` but on `6.1.3.r27.gc5d7d39`. That's because I apply some custom but unrelated patches to Arch's kwin package, and forgot that I built from the `Plasma/6.1` branch instead of the latest tagged commit. The issue still occurs when using Arch's default kwin package though.

So I decided to do some bisecting the past couple of hours... I found a bad commit, but I'm still not 100% sure, because there's still some very rare stuttering in all of my `v6.1.0...Plasma/6.1` builds.

When building from `d7385d441417d8f43cfb09341b5c0ae449ccd219` (committed after `v6.1.3`), the issue is way worse and it stutters every so often. Building from `d7385d441417d8f43cfb09341b5c0ae449ccd219~1` does only stutter very rarely, same as on `v6.1.0`.
https://invent.kde.org/plasma/kwin/-/commit/d7385d441417d8f43cfb09341b5c0ae449ccd219
Comment 6 bastimeyer123 2024-07-31 17:22:30 UTC
Issue seems to be fixed with aad82e9c772d52e853e7fa36a97620e41172df95...7b8f24698f797143531f0d5723cc6c263b9175e8
Thanks!