Input Timing bug

Looking into the implementations of Fuse.Gestures I noticed a bug that might lead to incorrect behaviour.

For example the class Clicker:

void OnPointerPressed(object sender, PointerPressedArgs args)
{
    ...
    _startTime = Time.FrameTime;    ...
}

void OnPointerMoved(object sender, PointerMovedArgs args)
{
    ...
    var deltaTime = Time.FrameTime - _startTime;
    ...
}

Time.FrameTime is not the time the InputEvent occured, it is the time Update is called.
On Android and iOS InputEvents provide a Timestamp which should be used instead.

To show the difference between Timestamp, FrameTime (and Clock.getSeconds) I used this snipped on iOS:

public void OnPointerMoved(object sender, PointerMovedArgs args)
{
    debug_log "Delta TimeStamp: " + ((args.Timestamp - lastTimeStamp) * 1000.0);
    debug_log "Delta FrameTime: " + (Fuse.Time.FrameTime - lastFrameTime);
    debug_log "Delta Clock: " + (Uno.Diagnostics.Clock.GetSeconds() - lastClock);

    ...
}

The table below reveals the differences for a couple of calls to OnPointerMoved

TimeStamp

FrameTime

Clock

0.016626

0.017401

0.015138

0.016558

0.015099

0.019484

0.016703

0.020304

0.018087

0.016885

0.018435

0.018644

0.016473

0

0.001563

0.016682

0.020627

0.020716

0.016843

0.03649

0.035308

0.016445

0.019969

0.017517

0.016694

0

0.00194

0.016675

0.019418

0.013313

0.016572

0.013425

0.016233

0.016688

0.016303

0.017642

Time base problem

An other problem I stumbled over when trying to fix our custom Gesture-System, is the time the different Properties are based on:

TimeStamp - is time since SystemUp

FrameTime - (not sure) since application started? Is updated on Application.Update()

Clock.getSeconds() - is time since an undefined point in time

A way to compare PointerEventArgs.Timestamp with Fuse.Time.FrameTime is needed

Hi!

Clock.GetSeconds() is seconds since epoch

Fuse.Time.FrameTime is the elapsed time in seconds since application started until the previously drawn frame

Fuse.Time.FrameInterval is the elapsed time in seconds between the two last frames

I will look into timestamping of inputevents tomorrow :slight_smile:

Wups sorry I was wrong on the Clock.GetSeconds() part

https://www.fusetools.com/learn/uno/api/uno/diagnostics/clock/getseconds