[PATCH libinput 0/1] Fix debouncing algorithm

Peter Hutterer peter.hutterer at who-t.net
Wed Nov 8 11:19:04 UTC 2017


On Tue, Nov 07, 2017 at 10:26:11PM +0100, Vicente Bergas wrote:
> Hi Peter,
> 
> On Thu, Nov 2, 2017 at 2:04 AM, Peter Hutterer <peter.hutterer at who-t.net> wrote:
> > On Thu, Nov 02, 2017 at 12:34:01AM +0100, Vicente Bergas wrote:
> ...
> >> I hope it is fixed, but not been able to run the test-suite.
> >> Please, can you confirm if the new test-suite passes?
> >
> > running the full test suite should be a simple sudo ninja test, or you run
> > it directly with
> >  sudo ./build/libinput-test-suite-runner --filter-test="*sometestname*"
> > That is particularly useful when you are working on a specific feature and
> > want a quick test turnover time (the full suite can take up 20 min or
> > longer)
> >
> > https://wayland.freedesktop.org/libinput/doc/latest/test-suite.html
> > has more documentation and we can add to that what's missing
> 
> I ran the test suite and it failed :(
> One of the reasons it failed is because the time parameter passed to
> fallback_interface_process is far behind the current time.
> Is that expected?
> I expected that the time parameter would be the same (or very close
> to) the current time.

yeah, it should be. in most case you get an  error message like this:
litest error libinput bug: timer event19 debounce: offset negative (-3165)
where the 'debounce' bit is the timer's name that gets wrongly set. For the
test cases it's often a sign of a missing libinput_dispatch()
e.g. for the timer_debounce it works with this diff applied:

diff --git a/test/test-pointer.c b/test/test-pointer.c
index 25ddc765..3ce80840 100644
--- a/test/test-pointer.c
+++ b/test/test-pointer.c
@@ -2154,6 +2154,7 @@ START_TEST(debounce_timer)
        litest_event(dev, EV_SYN, SYN_REPORT, 0);
        litest_event(dev, EV_KEY, BTN_LEFT, 0);
        litest_event(dev, EV_SYN, SYN_REPORT, 0);
+       libinput_dispatch(li);

        litest_timeout_debounce();
        litest_drain_events(li);


but I also see failures in e.g. trackpoint_topsoftbuttons_left_handed_both,
touchpad_left_handed and pointer_left_handed which have no obvious error in
the test case. After debugging this for way too long I discovered/remembered
that litest_button_click() forces a debounce timeout (15ms). That's likely
the source of your offsets, any test with that call can cause the test case
failure. The debounce timeout was added there because otherwise we'd have to
update a lot of test cases for debouncing - I guess with your new algorithm
we'll have to do this anyway.

Cheers,
   Peter



> If you apply the following patch to the currently released libinput,
> then you will be able to reproduce with:
> ./build/libinput-test-suite-runner --filter-test="debouce_timer"
> All 14 tests will fail in the newly added check.
> 
> --- a/src/evdev-fallback.c
> +++ b/src/evdev-fallback.c
> @@ -28,6 +28,8 @@
> 
>  #include <mtdev-plumbing.h>
> 
> +#include <inttypes.h>
> +
>  #include "evdev.h"
> 
>  #define    DEBOUNCE_TIME ms2us(12)
> @@ -1132,6 +1134,10 @@ fallback_interface_process(struct
> evdev_dispatch *evdev_dispatch,
>      struct fallback_dispatch *dispatch = fallback_dispatch(evdev_dispatch);
>      enum evdev_event_type sent;
> 
> +    uint64_t now = libinput_now(dispatch->debounce.timer.libinput);
> +    if(time+DEBOUNCE_TIME < now)
> +        log_bug_libinput(dispatch->debounce.timer.libinput, "event
> time is far behind: %"PRId64"\n", time-now);
> +


>      if (dispatch->ignore_events)
>          return;
> 
> (this patch is for ilustrative purposes only, not to be merged)
> 
> Regards,
>   Vicente.
> 
> >
> > rest of the comments are in the v2 patch (haven't looked at it yet though),
> > many thanks for the v2
> >
> > Cheers,
> >    Peter
> ...


More information about the wayland-devel mailing list