Skip to content

Fix pointer id/coordinate mismatch in Android platform view multi-touch - #191631

Merged
auto-submit[bot] merged 4 commits into
flutter:masterfrom
kaluli123123:fix-platform-view-multitouch-pointer-id-191105
Sep 30, 2026
Merged

auto-submit[bot] merged 4 commits into
flutter:masterfrom
kaluli123123:fix-platform-view-multitouch-pointer-id-191105

Conversation

@kaluli123123

Copy link
Copy Markdown
Contributor

Summary

  • _AndroidMotionEventConverter.toAndroidMotionEvent built its pointer list from pointerPositions.keys.toList(), which iterates in Flutter pointer insertion order.
  • The engine (PlatformViewsController.toMotionEvent / translateMotionEvent, Java) pairs the coordinates sent from the framework with the original MotionEvent's pointers by array position, on the assumption that this order matches ascending Android pointer id.
  • Those two orders agree until a released Android pointer id gets recycled by a new touch-down, at which point insertion order and id order diverge — corrupting the derived action index and pairing each pointer with the wrong coordinates (two fingers can end up reporting identical/reflected coordinates).
  • Fix: sort the pointer list by AndroidPointerProperties.id (the Android pointer id) before deriving the action index and building the pointerProperties/pointerCoords arrays, so both sides agree on what array order means.

Fixes #191105

Test plan

  • Added a regression test in packages/flutter/test/services/platform_views_test.dart that recycles a released Android pointer id and asserts the resulting MotionEvent's pointer order, action index, and coordinates are keyed by Android pointer id, not insertion order.
  • Red/green verified: reverting the fix makes the new test fail with a corrupted action-index value; restoring the fix makes it pass.
  • flutter test packages/flutter/test/services/platform_views_test.dart — 27/27 passing.
  • flutter analyze on the two changed files — no issues.

🤖 Generated with Claude Code

@github-actions github-actions Bot added the framework flutter/packages/flutter repository. See also f: labels. label Aug 25, 2026
@google-cla

google-cla Bot commented Aug 25, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies the AndroidMotionEventConverter to sort pointers by their Android pointer ID, addressing an issue where recycled pointer IDs caused ordering mismatches. A regression test has been added to verify this behavior. Feedback suggests using the null-assertion operator (!) instead of null-safe operators when sorting, as the pointer properties are expected to be non-null, allowing the code to fail fast if this invariant is violated.

Comment thread packages/flutter/lib/src/services/platform_views.dart Outdated
@kaluli123123
kaluli123123 force-pushed the fix-platform-view-multitouch-pointer-id-191105 branch from 6b8f567 to c1283d1 Compare August 25, 2026 03:56
_AndroidMotionEventConverter.toAndroidMotionEvent built the pointer
list from pointerPositions.keys.toList(), which iterates in Flutter
pointer insertion order. The engine's PlatformViewsController pairs
the coordinates sent here with the original MotionEvent's pointers by
array position, assuming ascending Android pointer id order. Once a
released Android pointer id is recycled by a new touch, insertion
order and id order diverge, corrupting the action index and pairing
each pointer with the wrong coordinates.

Sort the pointer list by Android pointer id before building the
action index and motion event arrays so both sides agree on what the
array order means.

Fixes flutter#191105
@kaluli123123
kaluli123123 force-pushed the fix-platform-view-multitouch-pointer-id-191105 branch from c1283d1 to 9ff6910 Compare August 25, 2026 03:58
@Renzo-Olivares
Renzo-Olivares requested review from a team and camsim99 and removed request for a team August 25, 2026 22:34
@camsim99
camsim99 requested review from gmackall and removed request for camsim99 August 31, 2026 18:36
@kaluli123123

Copy link
Copy Markdown
Contributor Author

@gmackall @Piinks @justinmc @mboetger @gaaclarke This PR has been stuck for several weeks and is still blocked. Could any available Flutter maintainer please take a look and help move it to merge? It fixes a pointer id/coordinate mismatch in Android platform-view multi-touch handling. Thank you!

@kaluli123123

Copy link
Copy Markdown
Contributor Author

@gmackall @gaaclarke @mboetger @jtmcdole Could one of the Flutter Android/platform-view maintainers please review and help move this PR to merge if it is ready? The PR has been open since August 25, the code checks and current tree-status are passing, and the existing review thread is resolved. The remaining visible gates are Google testing and Awaiting CICD label. Please take a look, approve if appropriate, and help advance the remaining workflow gates, or point out any blocker.

