[Questions at the bottom]
I am trying to reimplement a UIScrollView for various reasons and noticed that the first touch locations captured via touchesBegan and touchesMoved have one erratic jump, usually among the first ~5 events.
This outlier will currently cause my implementation to jump the scroll content for a few pixels before smooth tracking picks up.
What that means is that even if the finger is being moved at constant speed, the distances between the touch events are not (near)constant (=first touchesMoved event is delayed and thus does not smoothly correspond to the finger movement).
It does not happen if the finger rests for a few event cycles. Furthermore, when testing on an iPad and using a pencil without coalesced/predictive touches the experience is smooth and no jumping occurs
Based on this I guess that the device needs a short amount of time to warm up before full 60 hz touch tracking is available. Because the pencil will, even without specific pencil code like coalesced/predictive, not show any signs of jumping for the first few touches it sounds reasonable to assume that the device warms up based on nearness of the tip to the screen (I remember this from some Apple presentation), coupled with the generally much higher sampling rate
Lastly, using the simulator and trackpad drag to test this shows no jumping at all, no matter the speed, supporting the wake up phase thesis for real iOS devices with finger input.
I could not find anything about this online, most likely because I have no idea what to search for.
Tested on iPhone X and iPad pro 10.5 with and without pencil
A good example project by Apple is here, where a simple drawing layer can be used with or without pencil.
The screenshot shows three example lines with a finger on iPad at various speeds from left to right and fastest on top. Line segments are individual touch measurements, light grey is used to show coalesced events (which would happen more often with the pencil). It is obvious, that the first touchesMoved event triggers later than following events, causing a jump in tracked distance.
I have zero reason to believe that this is an implementation problem as I tested it with multiple small examples. Resting the finger first as described above will not cause this, meaning that it also shouldn't be a problem with the finger itself (initial resistance/stickiness etc)
When looking at the Apple UIScrollView there is no jumping. The experience is smooth no matter how the interaction is started (resting vs immediate action, fast vs slow movement). This leads me to the following questions:
Is there some implementation detail that I am missing? Maybe Apple is using some internal setting? Seems unlikely tbh but who knows
Is Apple using some short lived animation to hide this initial gap in measurements? I wanted to look at this with the phones 240fps slomo but haven't done so yet. If they animate, any idea how they do it? Some mechanism that translates the view faster than the touchesMoved delta for ~X events up to the point where it can catch up with minimal visual distraction? No idea, sounds complicated
Any other idea how I can translate an element based on touchesMoved events nice and smoothly without the single initial jump at low speeds?