Bug 508822 - SDL_WarpMouseInWindow breaks V-SYNC under Wayland/kwin
Summary: SDL_WarpMouseInWindow breaks V-SYNC under Wayland/kwin
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (other bugs)
Version First Reported In: 6.4.4
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-08-27 20:14 UTC by adrian.v.przekwas
Modified: 2025-08-29 01:29 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 6.4.5
Sentry Crash Report:


Attachments
testing app (1.08 MB, video/mp4)
2025-08-27 20:14 UTC, adrian.v.przekwas
Details
testing app source code (2.95 KB, text/x-c++src)
2025-08-27 20:14 UTC, adrian.v.przekwas
Details

Note You need to log in before you can comment on or make changes to this bug.
Description adrian.v.przekwas 2025-08-27 20:14:03 UTC
Created attachment 184506 [details]
testing app

SUMMARY
If SDL_WarpMouseInWindow is used in combination with SDLGPU3 and Wayland/kwin, V-SYNC is not respected.

Initially I reported this in SDL's bug tracker https://github.com/libsdl-org/SDL/issues/13812 but it does not seem to be a SDL bug, since it cannot be reproduced in other DE's. Also v-sync works fine with X11. 

STEPS TO REPRODUCE
1. compile the attached file "g++ vsync-test.cpp -o vsync-test -lSDL3"
2. Run the executable
3. comment-out the "SDL_WarpMouseInWindow(window, 0, 0);"  line and recompile
4. Run the executable again

OBSERVED RESULT
With SDL_WarpMouseInWindow, v-sync is disabled. The executable prints: Frame time: 0

EXPECTED RESULT
In both cases v-sync should be enabled.

SOFTWARE/OS VERSIONS
Operating System: Fedora Linux 42
KDE Plasma Version: 6.4.4
KDE Frameworks Version: 6.17.0
Qt Version: 6.9.1

ADDITIONAL INFORMATION
-
Comment 1 adrian.v.przekwas 2025-08-27 20:14:41 UTC
Created attachment 184507 [details]
testing app source code
Comment 2 Zamundaaa 2025-08-27 23:02:29 UTC
This is the WAYLAND_DEBUG output of a single frame of that test app:

> [2477892.765] {mesa vk display queue}  -> wp_linux_drm_syncobj_surface_v1#79.set_acquire_point(wp_linux_drm_syncobj_timeline_v1#99, 0, 2743)
> [2477892.769] {mesa vk display queue}  -> wp_linux_drm_syncobj_surface_v1#79.set_release_point(wp_linux_drm_syncobj_timeline_v1#100, 0, 2743)
> [2477892.771] {mesa vk display queue}  -> wl_surface#4.attach(wl_buffer#97, 0, 0)
> [2477892.774] {mesa vk display queue}  -> wl_surface#4.damage_buffer(0, 0, 2147483647, 2147483647)
> [2477892.777] {mesa vk display queue}  -> wp_fifo_v1#80.set_barrier()
> [2477892.779] {mesa vk display queue}  -> wp_fifo_v1#80.wait_barrier()
> [2477892.782] {mesa vk display queue}  -> wl_surface#4.commit()
> [2477892.787] {mesa vk display queue} discarded wl_buffer#76.release()
> Frame time: 0
> [2477892.796] {Default Queue}  -> zwp_pointer_constraints_v1#14.lock_pointer(new id zwp_locked_pointer_v1#104, wl_surface#4, wl_pointer#41, nil, 2)
> [2477892.800] {Default Queue}  -> zwp_locked_pointer_v1#104.set_cursor_position_hint(0.00000000, 0.00000000)
> [2477892.804] {Default Queue}  -> wl_surface#4.commit()
> [2477892.807] {Default Queue}  -> zwp_locked_pointer_v1#104.destroy()
> [2477892.943] {Display Queue} wl_display#1.delete_id(104)

The issue is that the commit for the pointer constraint clears the fifo barrier, which it shouldn't do.

I'm not so sure SDL should be doing these commits either, but there's also definitely a bug in KWin here.
Comment 3 Bug Janitor Service 2025-08-28 12:04:26 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/8047
Comment 4 Zamundaaa 2025-08-29 00:13:38 UTC
Git commit fdd0a94e0013c0190e115a433588b294de4df144 by Xaver Hugl.
Committed on 28/08/2025 at 19:46.
Pushed by zamundaaa into branch 'master'.

wayland/surface: don't clear fifo barrier on new commits

Otherwise, the following sequence will cause presentation to be infinitely fast,
despite fifo being used:
- set_barrier
- commit
- commit
- wait_barrier

M  +37   -0    autotests/integration/test_fifo.cpp
M  +1    -1    src/wayland/surface.cpp

https://invent.kde.org/plasma/kwin/-/commit/fdd0a94e0013c0190e115a433588b294de4df144
Comment 5 Zamundaaa 2025-08-29 00:38:10 UTC
Git commit 0480eb45adfe532888017cc1f36f23ba3d4dfca6 by Xaver Hugl.
Committed on 29/08/2025 at 00:13.
Pushed by zamundaaa into branch 'Plasma/6.4'.

wayland/surface: don't clear fifo barrier on new commits

Otherwise, the following sequence will cause presentation to be infinitely fast,
despite fifo being used:
- set_barrier
- commit
- commit
- wait_barrier


(cherry picked from commit fdd0a94e0013c0190e115a433588b294de4df144)

Co-authored-by: Xaver Hugl <xaver.hugl@kde.org>

M  +37   -0    autotests/integration/test_fifo.cpp
M  +1    -1    src/wayland/surface.cpp

https://invent.kde.org/plasma/kwin/-/commit/0480eb45adfe532888017cc1f36f23ba3d4dfca6