@gmackall gmackall added the CICD Run CI/CD label Sep 29, 2026
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Sep 29, 2026
@justinmc

Copy link
Copy Markdown
Contributor

Thanks for waiting here, this one is in our queue and will get picked up.

@gmackall gmackall left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks for the fix, sorry for review delay

@gmackall
gmackall requested review from a team and mboetger and removed request for a team September 29, 2026 22:49
@gmackall gmackall added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 30, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Sep 30, 2026
Merged via the queue into flutter:master with commit b9db4f9 Sep 30, 2026
27 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Sep 30, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Oct 1, 2026
…13104)

Manual roll requested by [email protected]

flutter/flutter@d649d2b...e89fd0a

2026-10-01 [email protected] Manual roll ICU from 6ebb40c59477 to 5aa526207171 (2 revisions) (flutter/flutter#193661)
2026-10-01 [email protected] fix(web): hash source maps before rewriting sourceMappingURL with --web-content-hash (flutter/flutter#193614)
2026-10-01 [email protected] [flutter_tools] Bootstrap DeviceManager in ToolDependencies (flutter/flutter#193524)
2026-10-01 [email protected] [wasm] Set flutter_runtime_mode in tools/gn to_gn_wasm_args (flutter/flutter#193407)
2026-10-01 [email protected] Remove remaining `download_jdk` references (flutter/flutter#193562)
2026-10-01 [email protected] Synchronize dart2wasm feature probes in roll script and flutter_bootstrap.js (flutter/flutter#193271)
2026-10-01 [email protected] [web] Unskip web tests that now pass in gestures, services, and widgets (flutter/flutter#193512)
2026-10-01 [email protected] Roll Fuchsia Test Scripts from whZAV1mfT-Rdc0rQ8... to fCNknap4ZI0AMcvIf... (flutter/flutter#193640)
2026-10-01 [email protected] Roll Skia from 0575a37d0619 to f2d68e0b8863 (2 revisions) (flutter/flutter#193621)
2026-10-01 [email protected] perf(widgets): use const <Never>{} in InheritedModelElement and avoid redundant casts in RenderObjectElement.update (flutter/flutter#192913)
2026-10-01 [email protected] [web] Unskip and strengthen missing glyph tofu test on Wimp (flutter/flutter#193426)
2026-10-01 [email protected] [flutter_tools] Fix `flutter drive -d chrome` hanging on web (flutter/flutter#193459)
2026-10-01 [email protected] [web] Fix hang when Chromium cannot bind remote debugging port (flutter/flutter#193461)
2026-10-01 [email protected] [flutter_tools] Bundle data assets from hooks in flutter test (flutter/flutter#193435)
2026-10-01 [email protected] Roll Packages from 0ba9a82 to d5ec6db (11 revisions) (flutter/flutter#193641)
2026-10-01 [email protected] Revert: [flutter_tools] Fix DTD "Stream already subscribed" error and wait for analysis over DTD in widget preview (flutter/flutter#193637)
2026-10-01 [email protected] Roll Skia from 6182a3cf8f98 to 0575a37d0619 (5 revisions) (flutter/flutter#193613)
2026-10-01 [email protected] [flutter_tools] Fix DTD "Stream already subscribed" error and wait for analysis over DTD in widget preview (flutter/flutter#192930)
2026-09-30 [email protected] [Impeller] Sample the render target rect in offscreen advanced blends (flutter/flutter#192988)
2026-09-30 [email protected] Roll Skia from 01524014dff5 to 6182a3cf8f98 (11 revisions) (flutter/flutter#193594)
2026-09-30 [email protected] [web] Use Xvfb -displayfd and clean up Xvfb after Firefox test suites (flutter/flutter#193510)
2026-09-30 [email protected] Fixes bug where sibling node fail to update size (flutter/flutter#191220)
2026-09-30 [email protected] Roll Skia from c7b323126bf0 to 01524014dff5 (3 revisions) (flutter/flutter#193577)
2026-09-30 [email protected] Remove some Undefined Behavior from run_customer_testing_tests.dart. (flutter/flutter#193582)
2026-09-30 [email protected] Fix pointer id/coordinate mismatch in Android platform view multi-touch (flutter/flutter#191631)
2026-09-30 [email protected] Roll Packages from 3c6ce59 to 0ba9a82 (11 revisions) (flutter/flutter#193578)
2026-09-30 [email protected] Fix unresolved doc comment references in dev/ tooling (flutter/flutter#193501)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Android] Platform view multi-touch: pointer ids and coordinates are mis-paired when a released Android pointer id is reused

4 participants