Mir

Merge lp:~vanvugt/mir/remove-input-resampling-standalone into lp:mir

Proposed by Daniel van Vugt
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 3949
Proposed branch: lp:~vanvugt/mir/remove-input-resampling-standalone
Merge into: lp:mir
Diff against target: 522 lines (+48/-274)
7 files modified
examples/fingerpaint.c (+0/-6)
examples/target.c (+0/-6)
src/client/input/android/android_input_receiver.cpp (+26/-98)
src/client/input/android/android_input_receiver.h (+3/-12)
tests/acceptance-tests/test_client_input.cpp (+0/-64)
tests/acceptance-tests/test_confined_pointer.cpp (+0/-1)
tests/unit-tests/client/input/test_android_input_receiver.cpp (+19/-87)
To merge this branch: bzr merge lp:~vanvugt/mir/remove-input-resampling-standalone
Reviewer Review Type Date Requested Status
Mir CI Bot continuous-integration Approve
Andreas Pokorny (community) Approve
Alan Griffiths Abstain
Chris Halse Rogers Approve
Review via email: mp+314305@code.launchpad.net

Commit message

Remove input resampling, finally.

Input events now get delivered from the kernel (via AndroidInput which we
can now retire) to clients without any resampling delay. That was [0,16.9]ms or an average of 8.4ms before, but is now around 0.2ms.

This fixes LP: #1570698 and LP: #1576600. Probably LP: #1394369 too.

Description of the change

I had believed until recently that we would need to land client-side vsync
before we could do this. However I have now invented a simpler
prerequisite which allows Mir to drop input resampling immediately:
lp:~vanvugt/unity8/fix-1497105

To post a comment you must log in.
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3910
https://mir-jenkins.ubuntu.com/job/mir-ci/2569/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/3347/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/3414
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/3406
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/3406
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/3406
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/3376
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/3376/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3376
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3376/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/3376/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3376
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3376/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3376
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3376/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3376
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3376/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/2569/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3911
https://mir-jenkins.ubuntu.com/job/mir-ci/2571/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/3349
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/3416
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/3408
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/3408
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=yakkety/3408
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/3378
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=yakkety/3378/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3378
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3378/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/3378
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=yakkety/3378/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3378
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3378/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3378
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3378/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3378
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3378/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/2571/rebuild

review: Approve (continuous-integration)
Revision history for this message
Chris Halse Rogers (raof) wrote :

The AndroidInputReceiverSetup.slow_raw_input_doesnt_cause_frameskipping test definitely needs renaming, because it no longer tests anything of the sort.

I'm weakly against the change to dispatch multiple events in a single process_and_maybe_send_event(). Your comment is incorrect - there were no races: if consume() didn't read all the events from the fd then it would remain readable and we'd return to the dispatcher and immediately get called again.

When client-driven dispatch is available clients are going to expect to get a single event out of a single dispatch call.

**** So: ****

*) Rename or remove AndroidInputReceiverSetup.slow_raw_input_doesnt_cause_frameskipping
*) Don't loop in process_and_maybe_send_event()

Optional:
*) Maybe rename process_and_maybe_send_event()? I'm pretty sure it is now always going to send an event.
*) Test that you get at most one event sent per dispatch() on the AndroidInputReceiver?

review: Needs Fixing
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I knew you would say that. Unfortunately I did try exactly what you suggested as a first choice and it seemed broken (either was no longer readable or the Dispatchable ignored wakeups). Will need to dig deeper now to find out why...

Revision history for this message
Chris Halse Rogers (raof) wrote :

Curious. MultiplexingDispatchable definitely uses level (rather than
edge) triggering, the socket is SEQPACKET, so there's guaranteed to
only be whole events there, and consume() looks like it should only eat
one...

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

> Curious. MultiplexingDispatchable definitely uses level (rather than
> edge) triggering, the socket is SEQPACKET, so there's guaranteed to
> only be whole events there, and consume() looks like it should only eat
> one...

I think thats what the second parameter "consumeBatches" does .. passing false there should help.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

No, consumeBatches should always be true now. We don't batch anything and want clients to receive all events immediately.

It was just our tests were overly simplistic and not able to consume wake notifications when they dispatch(), leaving the fd readable indefinitely. So it was just a problem with the tests. But instead of modifying the tests too much I have reworked the semaphore logic to deal with the simplistic test expectations so that dispatch() can also drain wake()'s.

Revision history for this message
Chris Halse Rogers (raof) wrote :

On 10 Jan. 2017 18:30, Andreas Pokorny <email address hidden> wrote:

