Bug 468146 - Discrepancy in Game Framerate Perception and Reported FPS Graphs, VSync magic behaviour.
Summary: Discrepancy in Game Framerate Perception and Reported FPS Graphs, VSync magic...
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (show other bugs)
Version: 5.27.4
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-04-04 12:11 UTC by Edgars
Modified: 2023-04-27 04:25 UTC (History)
4 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Edgars 2023-04-04 12:11:29 UTC
STEPS TO REPRODUCE
1. Lunch CSGO on plasma wayland session using xwayland
2. Enter any game
3. Lag

OBSERVED RESULT
Seems like it's very laggy. Gameplay feels like 40-50 fps, meanwhile, the framerate graph shows 130-140.


EXPECTED RESULT
The expected result is that the gameplay should run smoothly and the framerate should match or exceed the capabilities of the device or system. In this case, the discrepancy between the perceived laggy gameplay at 40-50 fps and the reported framerate graph of 130-140 suggests that there may be an issue kwin_wayland. No issues on kwin_x11 side


Linux/KDE Plasma: Arch
KDE Plasma Version: 5.27.3
KDE Frameworks Version: 5.104.0
Qt Version: 5.15.8+kde+r185-1

ADDITIONAL INFORMATION
However, when using Gnome Wayland session with Mutter, comp the game actually feels much smoother with a higher framerate, around 130-140 fps, which is accurately reflected on the fps graph. On the kwin_wayland side, enabling vysnc resolves the issue, but it caps the framerate at 60 fps, which may not be desirable.

I am fully using AMD GPU.
Comment 1 Edgars 2023-04-08 11:12:56 UTC
I updated to Plasma 5.27.4, but I'm still experiencing the same issue as before.
Comment 2 Zamundaaa 2023-04-11 12:24:32 UTC
Runs fine for me. Did you change any compositor settings from the default?
Comment 3 Edgars 2023-04-11 22:09:45 UTC
(In reply to Zamundaaa from comment #2)
> Runs fine for me. Did you change any compositor settings from the default?

No i didn't. Locking frames to 60 FPS is smooth over 60 lags as hell aka a lot lag spikes
Comment 4 Zamundaaa 2023-04-23 07:26:35 UTC
What specific hardware are you using? There's https://gitlab.freedesktop.org/drm/amd/-/issues/2516, which may be related
Comment 5 Edgars 2023-04-23 07:33:34 UTC
(In reply to Zamundaaa from comment #4)
> What specific hardware are you using? There's
> https://gitlab.freedesktop.org/drm/amd/-/issues/2516, which may be related

I am having Ryzen 5 3500U with AMD IGPU Vega 8 Mobile, I guess the issue is with kernel?
Comment 6 Zamundaaa 2023-04-23 09:52:14 UTC
Yes, it seems so. You can check by downgrading to Linux 6.1 or earlier

If you change the latency policy in the compositor settings to "Force smoothest animations", does the stutter go away?
Comment 7 Edgars 2023-04-23 09:58:22 UTC
(In reply to Zamundaaa from comment #6)
> Yes, it seems so. You can check by downgrading to Linux 6.1 or earlier
> 
> If you change the latency policy in the compositor settings to "Force
> smoothest animations", does the stutter go away?

By default it's on Force smoothness animations" also it's not more about stuttering. Tested on gnome 43.4 the frames are rhe same in the graph meanwhile (In reply to Zamundaaa from comment #6)
> Yes, it seems so. You can check by downgrading to Linux 6.1 or earlier
> 
> If you change the latency policy in the compositor settings to "Force
> smoothest animations", does the stutter go away?

By default it's set to force smoothness animations. Well i dunno it's kernel issue, Because on gnome 43.4 I have no issues also dunno if it's stuttering, because on KDE Wayland session game via xwayland graph shows  130-140  but game it self feels 40-50 FPS, vsync fixes the issues but frames are locked to 60.

However lunching game with Wayland session SDL_VIDEODRIVER=wayland I have no issues but at them same moment I can't use OpenGL. 
However on Gnome 43.4 running game on xwayland I have no issues.
Comment 8 Zamundaaa 2023-04-23 10:52:56 UTC
Right, we changed the default in 5.27.

> Well i dunno it's kernel issue, Because on gnome 43.4 I have no issues
That's not really relevant, the upstream bug report says the same. Please test with Linux 6.1 or earlier
Comment 9 Edgars 2023-04-23 10:56:39 UTC
(In reply to Zamundaaa from comment #8)
> Right, we changed the default in 5.27.
> 
> > Well i dunno it's kernel issue, Because on gnome 43.4 I have no issues
> That's not really relevant, the upstream bug report says the same. Please
> test with Linux 6.1 or earlier

Tried linux-lts kernel 6.1.25 the same issue. The issue happened after upgrading to 5.27
Comment 10 Zamundaaa 2023-04-23 12:02:44 UTC
Okay, then it's a different thing from the amd bug.
Does anything change if you set the latency policy to balanced (which was the default in 5.26)?
Comment 11 Edgars 2023-04-23 19:47:05 UTC
(In reply to Zamundaaa from comment #10)
> Okay, then it's a different thing from the amd bug.
> Does anything change if you set the latency policy to balanced (which was
> the default in 5.26)?

Didn't help, nothing changed.
Comment 12 Edgars 2023-04-27 04:25:48 UTC
I fixed the stuttering issue by compiling the kernel myself. I'm not sure why it worked, but it did.