Bug 512968

Summary: after commit 03f77c flickering on external screen and when atomic modeset is disabled, kwin crashes
Product: [Plasma] kwin Reporter: fanzhuyifan
Component: compositingAssignee: KWin default assignee <kwin-bugs-null>
Status: REPORTED ---    
Severity: normal CC: kde, nate
Priority: NOR Keywords: regression
Version First Reported In: 6.5.80   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: external screen flickering
desktop transition setting
backtrace for kwin crash when atomic modeset is disabled

Description fanzhuyifan 2025-12-05 06:44:43 UTC
Created attachment 187351 [details]
external screen flickering

SUMMARY
Flickers/artifacts on any external screen connected via HDMI to laptop after commit 03f77cf9e7041d4eeefc7c9da9de4ee7284c9920 (https://invent.kde.org/plasma/kwin/-/merge_requests/8436).

STEPS TO REPRODUCE
1. connect external screen via HDMI
2. switch virtual desktops

OBSERVED RESULT
Screen artifacts, see attachment.

EXPECTED RESULT
Smooth transition, like before commit 03f77c.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux 
KDE Plasma Version: 6.5.80
KDE Frameworks Version: 6.21.0
Qt Version: 6.10.1
Kernel Version: 6.18.0-arch1-1 (64-bit)
Graphics Platform: Wayland
Processors: 20 × 13th Gen Intel® Core™ i9-13900H
Memory: 16 GiB of RAM (15.2 GiB usable)
Graphics Processor 1: Mesa Intel® Graphics
Graphics Processor 2: NVIDIA GeForce RTX 4060 Laptop GPU/PCIe/SSE2
Manufacturer: ASUSTeK COMPUTER INC.
Product Name: ROG Zephyrus G16 GU603VV_GU603VV
System Version: 1.0

ADDITIONAL INFORMATION

I think this also happens during normal usage, and not just switching desktops.
This only happens on external screen.
There is some randomness and this does not always happen. Happens around once a minute.
I tested the commit before 03f77cf9e7041d4eeefc7c9da9de4ee7284c9920 for quite a while and cannot see the issue. Hence I am fairly sure that 03f77c is the first bad commit.
Comment 1 David Edmundson 2025-12-05 09:15:45 UTC
>I tested the commit before 03f77cf9e7041d4eeefc7c9da9de4ee7284c9920 for quite a while and cannot see the issue. Hence I am fairly sure that 03f77c is the first bad commit.

You need to test the commit both sides to be able to be able to confirm that.
Can you test running 03f77c itself and confirm it *does* happen again. 

Or run master and just revert that commit.

My change should not be affecting normal usage nor switching desktops, only the overview effect and a few other QtQuick places. I can't see why it would affect anything else.
Comment 2 fanzhuyifan 2025-12-05 20:25:39 UTC
(In reply to David Edmundson from comment #1)
> >I tested the commit before 03f77cf9e7041d4eeefc7c9da9de4ee7284c9920 for quite a while and cannot see the issue. Hence I am fairly sure that 03f77c is the first bad commit.
> 
> You need to test the commit both sides to be able to be able to confirm that.
> Can you test running 03f77c itself and confirm it *does* happen again. 

I did test that, and the issue does happen. Sorry for not being clear about this.

> Or run master and just revert that commit.

On master I observed the issue quite frequently (like at least once every minute). After reverting the commit and running for >5 minutes, I cannot observe the issue.

Note: there is a slight conflict that needs to be resolved when reverting 03f77c.

> My change should not be affecting normal usage nor switching desktops, only
> the overview effect and a few other QtQuick places. I can't see why it would
> affect anything else.

Does the sliding animation for transitioning desktops depend on QtQuick?
See attachment for my setting.

Also I am on a dual GPU system, and I think external monitors are connected to the nvidia dGPU. Not sure if that is relevant here.
Comment 3 fanzhuyifan 2025-12-05 20:26:02 UTC
Created attachment 187375 [details]
desktop transition setting
Comment 4 fanzhuyifan 2025-12-08 18:50:04 UTC
Another piece of information: While using the touchpad to transition virtual desktops, the issue only happens when I release and let the desktop slide into place, and never in the middle when I am still actively sliding.
Comment 5 fanzhuyifan 2025-12-08 19:36:33 UTC
The more serious issue seems be that after this commit, when I disable atomic mode setting (`KWIN_DRM_NO_AMS=1`), kwin consistently crashes.

(I tested both on master, consistent crash, and with the commit reverted, consistent crash)

For full backtrace, see attachment. The issue seems to be `gpu->m_defunctCommits` becomes corrupted at kwin/src/backends/drm/drm_gpu.cpp:544 (https://invent.kde.org/plasma/kwin/-/blob/1b4896c218dd705742dcd091665db27702c3525d/src/backends/drm/drm_gpu.cpp#L544)

> +p gpu->m_defunctCommits 
> $1 = std::vector of length -137438961664, capacity -137438961625 = {Cannot access memory at address 0x10000010000
Comment 6 fanzhuyifan 2025-12-08 19:37:01 UTC
Created attachment 187438 [details]
backtrace for kwin crash when atomic modeset is disabled
Comment 7 fanzhuyifan 2025-12-08 19:39:49 UTC
(In reply to fanzhuyifan from comment #5)

> (I tested both on master, consistent crash, and with the commit reverted,
> consistent crash)

Apologies -- I mean with commit reverted, consistent *no* crash
Comment 8 fanzhuyifan 2025-12-13 02:50:24 UTC
Some additional debugging:

Still observe glitches when internal and external screen both set to 60Hz. Adaptive sync setting for internal screen doesn't seem to change things (I tried always, automatic, and never)

- only using nvidia dGPU through bias setting
  No glitches, but still crashes when `KWIN_DRM_NO_AMS=1`
- forcing sync
  Setting KWIN_DRM_FORCE_GL_FINISH_MGPU_COPY=1 and KWIN_DRM_FORCE_GL_FINISH_PRESENT=1
  No glitches.
  When `KWIN_DRM_NO_AMS=1`, still crashes. Looking at backtrace, segfault on same line (pageFlipHandler, handling defunct commits). Issue is commit->gpu() is null.
- using Nouveau
  crashes, even when not setting `KWIN_DRM_NO_AMS=1`. In the backtrace, commit->gpu() is null.
  This does not happen with the commit 03f77c reverted.
  I think this indicates that the issue is not with the nvidia proprietary driver.
- with 03f77c reverted, and https://invent.kde.org/plasma/kwin/-/merge_requests/7980 (commit ad1eb9b215043fafb017a1a3a51790739930d6e0) applied
  No glitches, and no crashes when setting `KWIN_DRM_NO_AMS=1`