>

> > Curious. MultiplexingDispatchable definitely uses level (rather than

> > edge) triggering, the socket is SEQPACKET, so there's guaranteed to

> > only be whole events there, and consume() looks like it should only eat

> > one...

>

> I think thats what the second parameter "consumeBatches" does .. passing false there should help.

Actually, I think it no longer matters what value use for consumeBatches - because we pass in a frame time of -1, I'm pretty sure we never generate any batches.

(Relatedly, I think this means we can delete almost all of AndroidInput)

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

iirc conumeBatches = true means that we read stuff from the socket without handing it out to the caller.. So we need to wake() the consuming thread again.

I am a bit confused now. Is the intention to remove batching and resampling, or just resampling?
Last time I wallowed in that code resampling only affected touch motion and not pointer movement, so this will only affect that X11-Mouse behavior if we also drop batching.

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3915
https://mir-jenkins.ubuntu.com/job/mir-ci/2605/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/3387/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/3454
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/3446
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/3446
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/3446
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/3416/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3416/console
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/3416/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3416
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3416/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3416
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3416/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3416
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3416/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/2605/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

Ah this MP also removes the timer fd! So it will affect the frequency of mouse events.

Then using false instead of true for consumeBatches should actually not drain the input channel fd. I assume it would be simpler to just serialize the MirEvent into a buffer in BasicSurface::consume_event and write it to the InputChannel fd, while on AndroirInputReceiver just deserialize from the fd, and get rid of all the rest..

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3916
https://mir-jenkins.ubuntu.com/job/mir-ci/2606/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/3388/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/3455
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/3447
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/3447
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/3447
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/3417/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3417
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3417/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/3417/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3417
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3417/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3417
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3417/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3417
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3417/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/2606/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

CI failures are bug 1655293 and bug 1639941. Is this branch aggravating those?...

Revision history for this message
Daniel van Vugt (vanvugt) wrote :
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3917
https://mir-jenkins.ubuntu.com/job/mir-ci/2633/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/3423
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/3490
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/3482
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/3482
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/3482
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/3452
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/3452/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3452
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3452/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/3452
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/3452/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3452
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3452/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3452
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3452/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3452
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3452/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/2633/rebuild

