Bug 100057

Summary: sporadic duplicate ButtonPress/ButtonRelease events for left mouse button only
Product: Wayland Reporter: joe.harvell.x
Component: libinputAssignee: Wayland bug list <wayland-bugs>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: medium CC: peter.hutterer
Version: unspecified   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: Xorg Server log file
output of xinput --list --long
evemu-record on /dev/input/event10
evemu-record on /dev/input/event12
xev button events

Description joe.harvell.x 2017-03-04 02:31:53 UTC
Created attachment 130061 [details]
Xorg Server log file

libinput version is 1.6.2

I have only one keyboard and one mouse.  Sometimes the X-server gets into a state where pressing the left mouse button generates two ButtonPress/ButtonRelease events for a single press/release:

ButtonPress event, serial 40, synthetic NO, window 0x5a00001,
    root 0x4b9, subw 0x0, time 80885247, (55,108), root:(1959,165),
    state 0x0, button 1, same_screen YES

ButtonRelease event, serial 40, synthetic NO, window 0x5a00001,
    root 0x4b9, subw 0x0, time 80885295, (55,108), root:(1959,165),
    state 0x100, button 1, same_screen YES

ButtonPress event, serial 40, synthetic NO, window 0x5a00001,
    root 0x4b9, subw 0x0, time 80885310, (55,108), root:(1959,165),
    state 0x0, button 1, same_screen YES

ButtonRelease event, serial 40, synthetic NO, window 0x5a00001,
    root 0x4b9, subw 0x0, time 80885342, (55,108), root:(1959,165),
    state 0x100, button 1, same_screen YES


Once it gets in this state, maybe the duplicate events happen 1/3 of the time.  It comes and goes.

I only see this for the left mouse button.

When I press and hold the left mouse button and release only after several seconds, then the duplicate Press/Release sequence comes after the first Release:

ButtonPress event, serial 40, synthetic NO, window 0x5a00001,
    root 0x4b9, subw 0x0, time 81126422, (114,108), root:(2018,165),
    state 0x0, button 1, same_screen YES

ButtonRelease event, serial 40, synthetic NO, window 0x5a00001,
    root 0x4b9, subw 0x0, time 81128158, (114,108), root:(2018,165),
    state 0x100, button 1, same_screen YES

ButtonPress event, serial 40, synthetic NO, window 0x5a00001,
    root 0x4b9, subw 0x0, time 81128166, (114,108), root:(2018,165),
    state 0x0, button 1, same_screen YES

ButtonRelease event, serial 40, synthetic NO, window 0x5a00001,
    root 0x4b9, subw 0x0, time 81128182, (114,108), root:(2018,165),
    state 0x100, button 1, same_screen YES


Note the times of the last 3 are all close together.

I don't think this is a hardware issue, because I am not the first person to report this (http://superuser.com/questions/750818/x11-evdev-mouse-generates-duplicate-events).  This report was from 2014.

I also have had this happen before years ago on the same system as today (maybe around 2014), but eventually it went away (I upgrade packages frequently).  I recently did a major system upgrade.
Comment 1 joe.harvell.x 2017-03-04 02:33:04 UTC
Created attachment 130062 [details]
output of xinput --list --long
Comment 2 joe.harvell.x 2017-03-04 02:34:08 UTC
I originally filed this bug report with Gentoo (my Linux distro).  The suggested I report it upstream to you. https://bugs.gentoo.org/show_bug.cgi?id=611248
Comment 3 Peter Hutterer 2017-03-05 22:08:41 UTC
I'll need an evemu-record for when this happens, this should make it clear where the bug sits, thanks.
Comment 4 joe.harvell.x 2017-03-10 19:19:59 UTC
I installed evemu.

I see the following in /dev/input:

jharvell@wolfhound /dev/input $ ls -l
total 0
drwxr-xr-x 2 root root     100  7 mars  17:54 by-id
drwxr-xr-x 2 root root     120  7 mars  17:54 by-path
crw-rw---- 1 root input 13, 64  7 mars  17:54 event0
crw-rw---- 1 root input 13, 65  7 mars  17:54 event1
crw-rw---- 1 root input 13, 74  7 mars  17:54 event10
crw-rw---- 1 root input 13, 75  7 mars  17:54 event11
crw-rw---- 1 root input 13, 76  7 mars  17:54 event12
crw-rw---- 1 root input 13, 66  7 mars  17:54 event2
crw-rw---- 1 root input 13, 67  7 mars  17:54 event3
crw-rw---- 1 root input 13, 68  7 mars  17:54 event4
crw-rw---- 1 root input 13, 69  7 mars  17:54 event5
crw-rw---- 1 root input 13, 70  7 mars  17:54 event6
crw-rw---- 1 root input 13, 71  7 mars  17:54 event7
crw-rw---- 1 root input 13, 72  7 mars  17:54 event8
crw-rw---- 1 root input 13, 73  7 mars  17:54 event9
crw-rw---- 1 root input 13, 63  7 mars  17:54 mice
crw-rw---- 1 root input 13, 32  7 mars  17:54 mouse0
crw-rw---- 1 root input 13, 33  7 mars  17:54 mouse1

jharvell@wolfhound /dev/input $ ls -l by-id/
total 0
lrwxrwxrwx 1 root root  9  7 mars  17:54 usb-DELL_Dell_USB_Entry_Keyboard-event-kbd -> ../event9
lrwxrwxrwx 1 root root 10  7 mars  17:54 usb-Logitech_USB_Optical_Mouse-event-mouse -> ../event11
lrwxrwxrwx 1 root root  9  7 mars  17:54 usb-Logitech_USB_Optical_Mouse-mouse -> ../mouse0


It seems like there are multiple input chardevs for both the keyboard and mouse:

Keyboard...

jharvell@wolfhound /dev/input $ sudo evemu-describe event2 | head -n5
# EVEMU 1.3
# Kernel: 4.10.0-jchlb-2235ea3
# DMI: dmi:bvnDellInc.:bvrA09:bd05/03/2013:svnDellInc.:pnPrecisionT5600:pvr01:rvnDellInc.:rn0GN6JF:rvrA01:cvnDellInc.:ct7:cvr:
# Input device name: "AT Translated Set 2 keyboard"
# Input device ID: bus 0x11 vendor 0x01 product 0x01 version 0xab41
jharvell@wolfhound /dev/input $ sudo evemu-describe event9 | head -n5
# EVEMU 1.3
# Kernel: 4.10.0-jchlb-2235ea3
# DMI: dmi:bvnDellInc.:bvrA09:bd05/03/2013:svnDellInc.:pnPrecisionT5600:pvr01:rvnDellInc.:rn0GN6JF:rvrA01:cvnDellInc.:ct7:cvr:
# Input device name: "DELL Dell USB Entry Keyboard"
# Input device ID: bus 0x03 vendor 0x413c product 0x2107 version 0x110

Mouse...

jharvell@wolfhound /dev/input $ sudo evemu-describe event11 | head -n5
# EVEMU 1.3
# Kernel: 4.10.0-jchlb-2235ea3
# DMI: dmi:bvnDellInc.:bvrA09:bd05/03/2013:svnDellInc.:pnPrecisionT5600:pvr01:rvnDellInc.:rn0GN6JF:rvrA01:cvnDellInc.:ct7:cvr:
# Input device name: "Logitech USB Optical Mouse"
# Input device ID: bus 0x03 vendor 0x46d product 0xc077 version 0x111
jharvell@wolfhound /dev/input $ sudo evemu-describe event12 | head -n5
# EVEMU 1.3
# Kernel: 4.10.0-jchlb-2235ea3
# DMI: dmi:bvnDellInc.:bvrA09:bd05/03/2013:svnDellInc.:pnPrecisionT5600:pvr01:rvnDellInc.:rn0GN6JF:rvrA01:cvnDellInc.:ct7:cvr:
# Input device name: "PS/2 Generic Mouse"
# Input device ID: bus 0x11 vendor 0x02 product 0x01 version 0000


