Skip to content

Conversation

Copy link

Copilot AI commented Feb 3, 2026

Drawing with Apple Pencil on iPadOS 26.1 exhibits severe latency—strokes visibly lag behind the stylus. Root cause: GestureDetector waits ~100ms for gesture disambiguation before firing callbacks.

Changes

Replaced GestureDetector with Listener in paint_canvas.dart for immediate pointer event handling:

  • Pointer event handlers: onScaleStart/Update/EndonPointerDown/Move/Up/Cancel
  • Multi-touch detection: Track _activePointerCount to cancel drawing during pinch-to-zoom
  • Tap detection: Manual threshold check (_tapDistanceThreshold = 10.0) to preserve polygon mode tap behavior
  • Eraser refactor: _processEraserInput(ScaleUpdateDetails)_processEraserInputAt(Offset)
// Before: GestureDetector adds disambiguation delay
GestureDetector(
  onScaleStart: _onScaleStart,
  onScaleUpdate: _onScaleUpdate,
  onScaleEnd: _onScaleEnd,
  // ...
)

// After: Listener responds immediately to pointer events
Listener(
  onPointerDown: _onPointerDown,
  onPointerMove: _onPointerMove,
  onPointerUp: _onPointerUp,
  onPointerCancel: _onPointerCancel,
  // ...
)

Multi-touch gestures are detected by counting active pointers; drawing is disabled when _activePointerCount > 1 to allow pinch-to-zoom to pass through.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug]: iPadOS 26.1 – Apple Pencil: severe drawing latency in editor</issue_title>
<issue_description>### Package Version

11.15.5

Flutter Version

3.38.6

Platforms

iOS

How to reproduce?

Hi Alex,

we’re seeing an issue on iPadOS 26.1 (tested on iPad Pro 1st–3rd gen and the new iPad 7th gen):

When drawing with the Apple Pencil in the image editor, strokes are rendered noticeably delayed—lines “catch up” after the user has already finished.

This causes a laggy, offset experience and makes precise work difficult.

On Android, the behavior is much better / barely noticeable.

Questions:
Are there known causes/workarounds (e.g., pointer events, requestAnimationFrame, coalesced events, pressure/tilt handling, canvas batching)?
Would a screen recording and device/browser details help you reproduce?

Thanks in advance,
Ali

Logs (optional)

Example code (optional)

Device Model (optional)

iPad Pro iOS version 26.1</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 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.

Copilot AI and others added 2 commits February 3, 2026 07:23
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
Copilot AI requested a review from hm21 February 3, 2026 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: iPadOS 26.1 – Apple Pencil: severe drawing latency in editor

2 participants