review: Approve (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3920
https://mir-jenkins.ubuntu.com/job/mir-ci/2674/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/3474/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/3541
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/3531
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/3531
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/3531
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/3501
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/3501/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3501
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3501/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/3501
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/3501/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3501
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3501/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3501
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3501/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3501/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/2674/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :
Revision history for this message
Chris Halse Rogers (raof) wrote :

LGTM, thanks.

I continue to be surprised that the FD doesn't remain readable if there's still an event left after consume(), and we'll be woken up once more than is strictly necessary, but this is fine.

review: Approve
Revision history for this message
Chris Halse Rogers (raof) wrote :

+ if (read(wake_fd, &dummy, sizeof(dummy)) != sizeof(dummy) &&
+ errno != EAGAIN)

Hm, now that I look at this again, I think you might be missing && errno != EINTR?

Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3925
https://mir-jenkins.ubuntu.com/job/mir-ci/2686/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/3488/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/3555
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/3545
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/3545
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/3545
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/3515/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3515
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3515/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/3515
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/3515/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3515
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3515/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3515
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3515/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3515
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3515/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/2686/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3927
https://mir-jenkins.ubuntu.com/job/mir-ci/2709/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/3520/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/3588
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/3578
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/3578
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/3578
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/3547
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/3547/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3547
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3547/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/3547
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/3547/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3547
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3547/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3547
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3547/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3547/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/2709/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3928
https://mir-jenkins.ubuntu.com/job/mir-ci/2712/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/3525/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/3593
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/3583
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/3583
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/3583
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/3552/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3552
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3552/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/3552/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3552
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3552/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3552
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3552/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3552/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/2712/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

FAILED: Continuous integration, rev:3929
https://mir-jenkins.ubuntu.com/job/mir-ci/2713/
Executed test runs:
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-mir/3527/console
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/3595
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/3585
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial+overlay/3585
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=zesty/3585
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/3554
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=zesty/3554/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3554
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial+overlay/3554/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/3554
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=zesty/3554/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3554
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/3554/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3554
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/3554/artifact/output/*zip*/output.zip
    FAILURE: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial+overlay/3554/console

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/2713/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

I don't feel I understand this code well enough to have an opinion. (Would like to hear from Andreas.)

review: Abstain
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

I am in favor of this change - my only opinions here are that we could simplify more... Each further step raises the question - do we want to send input related MirEvents through the "normal" MirConnection fd?

From personal use on the phone I prefer not having the resampling, and also activate a different cpu frequency governor - so from that pov I am not concerned about removing the resampling..

But we can do that in a later MP.

review: Approve
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

Poor editing of my last review comment, lead to some confusion. By "that" I meant the removal of the remaining android input parts and using the fd of the session.

Revision history for this message
Mir CI Bot (mir-ci-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'examples/fingerpaint.c'
--- examples/fingerpaint.c 2017-01-12 03:18:54 +0000
+++ examples/fingerpaint.c 2017-01-16 08:35:54 +0000
@@ -16,8 +16,6 @@
16 * Author: Daniel van Vugt <daniel.van.vugt@canonical.com>16 * Author: Daniel van Vugt <daniel.van.vugt@canonical.com>
17 */17 */
1818
19#define _POSIX_C_SOURCE 200112L // for setenv() from stdlib.h
20
21#include "mir_toolkit/mir_client_library.h"19#include "mir_toolkit/mir_client_library.h"
22#include "mir_toolkit/events/input/input_event.h"20#include "mir_toolkit/events/input/input_event.h"
2321
@@ -415,10 +413,6 @@
415 }413 }
416 }414 }
417415
418 // We do our own resampling now. We can keep up with raw input...
419 // TODO: Replace setenv with a proper Mir function (LP: #1439590)
420 setenv("MIR_CLIENT_INPUT_RATE", "0", 0);
421
422 conn = mir_connect_sync(mir_socket, argv[0]);416 conn = mir_connect_sync(mir_socket, argv[0]);
423 if (!mir_connection_is_valid(conn))417 if (!mir_connection_is_valid(conn))
424 {418 {
425419
=== modified file 'examples/target.c'
--- examples/target.c 2017-01-12 03:18:54 +0000
+++ examples/target.c 2017-01-16 08:35:54 +0000
@@ -16,7 +16,6 @@
16 * Author: Daniel van Vugt <daniel.van.vugt@canonical.com>16 * Author: Daniel van Vugt <daniel.van.vugt@canonical.com>
17 */17 */
1818
19#define _POSIX_C_SOURCE 200112L // for setenv() from stdlib.h
20#include "eglapp.h"19#include "eglapp.h"
21#include <assert.h>20#include <assert.h>
22#include <stdio.h>21#include <stdio.h>
@@ -265,11 +264,6 @@
265 sigaddset(&sigs, SIGHUP);264 sigaddset(&sigs, SIGHUP);
266 pthread_sigmask(SIG_BLOCK, &sigs, NULL);265 pthread_sigmask(SIG_BLOCK, &sigs, NULL);
267266
268 // Disable Mir's input resampling. We do our own here, in a way that
269 // has even lower latency than Mir's default algorithm.
270 // TODO: Make a proper client API function for this:
271 setenv("MIR_CLIENT_INPUT_RATE", "0", 0);
272
273 static unsigned int width = 0, height = 0;267 static unsigned int width = 0, height = 0;
274 if (!mir_eglapp_init(argc, argv, &width, &height, NULL))268 if (!mir_eglapp_init(argc, argv, &width, &height, NULL))
275 return 1;269 return 1;
276270
=== modified file 'src/client/input/android/android_input_receiver.cpp'
--- src/client/input/android/android_input_receiver.cpp 2016-10-31 02:37:31 +0000
+++ src/client/input/android/android_input_receiver.cpp 2017-01-16 08:35:54 +0000
@@ -53,54 +53,29 @@
53mircva::InputReceiver::InputReceiver(droidinput::sp<droidinput::InputChannel> const& input_channel,53mircva::InputReceiver::InputReceiver(droidinput::sp<droidinput::InputChannel> const& input_channel,
54 std::shared_ptr<mircv::XKBMapper> const& keymapper,54 std::shared_ptr<mircv::XKBMapper> const& keymapper,
55 std::function<void(MirEvent*)> const& event_handling_callback,55 std::function<void(MirEvent*)> const& event_handling_callback,
56 std::shared_ptr<mircv::InputReceiverReport> const& report,56 std::shared_ptr<mircv::InputReceiverReport> const& report)
57 AndroidClock clock)57 : wake_fd{valid_fd_or_system_error(eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK),
58 : timer_fd{valid_fd_or_system_error(timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC),
59 "Failed to create IO timer")},
60 wake_fd{valid_fd_or_system_error(eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK | EFD_SEMAPHORE),
61 "Failed to create IO wakeup notifier")},58 "Failed to create IO wakeup notifier")},
62 input_channel(input_channel),59 input_channel(input_channel),
63 handler{event_handling_callback},60 handler{event_handling_callback},
64 xkb_mapper(keymapper),61 xkb_mapper(keymapper),
65 report(report),62 report(report),
66 input_consumer(std::make_shared<droidinput::InputConsumer>(input_channel)),63 input_consumer(std::make_shared<droidinput::InputConsumer>(input_channel))
67 android_clock(clock)
68{64{
69 /*65 dispatcher.add_watch(wake_fd,
70 * 59Hz by default. This ensures the input rate never gets ahead of the66 [this]() { woke(); });
71 * typical display rate, which would be seen as visible lag.
72 */
73 event_rate_hz = 59;
74 auto env = getenv("MIR_CLIENT_INPUT_RATE");
75 if (env != NULL)
76 event_rate_hz = atoi(env);
77
78 dispatcher.add_watch(timer_fd, [this]()
79 {
80 consume_wake_notification(timer_fd);
81 process_and_maybe_send_event();
82 });
83
84 dispatcher.add_watch(wake_fd, [this]()
85 {
86 consume_wake_notification(wake_fd);
87 process_and_maybe_send_event();
88 });
89
90 dispatcher.add_watch(mir::Fd{mir::IntOwnedFd{input_channel->getFd()}},67 dispatcher.add_watch(mir::Fd{mir::IntOwnedFd{input_channel->getFd()}},
91 [this]() { process_and_maybe_send_event(); });68 [this]() { woke(); });
92}69}
9370
94mircva::InputReceiver::InputReceiver(int fd,71mircva::InputReceiver::InputReceiver(int fd,
95 std::shared_ptr<mircv::XKBMapper> const& keymapper,72 std::shared_ptr<mircv::XKBMapper> const& keymapper,
96 std::function<void(MirEvent*)> const& event_handling_callback,73 std::function<void(MirEvent*)> const& event_handling_callback,
97 std::shared_ptr<mircv::InputReceiverReport> const& report,74 std::shared_ptr<mircv::InputReceiverReport> const& report)
98 AndroidClock clock)
99 : InputReceiver(new droidinput::InputChannel(droidinput::String8(""), fd),75 : InputReceiver(new droidinput::InputChannel(droidinput::String8(""), fd),
100 keymapper,76 keymapper,
101 event_handling_callback,77 event_handling_callback,
102 report,78 report)
103 clock)
104{79{
105}80}
10681
@@ -138,36 +113,28 @@
138113
139}114}
140115
141void mircva::InputReceiver::process_and_maybe_send_event()116void mircva::InputReceiver::woke()
142{117{
118 uint64_t dummy;
119
120 /*
121 * We never care about the cause of the wakeup. Either real input or a
122 * wake(). Either way the only requirement is that we woke() after each
123 * wake() or real input channel event.
124 */
125 if (read(wake_fd, &dummy, sizeof(dummy)) != sizeof(dummy) &&
126 errno != EAGAIN &&
127 errno != EINTR)
128 {
129 BOOST_THROW_EXCEPTION((std::system_error{errno,
130 std::system_category(),
131 "Failed to consume notification"}));
132 }
133
143 droidinput::InputEvent *android_event;134 droidinput::InputEvent *android_event;
144 uint32_t event_sequence_id;135 uint32_t event_sequence_id;
145136
146 /*137 auto const frame_time = std::chrono::nanoseconds(-1);
147 * Enable "Project Butter" input resampling in InputConsumer::consume():
148 * consumeBatches = true, so as to ensure the "cooked" event rate that
149 * clients experience is at least the minimum of event_rate_hz
150 * and the raw device event rate.
151 * frame_time = A regular interval. This provides a virtual frame
152 * interval during which InputConsumer will collect raw events,
153 * resample them and emit a "cooked" event back to us at roughly every
154 * 60th of a second. "cooked" events are both smoothed and
155 * extrapolated/predicted into the future (for tool=finger) giving the
156 * appearance of lower latency. Getting a real frame time from the
157 * graphics logic (which is messy) does not appear to be necessary to
158 * gain significant benefit.
159 */
160
161 auto frame_time = std::chrono::nanoseconds(-1);
162
163 if (event_rate_hz > 0)
164 {
165 auto one_frame = std::chrono::nanoseconds(1000000000ULL / event_rate_hz);
166 std::chrono::nanoseconds const
167 now = android_clock(SYSTEM_TIME_MONOTONIC);
168 frame_time = (now / one_frame) * one_frame;
169 }
170
171 auto result = input_consumer->consume(&event_factory,138 auto result = input_consumer->consume(&event_factory,
172 true,139 true,
173 frame_time,140 frame_time,
@@ -197,45 +164,6 @@
197 // So, we ensure we'll appear dispatchable by pushing an event to the wakeup pipe.164 // So, we ensure we'll appear dispatchable by pushing an event to the wakeup pipe.
198 wake();165 wake();
199 }166 }
200 else if (input_consumer->hasPendingBatch() && event_rate_hz > 0)
201 {
202 using namespace std::chrono;
203 // If we batch according to a fixed event rate - we wait until the next "frame" occurs.
204 auto one_frame = nanoseconds(1000000000ULL / event_rate_hz);
205 auto now = android_clock(SYSTEM_TIME_MONOTONIC);
206 auto next_frame = frame_time + one_frame;
207
208 if (next_frame <= now)
209 {
210 wake();
211 }
212 else
213 {
214 auto full_sec = duration_cast<duration<long>>(next_frame);
215 auto nano_sec = duration_cast<duration<long,std::nano>>(next_frame - full_sec);
216 struct itimerspec const frame_timeout = {
217 { 0, 0 },
218 { full_sec.count(), nano_sec.count()}
219 };
220 if (timerfd_settime(timer_fd, TFD_TIMER_ABSTIME, &frame_timeout, NULL) < 0)
221 {
222 BOOST_THROW_EXCEPTION((std::system_error{errno,
223 std::system_category(),
224 "Failed to arm timer"}));
225 }
226 }
227 }
228}
229
230void mircva::InputReceiver::consume_wake_notification(mir::Fd const& fd)
231{
232 uint64_t dummy;
233 if (read(fd, &dummy, sizeof(dummy)) != sizeof(dummy))
234 {
235 BOOST_THROW_EXCEPTION((std::system_error{errno,
236 std::system_category(),
237 "Failed to consume notification"}));
238 }
239}167}
240168
241void mircva::InputReceiver::wake()169void mircva::InputReceiver::wake()
242170
=== modified file 'src/client/input/android/android_input_receiver.h'
--- src/client/input/android/android_input_receiver.h 2016-01-29 08:18:22 +0000
+++ src/client/input/android/android_input_receiver.h 2017-01-16 08:35:54 +0000
@@ -56,18 +56,14 @@
56class InputReceiver : public dispatch::Dispatchable56class InputReceiver : public dispatch::Dispatchable
57{57{
58public:58public:
59 typedef std::function<std::chrono::nanoseconds(int)> AndroidClock;
60
61 InputReceiver(droidinput::sp<droidinput::InputChannel> const& input_channel,59 InputReceiver(droidinput::sp<droidinput::InputChannel> const& input_channel,
62 std::shared_ptr<XKBMapper> const& keymapper,60 std::shared_ptr<XKBMapper> const& keymapper,
63 std::function<void(MirEvent*)> const& event_handling_callback,61 std::function<void(MirEvent*)> const& event_handling_callback,
64 std::shared_ptr<InputReceiverReport> const& report,62 std::shared_ptr<InputReceiverReport> const& report);
65 AndroidClock clock = systemTime);
66 InputReceiver(int fd,63 InputReceiver(int fd,
67 std::shared_ptr<XKBMapper> const& keymapper,64 std::shared_ptr<XKBMapper> const& keymapper,
68 std::function<void(MirEvent*)> const& event_handling_callback,65 std::function<void(MirEvent*)> const& event_handling_callback,
69 std::shared_ptr<InputReceiverReport> const& report,66 std::shared_ptr<InputReceiverReport> const& report);
70 AndroidClock clock = systemTime);
7167
72 virtual ~InputReceiver();68 virtual ~InputReceiver();
7369
@@ -81,7 +77,6 @@
8177
82private:78private:
83 dispatch::MultiplexingDispatchable dispatcher;79 dispatch::MultiplexingDispatchable dispatcher;
84 Fd const timer_fd;
85 Fd const wake_fd;80 Fd const wake_fd;
8681
87 droidinput::sp<droidinput::InputChannel> input_channel;82 droidinput::sp<droidinput::InputChannel> input_channel;
@@ -92,11 +87,7 @@
92 std::shared_ptr<droidinput::InputConsumer> input_consumer;87 std::shared_ptr<droidinput::InputConsumer> input_consumer;
93 droidinput::PreallocatedInputEventFactory event_factory;88 droidinput::PreallocatedInputEventFactory event_factory;
9489
95 AndroidClock const android_clock;90 void woke();
96 int event_rate_hz;
97
98 void process_and_maybe_send_event();
99 static void consume_wake_notification(mir::Fd const& fd);
100 void wake();91 void wake();
101};92};
10293
10394
=== modified file 'tests/acceptance-tests/test_client_input.cpp'
--- tests/acceptance-tests/test_client_input.cpp 2017-01-16 04:43:36 +0000
+++ tests/acceptance-tests/test_client_input.cpp 2017-01-16 08:35:54 +0000
@@ -330,8 +330,6 @@
330330
331TEST_F(TestClientInput, clients_receive_relative_pointer_events)331TEST_F(TestClientInput, clients_receive_relative_pointer_events)
332{332{
333 mtf::TemporaryEnvironmentValue disable_batching("MIR_CLIENT_INPUT_RATE", "0");
334
335 positions[first] = geom::Rectangle{{0,0}, {surface_width, surface_height}};333 positions[first] = geom::Rectangle{{0,0}, {surface_width, surface_height}};
336 Client first_client(new_connection(), first);334 Client first_client(new_connection(), first);
337335
@@ -648,68 +646,6 @@
648 first_client.all_events_received.wait_for(2s);646 first_client.all_events_received.wait_for(2s);
649}647}
650648
651TEST_F(TestClientInput, receives_one_touch_event_per_frame)
652{
653 positions[first] = screen_geometry;
654 Client first_client(new_connection(), first);
655
656 int const frame_rate = 60;
657 int const input_rate = 500;
658 int const nframes = 100;
659 int const nframes_error = 80;
660 int const inputs_per_frame = input_rate / frame_rate;
661 int const ninputs = nframes * inputs_per_frame;
662 auto const frame_time = 1000ms / frame_rate;
663 auto const input_interval = std::chrono::duration<double>(1s) / input_rate;
664
665 int received_input_events = 0;
666
667 EXPECT_CALL(first_client, handle_input(_))
668 .Times(Between(nframes-nframes_error, nframes+nframes_error))
669 .WillRepeatedly(InvokeWithoutArgs(
670 [&]()
671 {
672 ++received_input_events;
673 if (received_input_events >= nframes-nframes_error)
674 first_client.all_events_received.raise();
675 }));
676
677 fake_touch_screen->emit_event(mis::a_touch_event()
678 .at_position({0,0}));
679
680 ASSERT_THAT(input_rate, Ge(2 * frame_rate));
681 ASSERT_THAT(ninputs, Gt(2 * nframes));
682
683 fake_touch_screen->emit_touch_sequence(
684 [this](int i)
685 {
686 auto const x = i;
687 auto const y = 2*i;
688 return mis::a_touch_event()
689 .with_action(mis::TouchParameters::Action::Move)
690 .at_position({x,y});
691 },
692 ninputs,
693 input_interval
694 );
695
696 // The main thing we're testing for is that too many events don't arrive
697 // so we wait a little to check the cooked event stream has stopped:
698 std::this_thread::sleep_for(200 * frame_time);
699
700 // Wait for the expected minimum number of events (should be quick but
701 // some CI runs are actually incredibly slow to finish)
702 ASSERT_TRUE(first_client.all_events_received.wait_for(120s));
703
704 // Remove reference to local received_input_events
705 Mock::VerifyAndClearExpectations(&first_client);
706
707 float const client_input_events_per_frame =
708 (float)received_input_events / nframes;
709 EXPECT_THAT(client_input_events_per_frame, Gt(0.0f));
710 EXPECT_THAT(client_input_events_per_frame, Lt(2.0f));
711}
712
713TEST_F(TestClientInput, send_mir_input_events_through_surface)649TEST_F(TestClientInput, send_mir_input_events_through_surface)
714{650{
715 Client first_client(new_connection(), first);651 Client first_client(new_connection(), first);
716652
=== modified file 'tests/acceptance-tests/test_confined_pointer.cpp'
--- tests/acceptance-tests/test_confined_pointer.cpp 2017-01-12 03:18:54 +0000
+++ tests/acceptance-tests/test_confined_pointer.cpp 2017-01-16 08:35:54 +0000
@@ -206,7 +206,6 @@
206 std::string first{"first"};206 std::string first{"first"};
207 std::string second{"second"};207 std::string second{"second"};
208 mtf::ClientPositions positions;208 mtf::ClientPositions positions;
209 mtf::TemporaryEnvironmentValue disable_batching{"MIR_CLIENT_INPUT_RATE", "0"};
210};209};
211210
212TEST_F(PointerConfinement, test_we_hit_pointer_confined_boundary)211TEST_F(PointerConfinement, test_we_hit_pointer_confined_boundary)
213212
=== modified file 'tests/unit-tests/client/input/test_android_input_receiver.cpp'
--- tests/unit-tests/client/input/test_android_input_receiver.cpp 2016-11-11 06:59:42 +0000
+++ tests/unit-tests/client/input/test_android_input_receiver.cpp 2017-01-16 08:35:54 +0000
@@ -36,6 +36,7 @@
36#include <memory>36#include <memory>
37#include <system_error>37#include <system_error>
38#include <boost/throw_exception.hpp>38#include <boost/throw_exception.hpp>
39#include <atomic>
3940
40namespace mircv = mir::input::receiver;41namespace mircv = mir::input::receiver;
41namespace mircva = mircv::android;42namespace mircva = mircv::android;
@@ -193,7 +194,7 @@
193 EXPECT_TRUE(producer.must_receive_handled_signal());194 EXPECT_TRUE(producer.must_receive_handled_signal());
194}195}
195196
196TEST_F(AndroidInputReceiverSetup, receiver_consumes_batched_motion_events)197TEST_F(AndroidInputReceiverSetup, receiver_consumes_all_motion_events)
197{198{
198 mircva::InputReceiver receiver{channel.client_fd(),199 mircva::InputReceiver receiver{channel.client_fd(),
199 std::make_shared<mircv::XKBMapper>(),200 std::make_shared<mircv::XKBMapper>(),
@@ -203,14 +204,18 @@
203 TestingInputProducer producer(channel.server_fd());204 TestingInputProducer producer(channel.server_fd());
204205
205 // Produce 3 motion events before client handles any.206 // Produce 3 motion events before client handles any.
206 producer.produce_a_pointer_event(0, 0, std::chrono::nanoseconds(0));207 int const nevents = 3;
207 producer.produce_a_pointer_event(0, 0, std::chrono::nanoseconds(0));208 for (int i = 0; i < nevents; ++i)
208 producer.produce_a_pointer_event(0, 0, std::chrono::nanoseconds(0));209 producer.produce_a_pointer_event(0, 0, std::chrono::nanoseconds(0));
209210
210 flush_channels();211 flush_channels();
211212
212 EXPECT_TRUE(mt::fd_becomes_readable(receiver.watch_fd(), next_event_timeout));213 for (int j = 0; j < nevents; ++j)
213 receiver.dispatch(md::FdEvent::readable);214 {
215 EXPECT_TRUE(mt::fd_becomes_readable(receiver.watch_fd(),
216 next_event_timeout));
217 receiver.dispatch(md::FdEvent::readable);
218 }
214219
215 // Now there should be no events220 // Now there should be no events
216 EXPECT_FALSE(mt::fd_is_readable(receiver.watch_fd()));221 EXPECT_FALSE(mt::fd_is_readable(receiver.watch_fd()));
@@ -218,50 +223,33 @@
218223
219TEST_F(AndroidInputReceiverSetup, slow_raw_input_doesnt_cause_frameskipping)224TEST_F(AndroidInputReceiverSetup, slow_raw_input_doesnt_cause_frameskipping)
220{ // Regression test for LP: #1372300225{ // Regression test for LP: #1372300
221 using namespace testing;
222 using namespace std::chrono;226 using namespace std::chrono;
223 using namespace std::literals::chrono_literals;227 using namespace std::literals::chrono_literals;
224228
225 auto t = 0ns;229 std::atomic_int handler_called{0};
226
227 std::unique_ptr<MirEvent> ev;
228 bool handler_called{false};
229230
230 mircva::InputReceiver receiver{channel.client_fd(),231 mircva::InputReceiver receiver{channel.client_fd(),
231 std::make_shared<mircv::XKBMapper>(),232 std::make_shared<mircv::XKBMapper>(),
232 [&ev, &handler_called](MirEvent* event)233 [&handler_called](MirEvent*)
233 {234 {
234 ev.reset(new MirEvent(*event));235 ++handler_called;
235 handler_called = true;
236 },236 },
237 std::make_shared<mircv::NullInputReceiverReport>(),237 std::make_shared<mircv::NullInputReceiverReport>()};
238 [&t](int)
239 {
240 return t;
241 }};
242 TestingInputProducer producer(channel.server_fd());238 TestingInputProducer producer(channel.server_fd());
243239
244 nanoseconds const one_frame = duration_cast<nanoseconds>(1s) / 59;240 nanoseconds const one_frame = duration_cast<nanoseconds>(1s) / 59;
245241
246 producer.produce_a_pointer_event(123, 456, t);242 producer.produce_a_pointer_event(123, 456, 0ns);
247 producer.produce_a_key_event();243 producer.produce_a_pointer_event(234, 567, one_frame);
248 flush_channels();244 flush_channels();
249245
250 // Key events don't get resampled. Will be reported first.
251 EXPECT_TRUE(mt::fd_becomes_readable(receiver.watch_fd(), next_event_timeout));246 EXPECT_TRUE(mt::fd_becomes_readable(receiver.watch_fd(), next_event_timeout));
252 receiver.dispatch(md::FdEvent::readable);247 receiver.dispatch(md::FdEvent::readable);
253 EXPECT_TRUE(handler_called);248 EXPECT_EQ(1, handler_called);
254 ASSERT_EQ(mir_input_event_type_key, ev->to_input()->input_type());
255249
256 t += 2 * one_frame; // Account for the slower 59Hz event rate
257 // The motion is still too new. Won't be reported yet, but is batched.
258 // and since batching is locked to the event rate android_input_receiver
259 // will wake up in one frame..
260 EXPECT_TRUE(mt::fd_becomes_readable(receiver.watch_fd(), 2 * one_frame));250 EXPECT_TRUE(mt::fd_becomes_readable(receiver.watch_fd(), 2 * one_frame));
261 receiver.dispatch(md::FdEvent::readable);251 receiver.dispatch(md::FdEvent::readable);
262252 EXPECT_EQ(2, handler_called);
263 EXPECT_TRUE(handler_called);
264 EXPECT_EQ(mir_input_event_type_touch, ev->to_input()->input_type());
265}253}
266254
267TEST_F(AndroidInputReceiverSetup, finish_signalled_after_handler)255TEST_F(AndroidInputReceiverSetup, finish_signalled_after_handler)
@@ -287,62 +275,6 @@
287 EXPECT_TRUE(producer.must_receive_handled_signal());275 EXPECT_TRUE(producer.must_receive_handled_signal());
288}276}
289277
290TEST_F(AndroidInputReceiverSetup, rendering_does_not_lag_behind_input)
291{
292 using namespace testing;
293 using namespace std::chrono;
294 using namespace std::literals::chrono_literals;
295
296 std::chrono::nanoseconds t;
297
298 int frames_triggered = 0;
299
300 mircva::InputReceiver receiver{channel.client_fd(),
301 std::make_shared<mircv::XKBMapper>(),
302 [&frames_triggered](MirEvent*)
303 {
304 ++frames_triggered;
305 },
306 std::make_shared<mircv::NullInputReceiverReport>(),
307 [&t](int)
308 {
309 return t;
310 }};
311 TestingInputProducer producer(channel.server_fd());
312
313 std::chrono::nanoseconds const device_sample_interval = duration_cast<nanoseconds>(1s) / 250;
314 std::chrono::nanoseconds const frame_interval = duration_cast<nanoseconds>(1s) / 60;
315 std::chrono::nanoseconds const gesture_duration = 1s;
316
317 std::chrono::nanoseconds last_produced = 0ns;
318
319 for (t = 0ns; t < gesture_duration; t += 1ms)
320 {
321 if (!t.count() || t >= (last_produced + device_sample_interval))
322 {
323 last_produced = t;
324 float a = t.count() * M_PI / 1000000.0f;
325 float x = 500.0f * sinf(a);
326 float y = 1000.0f * cosf(a);
327 producer.produce_a_pointer_event(x, y, t);
328 flush_channels();
329 }
330
331 if (mt::fd_is_readable(receiver.watch_fd()))
332 {
333 receiver.dispatch(md::FdEvent::readable);
334 }
335 }
336
337 // If the rendering time resulting from the gesture is longer than the
338 // gesture itself then that's laggy...
339 std::chrono::nanoseconds render_duration = frame_interval * frames_triggered;
340 EXPECT_THAT(render_duration, Le(gesture_duration));
341
342 int average_lag_milliseconds = (render_duration - gesture_duration) / (frames_triggered * 1ms);
343 EXPECT_THAT(average_lag_milliseconds, Le(1));
344}
345
346TEST_F(AndroidInputReceiverSetup, input_comes_in_phase_with_rendering)278TEST_F(AndroidInputReceiverSetup, input_comes_in_phase_with_rendering)
347{279{
348 using namespace testing;280 using namespace testing;

Subscribers

People subscribed via source and target branches