Repository navigation
Commit b9db4f9
Fix pointer id/coordinate mismatch in Android platform view multi-touch (flutter#191631)
## 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 flutter#191105
## Test plan
- [x] 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.
- [x] Red/green verified: reverting the fix makes the new test fail with
a corrupted action-index value; restoring the fix makes it pass.
- [x] `flutter test
packages/flutter/test/services/platform_views_test.dart` — 27/27
passing.
- [x] `flutter analyze` on the two changed files — no issues.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: vam <[email protected]>
Co-authored-by: Gray Mackall <[email protected]>1 parent 5f6a879 commit b9db4f9
2 files changed
Lines changed: 97 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
627 | 627 | | |
628 | 628 | | |
629 | 629 | | |
630 | | - | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
631 | 640 | | |
632 | 641 | | |
633 | 642 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
496 | 496 | | |
497 | 497 | | |
498 | 498 | | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
499 | 586 | | |
500 | 587 | | |
501 | 588 | | |
| |||
0 commit comments