Fix Apple Pencil drawing latency by using Listener instead of GestureDetector#753
Draft
Fix Apple Pencil drawing latency by using Listener instead of GestureDetector#753
Conversation
Use Listener widget instead of GestureDetector to eliminate gesture disambiguation delays that cause drawing latency on iPadOS with Apple Pencil. The Listener widget responds immediately to pointer events while GestureDetector waits to determine gesture type. Key changes: - Replace onScaleStart/Update/End with onPointerDown/Move/Up/Cancel - Add multi-touch detection to allow pinch-to-zoom gestures - Maintain tap detection for polygon mode and other modes - Rename _processEraserInput to _processEraserInputAt for clarity This significantly reduces drawing latency on iPadOS with Apple Pencil by bypassing the gesture recognition pipeline. Co-authored-by: hm21 <40503456+hm21@users.noreply.github.com>
- Add _tapDistanceThreshold constant (10.0 logical pixels) for clarity - Move polygon completion check from pointer down to pointer up for tap detection to match original GestureDetector.onTapDown behavior - Add clarifying comment for eraser mode early return Co-authored-by: hm21 <40503456+hm21@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix severe drawing latency with Apple Pencil in iPadOS 26.1
Fix Apple Pencil drawing latency by using Listener instead of GestureDetector
Feb 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Drawing with Apple Pencil on iPadOS 26.1 exhibits severe latency—strokes visibly lag behind the stylus. Root cause:
GestureDetectorwaits ~100ms for gesture disambiguation before firing callbacks.Changes
Replaced
GestureDetectorwithListenerinpaint_canvas.dartfor immediate pointer event handling:onScaleStart/Update/End→onPointerDown/Move/Up/Cancel_activePointerCountto cancel drawing during pinch-to-zoom_tapDistanceThreshold = 10.0) to preserve polygon mode tap behavior_processEraserInput(ScaleUpdateDetails)→_processEraserInputAt(Offset)Multi-touch gestures are detected by counting active pointers; drawing is disabled when
_activePointerCount > 1to allow pinch-to-zoom to pass through.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.