Mir

Comment 0 for bug 1515515

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote : Monotonic clocks behave weird after a wakeup

Calling clock_gettime behaves strangely with CLOCK_MONOTONIC CLOCK_MONOTONIC_RAW or CLOCK_MONOTONIC_BOOTTIME depending on which process you are in. Whithin usc and unity8 we get a consistent stream of monotonic time updates. independet of suspends/wakeups. Within a process like unity8-dash it seems to work until after the first suspend then the current time of CLOCK_REALTIME is returned.

This can be observed through input receiver traces in mir/unity8 and unity8-dash.

Steps to reproduce - take the current released version of mir :
http://bazaar.launchpad.net/~mir-team/mir/0.17/view/head:/3rd_party/android-input/android/frameworks/native/libs/utils/Timers.cpp
Modify
   // we don't support the clocks here.
    struct timeval t;
    t.tv_sec = t.tv_usec = 0;
    gettimeofday(&t, NULL);
    return std::chrono::nanoseconds(t.tv_sec)*1000000000LL + std::chrono::nanoseconds(t.tv_usec)*1000LL;

into:

    struct timespec t;
    t.tv_sec = t.tv_nsec = 0;
    clock_gettime(CLOCK_MONOTONIC, &t);
    return std::chrono::nanoseconds(t.tv_sec*1000000000LL) +
        std::chrono::nanoseconds(t.tv_nsec);

Then enable mirs input traces in /usr/share/upstart/sessions/unity8-dash.conf
i.e. add:
   export MIR_CLIENT_INPUT_RECEIVER_REPORT=log

and for comparison you could do something similar in /usr/share/upstart/sessions/unity8.conf

You should get traces like:
[1447315263.459656] <DEBUG> input-receiver: Received event:touch_event(when=71864404480 (-88787157.149558 ms ago), from=0, touch = {{id=0, action=change, tool=finger, x=328.545, y=504.624, pressure=0.275735, major=7.98521, minor=0, size=0}, modifiers=1)

The timestamp at the beginning of the trace is gettimeofday(), but look at the "when=" part - this is the 'current time' androids input resampling believes it is.

Then after the wakeup you should see:
[1447315273.639723] <DEBUG> input-receiver: Received event:touch_event(when=1447404060779907704 (-88787140.-356826 ms ago), from=0, touch = {{id=0, action=down, tool=finger, x=416.229, y=593.339, pressure=0.291054, major=11.9778, minor=0, size=0}, modifiers=1)

when= is now closer to gettimeofday..