Bug 494547

Summary: Parts of external screens "flickering"
Product: [Plasma] kwin Reporter: Lech <misc>
Component: generalAssignee: KWin default assignee <kwin-bugs-null>
Status: RESOLVED FIXED    
Severity: grave CC: antonio.tigri, krorkle, nate, petr.vorel, xaver.hugl
Priority: NOR Keywords: multiscreen, regression
Version: 6.2.0   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed In: 6.2.1
Sentry Crash Report:
Attachments: Neon flickering console
Neon GIMP flickering
Neon affected versions

Description Lech 2024-10-11 15:42:04 UTC
SUMMARY

After upgrading to KDE 6.2.0 on Wayland on Fedora 40, I experienced screen "flickering" on my external monitors connected to a laptop. Most visible on updating items, such as panels with widgets or movies.




STEPS TO REPRODUCE
1. Run KDE 6.2.0 on Wayland on an optimus laptop with AMD Radeon 780M/NVidia 4070 graphic cards
2. Connect any external monitor (HDMI or USB-C->DP)
3. Observe the flickering on updating objects (panels, movies) on external monitors

OBSERVED RESULT

By "flickering" I mean very short corruptions of parts of the screen. Too short to notice what the corruptions "include", but I think sometimes garbage, sometimes parts of windows from other parts of the screen. Not sure though. Most visible on movies, because occupying bigger part of the screen (not whole image though). Tried with movies playing both in Firefox and through the system player.

EXPECTED RESULT

No flickering/corruption. Was perfectly fine before the update, on Plasma 6.1.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Fedora 40
KDE Plasma Version: 6.2.0
KDE Frameworks Version: 6.7.0
Qt Version: 6.7.2

ADDITIONAL INFORMATION

1. Bug present regardless if 1 or 2 external monitors is connected, and which one of them (HDMI or USB-C->DP)
2. Not present on the built-in monitor of the laptop, regardless of the refresh rate (144 Hz, or 60 Hz like the external monitors)
3. Chaning scaling on the external monitors did not help
4. I am not sure if both my external monitors are connected to the dGPU, or just one. My laptop is ASUS TUF Gaming A15 FA507XI_FA507XI
Comment 1 Lech 2024-10-11 16:37:06 UTC
An update: after ~3 hours of work, screens started flickering very often even with all programs minimised, and kwin_wayland process started using >=62% of a single core. Closing the programs did not help, but logging out and back into KDE brought the situation back to the somewhat less intrusive flickering described in the main bug report.
Comment 2 Zamundaaa 2024-10-12 17:18:00 UTC
Git commit 0133431c1d4b8a07ff5027df7f59928382562b38 by Xaver Hugl.
Committed on 12/10/2024 at 17:00.
Pushed by zamundaaa into branch 'master'.

backends/drm: disable triple buffering on NVidia by default

There's some unresolved glitches on multi gpu systems. Until that's taken care of,
triple buffering is disabled by default on NVidia unless the environment variable
KWIN_DRM_DISABLE_TRIPLE_BUFFERING=0 is set
Related: bug 494407

M  +3    -2    src/backends/drm/drm_output.cpp

https://invent.kde.org/plasma/kwin/-/commit/0133431c1d4b8a07ff5027df7f59928382562b38
Comment 3 Lech 2024-10-12 18:10:06 UTC
Thank you! export KWIN_DRM_DISABLE_TRIPLE_BUFFERING=1 for the session fixed the problem. When will it no longer be needed?
Comment 4 Zamundaaa 2024-10-12 20:38:21 UTC
Git commit b3358350b67b39ecea8fd4234df4ad8c0fa99017 by Xaver Hugl.
Committed on 12/10/2024 at 20:14.
Pushed by zamundaaa into branch 'Plasma/6.2'.

backends/drm: disable triple buffering on NVidia by default

There's some unresolved glitches on multi gpu systems. Until that's taken care of,
triple buffering is disabled by default on NVidia unless the environment variable
KWIN_DRM_DISABLE_TRIPLE_BUFFERING=0 is set
Related: bug 494407


(cherry picked from commit 0133431c1d4b8a07ff5027df7f59928382562b38)

Co-authored-by: Xaver Hugl <xaver.hugl@gmail.com>

M  +3    -2    src/backends/drm/drm_output.cpp

https://invent.kde.org/plasma/kwin/-/commit/b3358350b67b39ecea8fd4234df4ad8c0fa99017
Comment 5 Nick H 2024-10-12 22:59:13 UTC
(In reply to Lech from comment #3)
> Thank you! export KWIN_DRM_DISABLE_TRIPLE_BUFFERING=1 for the session fixed
> the problem. When will it no longer be needed?

Lech - How did you apply that fix?
(thanks)
Comment 6 Lech 2024-10-13 07:55:07 UTC
I've created kwin_settings.sh file in  ~/.config/plasma-workspace/env and added there:
export KWIN_DRM_DISABLE_TRIPLE_BUFFERING=1

This way the file is called when KDE is started and the variable is set for the whole session. It can be confirmed with "printenv".
Comment 7 Zamundaaa 2024-10-13 21:10:47 UTC
*** Bug 494675 has been marked as a duplicate of this bug. ***
Comment 8 Petr Vorel 2024-11-25 18:17:14 UTC
I have the same problem (i.e. flickering on external screens on Nvidia GPU, using Wayland) on openSUSE Tumbleweed with latest KDE
(kernel 6.12 with nouveau, Wayland, KDE Plasma 6.2.3, KDE Frameworks 6.8, Qt 6.8):

$ lspci |grep VGA # Thinkpad P16
00:02.0 VGA compatible controller: Intel Corporation Alder Lake-HX GT1 [UHD Graphics 770] (rev 0c)
01:00.0 VGA compatible controller: NVIDIA Corporation GA107GLM [RTX A1000 Laptop GPU] (rev a1)

Problem raised with update to KDE 5.

I was able to reproduce the issue with Neon live CD: neon-user-20241117-0745.iso and neon-user-20241110-0746.iso (kernel 6.8 with nouveau, Wayland, KDE Plasma 6.2.3, KDE Frameworks 6.8, Qt 6.8)

Because I was unable to modify Neon live CD, I tried the workaround with setting KWIN_DRM_DISABLE_TRIPLE_BUFFERING=1 and KWIN_DRM_FORCE_MGPU_GL_FINISH=1 in Tumbleweed. It did not help as well.
Comment 9 Petr Vorel 2024-11-25 18:19:04 UTC
Created attachment 176112 [details]
Neon flickering console
Comment 10 Petr Vorel 2024-11-25 18:19:34 UTC
Created attachment 176113 [details]
Neon GIMP flickering
Comment 11 Petr Vorel 2024-11-25 18:20:20 UTC
Created attachment 176114 [details]
Neon affected versions
Comment 12 Petr Vorel 2024-11-25 18:35:40 UTC
OK, 0133431c1d4b8a07ff5027df7f59928382562b38 has not been released yet even in 6.2.3, thus setting back the original status resolved fixes. But I wonder why "Version Fixed In" is set to 6.2.1.