Bug 468251

Summary: After updating to 5.27.4 changing the display refresh rate on Wayland no longer works properly
Product: [Plasma] kwin Reporter: Prajna Sariputra <putr4.s>
Component: wayland-genericAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED DUPLICATE    
Severity: normal CC: cellstije, tjumat
Priority: NOR    
Version: 5.27.4   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: drm_info output

Description Prajna Sariputra 2023-04-07 15:07:44 UTC
SUMMARY
While my laptop's display supports 144Hz refresh rate I perfer keeping it at 60Hz instead since I don't think the minor smoothness advantage is worth the extra load on the system, plus it would also add unnecessary power draw on battery.

Unfortunately, after upgrading to 5.27.4 I noticed that things looked strangely smooth despite having set the refresh rate at 60Hz, then I found out that KWin was still rendering at 144 fps (based on the Show FPS effect), and Firefox with a vsync tester website also reports running at 144 fps instead of 60 fps. Changing the refresh rate (both via System Settings and kscreen-doctor) also only caused the screen to flash once very quickly (normally changing refresh rates takes a whole second or two), and all that did was change the "Maximum FPS" value in the Show FPS effect, while the "current FPS" part still says 144 the whole time.

I believe the culprit is this commit: https://invent.kde.org/plasma/kwin/-/commit/dc95392b982ac9ae95a72e5f38e5ecc499f0bc19 (backends/drm: restrict common mode generation to drivers that support scaling), if I compile KWin 5.27.3 with that patch I also see this bug, while plain KWin 5.27.3 works fine.

STEPS TO REPRODUCE
1. Have a screen that supports 60 and 144 Hz
2. Set the refresh rate to 60 Hz in a Wayland session
3. Enable the "Show FPS" effect

OBSERVED RESULT
While the maximum FPS value is 60 the current FPS value is still 144.

EXPECTED RESULT
The maximum and current FPS values both drop to 60.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 5.27.4
KDE Frameworks Version: 5.104.0
Qt Version: 5.15.8
Kernel Version: 6.2.8-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 16 × AMD Ryzen 7 6800H with Radeon Graphics
Memory: 14.9 GiB of RAM
Graphics Processor: AMD Radeon Graphics
Manufacturer: HP
Product Name: OMEN by HP Gaming Laptop 16-n0xxx

ADDITIONAL INFORMATION
After logging into a Wayland session if I switch back to X11 the bug persists, changing the refresh rate via xrandr also has no real effect, but if I reboot and log into an X11 session first then changing refresh rates work as before.
Comment 1 Prajna Sariputra 2023-04-07 15:18:39 UTC
Also, to be clear it's not just actively switching refresh rates that causes the problem, just setting the refresh rate to 60Hz and then rebooting means that the true refresh rate is still stuck at 144Hz when I log back into a Plasma Wayland session.
Comment 2 tjumat 2023-04-07 15:42:53 UTC
I have a very similar problem, since 5.27.4 KDE stays at 60fps even if I set 120,144 or 165Hz in monitor settings. Only if I set it to 170Hz will it show 170fps in the desktop effects fps meter.
Comment 3 Prajna Sariputra 2023-04-07 15:49:07 UTC
Created attachment 157930 [details]
drm_info output

For what it's worth here is the output of drm_info in my case, the scaling mode reported is "None", and the listed modes there are 1920x1080@144, 1920x1080@60, and a bunch of other resolutions down to 640x480, all at 144Hz.
Comment 4 Prajna Sariputra 2023-04-08 12:09:34 UTC
Seems like bug 468235 might be at least related if not the same bug, although in that case the issue was that they got 60Hz while in my case I get 144Hz all the time instead.
Comment 5 cellstije 2023-04-08 17:48:33 UTC
Hi,

I have exactly the same problem on :

Operating System: Arch Linux 
KDE Plasma Version: 5.27.4
KDE Frameworks Version: 5.104.0
Qt Version: 5.15.8
Kernel Version: 6.2.10-zen1-1-zen (64-bit)
Graphics Platform: Wayland
Processors: 24 × AMD Ryzen 9 5900X 12-Core Processor
Memory: 31.3 GiB of RAM
Graphics Processor: AMD Radeon RX 6800


I have set Screen refresh to 60 Hz in 'Display Configuration', but monitor is stuck at 165Hz.

If I run kscreen-console:
-----
Id:  1
Name:  "DP-2"
Type:  "DisplayPort"
Connected:  true
Enabled:  true
Priority:  1
Rotation:  KScreen::Output::None
Pos:  QPoint(0,0)
MMSize:  QSize(700, 390)
FollowPreferredMode:  false
Size:  QSize(2560, 1440)
Scale:  1
Clones:  None
Mode:  "33"
Preferred Mode:  "0"
Preferred modes:  ("0", "1")
Modes: 
[...]
         "33"    "2560x1440@60"   QSize(2560, 1440)   59.961
----

Same mode reported by kscreen-doctor -o
However my monitor reports running at 165 Hz (and games attempt to VSync to that frequency, definitely not 60Hz)

Thanks
Comment 6 Prajna Sariputra 2023-04-09 00:25:25 UTC
The MR linked in bug 468235 does fix the problem for me if applied on 5.27.4 so this is probably the same bug then.

*** This bug has been marked as a duplicate of bug 468235 ***
Comment 7 cellstije 2023-04-12 20:48:50 UTC
Hi,

the latest version of kwin landed today in Arch repos has fixed the issue for me (kwin 5.24.4.1-1)

Thanks