Touch events sometimes "queue" up with multi-touch, a pencil, and a Metal powered view

Originator:twobitbear
Number:rdar://24046919 Date Originated:4/1/2016
Status:Open Resolved:
Product:iOS Product Version:iOS 9.2 13C75
Classification:Serious Bug Reproducible:Always
 
Summary:
If you handle touches with touchesMoved: when a MTKView is displayed, and use multi-touch with a pencil, touches seem to get queued up and delivered much later than when they are recorded. Using the pencil or a finger by itself doesn't reproduce this, but using the pencil and holding (or moving) one or more fingers simultaneously triggers the behavior reasonably often. It doesn't occur every time you do this, but on a dozen or so tries it reliably happens. The queueing gets worse and worse with a continuous pencil touch, so touches get further and further behind real-time until they are multiple seconds behind if you keep drawing. This doesn't seem reproducible if you are not using a Metal powered view (MTKView).

I'm measuring the lag in the TouchLag sample app using the following code in touchesMoved:
let now = NSProcessInfo.processInfo().systemUptime
let lag = touch.timestamp - now

Typical numbers are:
-0.0127476250054315
-0.00874762499006465
-0.0037476250436157
When things go bad numbers look like:
-1.1807324999827

Steps to Reproduce:
1. Open TouchLag app.
2. Install on iPad Pro w/ Pencil
3. Run TouchLag app.
4. Touch with one or more fingers, and then draw with the Pencil.
5. Draw for a while with the Pencil.
6. Remove fingers and Pencil.
7. Repeat steps 4-6 while watching the log.

The app prints the lag as described above.


Expected Results:
Normally the numbers printed in touchesMoved: will be < 0.02
They should always be that small, even with multiple fingers and a Pencil touching and moving.

Actual Results:
Every so often (you may need to try many dozens of times or more), the numbers will start to grow. They'll start out small, and then grow without bound. The longer you draw a continuously in this state the worse the numbers get. The event queue will end up delivering touches 10 seconds or more later than they were recorded. It never happens with a single touch, only with multi-touch. More fingers seem better to reproduce this, but I've seen it frequently with only one finger and the Pencil. Sometimes it's easy to reproduce, and sometimes I try for a while before it occurs. I can reproduce it in my full application more reliably, but I can't figure out why. It's definitely reproducible, if somewhat less often, in the simple application included.


Version:
iOS 9.2 13C75

Notes:


Configuration:
iPad Pro 128GB + Pencil

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!