jharvell@wolfhound /dev/input $ sudo evemu-describe mouse
mouse0  mouse1  
jharvell@wolfhound /dev/input $ sudo evemu-describe mouse0 
error: could not describe device
jharvell@wolfhound /dev/input $ sudo evemu-describe mouse1
error: could not describe device

I am guessing the problem is the two evdevs for the same mouse.  If you want me to do an evemu-record to confirm, I gues you want me to do that on both event11 and event12?
Comment 5 Peter Hutterer 2017-03-10 23:13:55 UTC
just run sudo evemu without any arguments, it'll give you a list of devices to pick. Pick the one(s) that is your mouse and record them, if there are multiple event nodes (quite common) just record all of them. In the end, only one node will matter for this bug.
Comment 6 Peter Hutterer 2017-03-15 23:39:42 UTC
ping?
Comment 7 joe.harvell.x 2017-03-16 15:55:19 UTC
Created attachment 130261 [details]
evemu-record on /dev/input/event10
Comment 8 joe.harvell.x 2017-03-16 15:55:51 UTC
Created attachment 130262 [details]
evemu-record on /dev/input/event12
Comment 9 joe.harvell.x 2017-03-16 15:56:21 UTC
Created attachment 130265 [details]
xev button events
Comment 10 joe.harvell.x 2017-03-16 16:01:10 UTC
Sorry for the delay.

While running 'xev -event mouse', I ran evemu-record on /dev/input/event10 and also ran a separate evemu-record on /dev/input/event12.  I pressed the left mouse button 4 times.  On the fourth time, I observed in xev output 4 events for that one press (ButtonPress, ButtonRelease, ButtonPress, ButtonRelease).
Comment 11 Peter Hutterer 2017-03-16 22:42:58 UTC
fourth button press in evemu recording corresponds to this sequence here:

E: 12.792386 0004 0004 589825	# EV_MSC / MSC_SCAN             589825
E: 12.792386 0001 0110 0001	# EV_KEY / BTN_LEFT             1
E: 12.792386 0000 0000 0000	# ------------ SYN_REPORT (0) ---------- +704ms
E: 12.816312 0004 0004 589825	# EV_MSC / MSC_SCAN             589825
E: 12.816312 0001 0110 0000	# EV_KEY / BTN_LEFT             0
E: 12.816312 0000 0000 0000	# ------------ SYN_REPORT (0) ---------- +24ms
E: 12.824400 0004 0004 589825	# EV_MSC / MSC_SCAN             589825
E: 12.824400 0001 0110 0001	# EV_KEY / BTN_LEFT             1
E: 12.824400 0000 0000 0000	# ------------ SYN_REPORT (0) ---------- +8ms
E: 12.872370 0004 0004 589825	# EV_MSC / MSC_SCAN             589825
E: 12.872370 0001 0110 0000	# EV_KEY / BTN_LEFT             0
E: 12.872370 0000 0000 0000	# ------------ SYN_REPORT (0) ---------- +48ms

which is left down (700ms after previous event), left up 24ms later, left down 8ms later, and then up again. Given that you can't release and press down within 8ms, this looks like a hardware issue.

There's nothing in libinput right now to work around that because the need for button debouncing is notoriously hard to detect correctly and the amount of work required to write it pales in comparison to the cost of a new mouse...
Comment 12 joe.harvell.x 2017-03-16 22:48:09 UTC
I will switch out the mouse and see if the problem goes away.
Comment 13 Peter Hutterer 2017-03-17 01:14:32 UTC
yes please. I'm closing this bug for now but please re-open if it's the same with the other mouse.
Comment 15 Peter Hutterer 2017-07-25 14:35:06 UTC
commit 55d1bb1217388e99b9405654c14881a9ebf8f880
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Jul 14 13:42:53 2017 +1000

    pointer: add button debouncing

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.