From: Yariv <oigevald+kernel@gmail.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org
Subject: PROBLEM: Apple external Trackpad event timestamps are jittery (regression)
Date: Mon, 11 May 2020 09:18:15 +0300 [thread overview]
Message-ID: <CAEwx+QrfLk4SR=yn4Df3rD_Lm0Xht1hgAi4szmOTU1nkFhMwhw@mail.gmail.com> (raw)
Using a vanilla installation of Ubuntu 20.04 (kernel v5.4), the
timestamps of input events from my Apple "Magic Trackpad" - 1st
generation, connected over Bluetooth - are jittery.
This is a kernel regression. I bisected the bug.
- The problem starts with upstream kernel commit 3b51c44bd693 ("Input:
allow drivers specify timestamp for input events"). After that commit,
the same timestamp is always emitted.
- This was partially fixed in commit 4370b231d100 ("Input: reset
device timestamp on sync"), however ever since then the timestamps are
jittery.
The problem still exists in the current upstream 'master' (commit c45e8bccecaf).
The following patch fixes the bug, however this is obviously a hack.
It effectively reverts commit 3b51c44bd693:
diff --git a/drivers/input/input.c b/drivers/input/input.c
index 3cfd2c18eebd..8890195547d6 100644
--- a/drivers/input/input.c
+++ b/drivers/input/input.c
@@ -1958,7 +1958,7 @@ ktime_t *input_get_timestamp(struct input_dev *dev)
{
const ktime_t invalid_timestamp = ktime_set(0, 0);
- if (!ktime_compare(dev->timestamp[INPUT_CLK_MONO], invalid_timestamp))
+ // if (!ktime_compare(dev->timestamp[INPUT_CLK_MONO], invalid_timestamp))
input_set_timestamp(dev, ktime_get());
return dev->timestamp;
Reproducing the bug
----------------------------
I used the following script as a reproducer. It relies on
libinput-debug-events. This script measures the time delta between
consecutive input events, then prints a "histogram" of these deltas.
#!/bin/bash
# log file name
logFile=${1:-~/Downloads/`uname -r`}
echo logFile=$logFile
if [[ "$1" == '' ]]; then
echo record
# log some events
sudo libinput debug-events | grep POINTER | tee $logFile
fi
# process the results
lastN=0
for f in `cat $logFile | awk '{print $3}' | sed "s/s//g" | sed "s/+//g"`;
do
echo "$f-$lastN" | bc;
lastN=$f;
done | sort | uniq -c
Steps to reproduce
-------------------------
1. Pair an external Apple Trackpad over Bluetooth.
2. Run the above script
3. Move your finger in circles on the external trackpad for a few seconds
4. Press ctrl+c
An example output of this script before the regression
-----------------------------------------------------------------------
2 .010
371 .011
127 .012
1 .876
The above output means that: 2 times the delta was 10ms, 371 times
11ms, 127 times 12ms and 1 time 876ms. This corresponds well with the
Trackpad's ~90Hz polling rate.
An example output of this script after the regression
---------------------------------------------------------------------
3 .003
12 .004
16 .005
14 .006
21 .007
16 .008
20 .009
13 .010
359 .011
47 .012
20 .013
17 .014
21 .015
14 .016
16 .017
15 .018
2 .019
1 .020
38 .022
21 .023
1 1.060
I suspect that other input devices might be affected as well.
The bug was reported downstream at
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1876449
Please let me know if you prefer that I open a corresponding issue in
the kernel bugzilla.
Best regards,
Yariv
next reply other threads:[~2020-05-11 6:18 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-11 6:18 Yariv [this message]
2020-05-11 20:11 ` PROBLEM: Apple external Trackpad event timestamps are jittery (regression) Dmitry Torokhov
2020-05-12 5:19 ` Peter Hutterer
2020-05-12 19:54 ` Yariv
2020-05-22 5:27 ` Yariv
2020-05-23 18:37 ` Dmitry Torokhov
2020-05-23 19:11 ` Yariv
2020-05-23 21:18 ` Dmitry Torokhov
2020-05-24 11:36 ` Yariv
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAEwx+QrfLk4SR=yn4Df3rD_Lm0Xht1hgAi4szmOTU1nkFhMwhw@mail.gmail.com' \
--to=oigevald+kernel@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).