Pressing a pen tip and a key at the same time freezes an app on Wayland
Description
Trying to press a pen tip and a key at the (almost) same time for a moment produces a large amount of KEY_DOWN events at some moment and freezes an app on Wayland.
SDL_VIDEO_DRIVER=wayland SDL_EVENT_LOGGING=2 WAYLAND_DEBUG=1 GALLIUM_HUD=fps gdb ./testpen at a1332d77f6cc63a8f0ff8ed82c7cadcf484f3a01, https://github.com/libsdl-org/SDL/issues/13003 is supposed to be a bug but it makes easier to see what's going on here 😅 :
https://github.com/user-attachments/assets/c93d59b0-5219-4082-ba9e-7c3a59b7f81a
This somehow didn't happen on Weston, but it might be because I didn't wait long enough for it to happen.
You can see that the FPS graph is frozen, so it's not that SDL stopped delivering input, but the thread just got stuck, probably due to an infinite loop?
git bisect says that a1332d77f6cc63a8f0ff8ed82c7cadcf484f3a01 is the bad commit.
I use sway 1.10.1 on openSUSE Tumbleweed.
Could you replicate this and dump the log to a text file? Trying to read the event log in the video isn't working, especially since some bits are obscured by the window.
Here is the log. It's quite large, but lines below 2000 are kind of redundant: https://gist.github.com/hwsmm/6252859a238a7ae6fbb808d45293811d
The problem is this event: wl_pointer#30.motion(0, 336.67968750, 221.28906250)
Raising the pen seems to cause a pointer motion event with a timestamp of 0 to be emitted by the compositor, which corrupts the timestamp offset since it looks like the timer rolled over.
So, it seems that Sway is at fault... I will try reporting this bug to Sway a bit later.
I'm leaving this open until we get some feedback from Sway, but in the meantime, I committed e3d44cdd51155946bd0762cd0d8e8c75f5e9ed4e, which uses the raw timestamp from the key down/up events to calculate the elapsed repeat time, so it won't grind everything to a halt while trying to enqueue days worth of repeat events if an anomalous timestamp from a different event occurs between the press and release.
Wayland 1.24 will have seat v10, which lets the compositor handle sending key repeat events instead of forcing clients to do it manually, which will make this irrelevant once it is adopted.
It got fixed in Sway, so I'll just close this issue.