Real-time feedback without lag

What is the recommended way to analyze PencilKit strokes in near real time without interfering with Apple Pencil latency? Should analysis occur only after canvasViewDrawingDidChange, after each stroke ends, or through lower-level touch handling?

Answered by Apple Developer Support in 891216022

You can use the canvasViewDrawingDidChange delegate method to analyse strokes as they're added to the PKCanvasView drawing.

Please note that the PKDrawing is sendable, so it's fine to pass it off to a background thread to avoid blocking the main thread while you process it.

Unfortunately there's no way to access the live/current stroke in PKCanvasView, so if you want even more fine grained feedback, you could add a simultaneous gesture that recognizes at the same time as our drawingGestureRecognizer. Just try to block the main thread as little as possible, so again do your processing on the live stroke data on a background thread.

You can use the canvasViewDrawingDidChange delegate method to analyse strokes as they're added to the PKCanvasView drawing.

Please note that the PKDrawing is sendable, so it's fine to pass it off to a background thread to avoid blocking the main thread while you process it.

Unfortunately there's no way to access the live/current stroke in PKCanvasView, so if you want even more fine grained feedback, you could add a simultaneous gesture that recognizes at the same time as our drawingGestureRecognizer. Just try to block the main thread as little as possible, so again do your processing on the live stroke data on a background thread.

Real-time feedback without lag
 
 
Q