Bug 102385

Summary: Forced touchscreen input device remove action via udev does not trigger touch-ups appropriately
Product: Wayland Reporter: Pekka Paalanen <ppaalanen>
Component: libinputAssignee: Peter Hutterer <peter.hutterer>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium CC: peter.hutterer
Version: unspecified   
Hardware: ARM   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:

Description Pekka Paalanen 2017-08-24 11:06:16 UTC
We have a system with two touchscreens connected and a modified Weston based on 1.11.1 release. Libinput is 1.4.3. The two touch devices are aggregated into a single wl_seat in Weston.

We need to be able to do touchscreen calibration on the fly by user request without restarting Weston and keep the existing calibration across reboots. As we do not have a protocol extension for touchscreen calibration, there is a calibration script, that clears the existing calibration,  flushes the calibration in udev, uses udev API for force-remove and re-add the touchscreen input device, launches weston-calibrator, refreshes the calibration matrix in udev, and uses udev API for force-remove and re-add the touchscreen input device in question. This force-remove and re-add triggers Weston to re-read the calibration from udev. As only one touch device is force-removed at a time, the wl_seat never loses the touch capability.

In our case the following process is enough to trigger this:
    
    1) Place finger on touchscreen
    2) Run "udevadm trigger -c remove -s input --name-match=/dev/input/event7" (This being out touchscreen input device)
    3) Remove finger
    4) Run "udevadm trigger -c add -s input --name-match=/dev/input/event7"
    5) Note touchscreen is unresponsive

If there is a touch down on the touch device at the time of its forced removal, Weston's DRM backend does not relay the required touch-up events to Weston core to update the touch-down counts. This leaves Weston core to believe there is a touch down, which cannot be released anymore, leading to essentially dead touchscreen.

Based on the IRC discussion with Peter Hutterer, the issue of the missing touch-ups might be a race in libinput. Or not. This bug report is to figure out if there would be anything to fix in libinput, or should Weston do something different.

Quoting Peter: "if I can reproduce it with a delayed libinput_dispatch() then I'll fix it in libinput for sure because that's what we promise."

It was tested once that if one physically unplugs the touch device from USB while a finger is down, then the touch-up came as it should.
Comment 1 Peter Hutterer 2017-08-28 01:46:36 UTC
Turns out this was fixed with 61e8542d6e578fd6fa7679452738c9ad3edf22e7

git tag --contains 61e8542d6e578fd6fa7679452738c9ad3edf22e7
1.4.901
1.5.0
1.5.1
1.5.2
1.5.3
1.5.4
...

You're one release too old ;) Should be possible to backport it though.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.