Bug 500166 - Tearing not working on Wayland
Summary: Tearing not working on Wayland
Status: RESOLVED UPSTREAM
Alias: None
Product: kwin
Classification: Plasma
Component: compositing (show other bugs)
Version: 6.3.2
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: usability, wayland-only
Depends on:
Blocks:
 
Reported: 2025-02-16 07:34 UTC by Syntist
Modified: 2025-03-06 01:10 UTC (History)
1 user (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 Syntist 2025-02-16 07:34:35 UTC
SUMMARY
So, I been testing to get tearing working, I have enabled QT_LOGGING_RULES="kwin_core.debug=true" to get the tearing log, but I am don't get anything if VRR is on I get 

Feb 16 02:16:00 syntist-pc kwin_wayland[1747]: kwin_core: Changed presentation mode to KWin::PresentationMode::VSync
Feb 16 02:16:01 syntist-pc kwin_wayland[1747]: kwin_core: Changed presentation mode to KWin::PresentationMode::AdaptiveSync
Feb 16 02:22:55 syntist-pc kwin_wayland[1747]: kwin_core: Changed presentation mode to KWin::PresentationMode::VSync

And when i disabled vrr, I don't get any output.

I have tried Wayland + Vulkan, Xwayland + DXVK, xwayland + vulkan with Intel GPU (IGPU) and Nvidia GPU (DGPU) 
I also make sure show compositing effect is not showing meaning the app is running in direct scannout. I don't see any tearing either.

STEPS TO REPRODUCE
1. Turn on allow tearing and kwin_core log QT_LOGGING_RULES="kwin_core.debug=true"
2. Run the game in full screen (direct scannout mode + immediate vulkan)
3. journalctl -f | grep 'Changed presentation mode' 

OBSERVED RESULT

Mode is never changed to tearing.

EXPECTED RESULT

Mode should change to tearing

SOFTWARE/OS VERSIONS
Operating System: CachyOS Linux 
KDE Plasma Version: 6.3.0
KDE Frameworks Version: 6.10.0
Qt Version: 6.8.2
Kernel Version: 6.13.2-2-cachyos (64-bit)
Graphics Platform: Wayland
Processors: 20 × 12th Gen Intel® Core™ i7-12800H
Memory: 15.3 GiB of RAM
Graphics Processor 1: Intel® Iris® Xe Graphics
Graphics Processor 2: NVIDIA RTX A1000 Laptop GPU


ADDITIONAL INFORMATION
It was working when we were testing the ticket, but after it never worked for me.
Comment 1 Vlad Zahorodnii 2025-02-17 14:28:59 UTC
Can you please post the output of drm_info? Also do you atomic modesetting or legacy modesetting? or whatever is default?
Comment 2 Zamundaaa 2025-02-17 22:09:49 UTC
If you run
> WAYLAND_DEBUG=1 vkcube --wsi wayland --present_mode 0 2>&1 | grep set_presentation_hint
does that output something like
> [3298581.344] {mesa vk display queue}  -> wp_tearing_control_v1#22.set_presentation_hint(1)
> [3298587.277] {mesa vk display queue}  -> wp_tearing_control_v1#32.set_presentation_hint(1)
?

If you set a window rule to force tearing for a specific window, do you see tearing then?
Comment 3 Syntist 2025-02-17 22:21:35 UTC
When i run vkcube, i did get this, but i didn't notice any tearing and the mode didn't change either.

[3839653.928]  -> wp_tearing_control_v1#22.set_presentation_hint(1)
[3840830.536]  -> wp_tearing_control_v1#22.set_presentation_hint(1)

This is the drm_info output https://paste.cachyos.org/p/0f02857

Also can it be cause I am using modified edid, that's load in boot time. Also am using default which is atomic modesetting
Comment 4 Syntist 2025-02-17 22:33:50 UTC
I also tried with window rules, I can't seem to get it too tear. Tearing is prominent on windows with same game, like cs2 etc.
Comment 5 Syntist 2025-03-02 12:18:44 UTC
Issue persistent in kde 6.3.2
Comment 6 Zamundaaa 2025-03-05 16:10:42 UTC
Okay, then please follow https://invent.kde.org/plasma/kwin/-/wikis/Debugging/Debugging-DRM-issues to record a drm debug log of KWin attempting to use tearing. If it does attempt it at least, we should see in that log why it doesn't work.
Comment 7 Syntist 2025-03-05 19:16:40 UTC
(In reply to Zamundaaa from comment #6)
> Okay, then please follow
> https://invent.kde.org/plasma/kwin/-/wikis/Debugging/Debugging-DRM-issues to
> record a drm debug log of KWin attempting to use tearing. If it does attempt
> it at least, we should see in that log why it doesn't work.

Hey, I did see Fetch create, related outputs but I can't much of it as I don't have much understanding of DRM, But here is the log maybe it can help 

https://paste.cachyos.org/p/ecc01e5
Comment 8 Zamundaaa 2025-03-05 19:55:59 UTC
Good, some progress:
> [drm:intel_atomic_check [i915]] [PLANE:77:cursor A] async flip not supported

KWin intentionally falls back to a software cursor when trying to do tearing, so that's nonsense. With the knowledge that this must be driver specific rather than something on your system, I also tested this on an Intel laptop and got the same result. I also made sure that the cursor plane is actually disabled while these messages are printed, so this is without a doubt a kernel bug.

You can follow this further at https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/13834
Comment 9 Syntist 2025-03-05 22:33:54 UTC
(In reply to Zamundaaa from comment #8)
> Good, some progress:
> > [drm:intel_atomic_check [i915]] [PLANE:77:cursor A] async flip not supported
> 
> KWin intentionally falls back to a software cursor when trying to do
> tearing, so that's nonsense. With the knowledge that this must be driver
> specific rather than something on your system, I also tested this on an
> Intel laptop and got the same result. I also made sure that the cursor plane
> is actually disabled while these messages are printed, so this is without a
> doubt a kernel bug.
> 
> You can follow this further at
> https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/13834

Oh great so you were able to reproduce it. how does tearing work actually? So the game is being render using DGPU but the DRM for tearing is handle by IGPU? And also when we were testing 4800! Tearing was working.
Comment 10 Zamundaaa 2025-03-05 22:40:19 UTC
> So the game is being render using DGPU but the DRM for tearing is handle by IGPU?
Yes, presentation happens on the internal GPU in this case.

> And also when we were testing 4800! Tearing was working.
The merge request initially had a way more complicated approach, which skipped the cursor plane entirely once it was disabled, and accidentally worked around this bug. Now KWin tells the kernel every frame that it is not using the cursor plane (as it's supposed to!), and that seems to trigger the issue.
Comment 11 Syntist 2025-03-06 01:10:54 UTC
Got it, maybe that's why when I have allow tearing application on, the application doesn't use direct scannout, The Compositing red text is shown.
But thanks for finding out the issue, hope so it get fixed.