Repository navigation
Description
Steps to Reproduce
- Execute
flutter runin the code sample's example folder, and two native androidButtons will be shown. - Tap down and hold "Button1" with one finger.
- Tap down and hold "Button2" with another finger.
- Move the first finger away from "Button1".
- Tap down and hold "Button1".
- Move the finger away from "Button1" again.
Expected results:
The first 4 steps behave normally. However, step 5 should make "Button1" get pressed, and step 6 should make "Button1" released.
Actual results:
On step 5, when my finger is tapping on "Button1", "Button1" is not tapped! And on step 6, when my finger moves away from "Button1", "Button2" is released! As shown clearly in the gif below:
So, I know this may be related to the fact that platform views only use OneSequenceGestureRecognizers as they support gesture arena teams. However, I believe the above steps can certainly be considered as a single sequence.
Code sample
A minimal example can be found in this example plugin: https://github.com/orenwang/flutter_platform_view_multi_tap_test
Logs
[ +7 ms] Connected to _flutterView/0x71e4392a20.
[ +3 ms] Flutter run key commands.
[ +1 ms] r Hot reload. 🔥🔥🔥
[ +1 ms] R Hot restart.
[ ] h List all available interactive commands.
[ ] d Detach (terminate "flutter run" but leave application running).
[ ] c Clear the screen
[ ] q Quit (terminate the application on the device).
[ ] 💪 Running with sound null safety 💪
[ ] An Observatory debugger and profiler on PAR AL00 is available at:
http://127.0.0.1:60763/D6HrEoR8obg=/
[ +208 ms] D/TextView(23124): get Display Panel Type is : 0
[ +589 ms] The Flutter DevTools debugger and profiler on PAR AL00 is available
at:
http://127.0.0.1:9101?uri=http://127.0.0.1:60763/D6HrEoR8obg=/
[ +1 ms] W/ap_test_exampl(23124): Accessing hidden method
Landroid/media/ImageReader;->newInstance(IIIIJ)Landroid/media/ImageReader; (dark
greylist, linking)
[ +2 ms] W/libEGL (23124): EGLNativeWindowType 0x71c68a9010 disconnect failed
[ ] D/mali_winsys(23124): EGLint new_window_surface(egl_winsys_display *,
void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
[ +24 ms] D/mali_winsys(23124): EGLint new_window_surface(egl_winsys_display *,
void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
[ +34 ms] E/ion (23124): ioctl c0044901 failed with code -1: Invalid
argument
[ +105 ms] I/ViewRootImpl(23124): jank_removeInvalidNode jank list is null
[+1751 ms] W/Settings(23124): Setting device_provisioned has moved from
android.provider.Settings.Secure to android.provider.Settings.Global.
[ +1 ms] V/HiTouch_HiTouchSensor(23124): User setup is finished.
[ +487 ms] D/AwareBitmapCacher(23124): handleInit switch not opened pid=23124
[ +757 ms] W/HiTouch_PressGestureDetector(23124): HiTouch Miss: Too large time
interval(TwoFingers), 1248
[ +289 ms] I/ap_test_exampl(23124): Starting profile saver IsSaveProfileNow end.
[ +893 ms] W/HiTouch_PressGestureDetector(23124): Touch pointer move a lot. The
moving distance of X is:305.71692, limit is:60The moving distance of Y
is:15.993164, limit is:60
[+1221 ms] W/HiTouch_PressGestureDetector(23124): HiTouch Miss: Too large time
interval(TwoFingers), 3637
[+3253 ms] W/InputMethodManager(23124): startInputReason = 8
[ +345 ms] D/ZrHung.AppEyeUiProbe(23124): stop checker.
[ +223 ms] D/ViewRootImpl[MainActivity](23124): surface should not be released
[ +29 ms] D/ZrHung.AppEyeUiProbe(23124): Current Activity:false
[ ] D/ZrHung.AppEyeUiProbe(23124): not watching, wait.
[ +251 ms] W/libEGL (23124): EGLNativeWindowType 0x71c68a8010 disconnect failed
[ +30 ms] V/ActivityThread(23124): Handle window ActivityRecord{836d7fd
token=android.os.BinderProxy@4d67819
{com.example.flutter_platform_view_multi_tap_test_example/com.example.flutter_pl
atform_view_multi_tap_test_example.MainActivity}} visibility: false
[+4440 ms] D/ZrHung.AppEyeUiProbe(23124): notify runnable to start.
[ +1 ms] D/ZrHung.AppEyeUiProbe(23124): restart watching
[ +9 ms] D/mali_winsys(23124): EGLint new_window_surface(egl_winsys_display *,
void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
[ +19 ms] E/BpSurfaceComposerClient(23124): Failed to transact (-1)
[ +2 ms] E/BpSurfaceComposerClient(23124): Failed to transact (-1)
[ +76 ms] I/ViewRootImpl(23124): jank_removeInvalidNode all the node in jank
list is out of time
[ +43 ms] W/InputMethodManager(23124): startInputReason = 1
[+1388 ms] DevFS: Deleting filesystem on the device
(file:///data/user/0/com.example.flutter_platform_view_multi_tap_test_example/co
de_cache/exampleREIRUL/example/)
[ +20 ms] DevFS: Deleted filesystem on the device
(file:///data/user/0/com.example.flutter_platform_view_multi_tap_test_example/co
de_cache/exampleREIRUL/example/)
[ +10 ms] executing: /Users/orenwang/Library/Android/sdk/platform-tools/adb -s
FJH7N18802004159 shell am force-stop
com.example.flutter_platform_view_multi_tap_test_example
[ +397 ms] Application finished.
[ +25 ms] "flutter run" took 61,431ms.
[ +36 ms] Service protocol connection closed.
[ +90 ms] ensureAnalyticsSent: 118ms
[ +1 ms] Running shutdown hooks
[ ] Shutdown hooks complete
[ ] exiting with code 0
Analyzing flutter_platform_view_multi_tap_test...
No issues found! (ran in 2.2s)
[✓] Flutter (Channel stable, 2.8.1, on macOS 12.0.1 21A559 darwin-arm, locale
en-CN)
• Flutter version 2.8.1 at /Users/orenwang/Downloads/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 77d935af4d (4 weeks ago), 2021-12-16 08:37:33 -0800
• Engine revision 890a5fca2e
• Dart version 2.15.1
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/orenwang/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• ANDROID_HOME = /Users/orenwang/Library/Android/sdk
• Java binary at: /Users/orenwang/Downloads/Android
Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2020.3)
• Android Studio at /Users/orenwang/Downloads/Android Studio
Preview.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
[✓] Android Studio (version 2020.3)
• Android Studio at /Users/orenwang/Downloads/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
[✓] VS Code (version 1.63.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.32.0
[✓] Connected device (3 available)
• PAR AL00 (mobile) • FJH7N18802004159 • android-arm64 • Android 9
(API 28)
• sdk gphone arm64 (mobile) • emulator-5554 • android-arm64 • Android 11
(API 30) (emulator)
• Chrome (web) • chrome • web-javascript • Google
Chrome 97.0.4692.71
• No issues found!

Activity
[-]Incorrect gesture received on platform views.[/-][+]Incorrect gesture received on native side via platform views.[/+]danagbemava-nc commentedon Jan 14, 2022
Issue is reproducible with sample found in https://github.com/orenwang/flutter_platform_view_multi_tap_test.
I'm not entirely familiar with
PlatformViewsand how they handle gestures, so I'm leaving this to the team for further input.flutter doctor -v
orenwang commentedon Jan 16, 2022
A potential fix (orenwang/flutter_platform_view_multi_tap_test@cd4f624) without changing Flutter framework code is here on the experiment branch of the code sample.
Note that I sorted the pointers by their pointerId to resolve the problem. As far as I understand, the order should not matter as long as we set pointerId, pointerIndex, and actionIndex values correctly. However, these values seem to be messed up. Also, apps made in native Android seem to always align them (meaning "the first finger" gets back with its
pointerIndexandpointerIdboth being 0 as of the simple example in the original issue).Running the experiment branch, it behaves normally now with multi tap:

I think a better fix would be changing MotionEventTracker which somehow ignores the
event.actionvalue passed here sometimes.cc-setwo commentedon Feb 9, 2022
Hello,
Looks like the issue exists on iOS with UiKitView.
ios_flutter_multi_touch_issue.mov
I have used the code provided in example: https://docs.flutter.dev/development/platform-integration/platform-views
But I have changed the part with label to display 2 buttons.
Here is my createNativeView code:
And the extension for UIButton:
flutter doctor -v
[✓] Flutter (Channel stable, 2.10.0, on macOS 12.2 21D49 darwin-x64, locale ru-RU) • Flutter version 2.10.0 at /Users/admin/Downloads/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 5f105a6 (8 days ago), 2022-02-01 14:15:42 -0800 • Engine revision 776efd2 • Dart version 2.16.0 • DevTools version 2.9.2[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
• Android SDK at /Users/admin/Library/Android/sdk
• Platform android-32, build-tools 32.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.2
[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
[✓] Connected device (2 available)
• SM A315F (mobile) • RF8N922ANWA • android-arm64 • Android 11 (API 30)
• iPhone (mobile) • 00008020-00140CD926D2002E • ios • iOS 13.3 17C54
! Error: iPhone is busy: Preparing the watch for development via iPhone. Xcode will continue when iPhone is finished. (code -10)
[✓] HTTP Host Availability
• All required HTTP hosts are available
Also, I have tried different FlutterPlatformViewGestureRecognizersBlockingPolicy, but the result unfortunately is the same.
Am I missing something?
@orenwang I know that your work around is for Android only, but maybe you may give some hint for iOS also? 🙏
orenwang commentedon Feb 10, 2022
@cc-setwo Looks like your problem on iOS is a bit different from this issue.
In your video, your steps are:
Tap & Hold 1-->Tap & Hold 2-->Leave 2...While this issue is about:
Tap & Hold 1-->Tap & Hold 2-->Leave 1...So, if you have an android device, you will find there is no problem in my sample code in this issue.
3 remaining items
Linspirit98 commentedon Jul 31, 2022
Hi @wns25678 can you recall what you changed in the engine? because I cannot run flutter app using your local engine. So i am think fork the flutter engine and try changing it myself. Also, do you remember the flutter version? I am using 2.10.2 for flutter sdk (2.16.1 for dart sdk). Could it be that the version is too low? Thank you in advance!
guoguoguilai commentedon Sep 12, 2022
Any update on this issue?
gray-seven commentedon Nov 30, 2022
Flutter team please fix this issue
wanglairo commentedon Apr 27, 2023
https://zhuanlan.zhihu.com/p/429345027
看的这篇文章,解决了多点触控问题,屏蔽掉flutter侧的手势,用的原生手势
iguangyu commentedon Jul 28, 2023
大佬,请问具体修改后的源码还在吗
mcathena commentedon Aug 28, 2023
Any update on this issue?
ddrccw commentedon Jun 5, 2024
On iOS, when debugging engine codes, I find that ForwardingGestureRecognizer is still working during the touch end phase as _currentTouchPointersCount is greater than 0 when 1 of 2 fingers ends, so touches are not delivered to the button on platform view
I try to add some codes below, it seems that it can fix this issue on iOS
tested on flutter commit 2f708eb (flutter-3.13-candidate.0) and engine commit a794cf2681
adrien-gannerie commentedon Jun 10, 2024
@ddrccw hi, your modifications only are enough for fixe the multi touch issue ?
Thanks.
ddrccw commentedon Jun 11, 2024
In my case, I have a virtual gamepad implemented via platform view that requires to support multi touches. It just works in my app.
I've also tested in the above mentioned demo flutter_platform_view_multi_tap_test.
Maybe it doesn't test enough, so I posted codes here. You could swizzle the method and have a try to check if it works in your case
adrien-gannerie commentedon Jun 12, 2024
Thanks I will try.
kaluli123123 commentedon Aug 25, 2026
This looks like the same root cause as #191105, which is already fixed by an open PR: #191631.
_AndroidMotionEventConverter.toAndroidMotionEventbuilds the pointer array frompointerPositions.keys.toList()(Flutter insertion order), while Android's embedded views expect thearray ordered by Android pointer id. Once a released Android pointer id is recycled by a new touch,
insertion order and id order diverge, so the pointer list and the encoded action index stop matching
what the receiving Android view expects — this matches the "incorrect gesture" symptom described here.
#191631 sorts the pointer list by Android pointer id before building the motion event, which should
fix both issues at once. Might be worth marking this a duplicate of #191105 once that PR lands, or
cross-linking them so reviewers see both repro reports.