Skip to content

Incorrect gesture received on native side via platform views. #96640

Open

Description

@orenwang

Steps to Reproduce

  1. Execute flutter run in the code sample's example folder, and two native android Buttons will be shown.
  2. Tap down and hold "Button1" with one finger.
  3. Tap down and hold "Button2" with another finger.
  4. Move the first finger away from "Button1".
  5. Tap down and hold "Button1".
  6. 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:

flutter-platform-view-multi-tap-test

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

  1. changed the title [-]Incorrect gesture received on platform views.[/-] [+]Incorrect gesture received on native side via platform views.[/+] on Jan 14, 2022
  2. danagbemava-nc commented on Jan 14, 2022

    @danagbemava-nc
    Member

    Issue is reproducible with sample found in https://github.com/orenwang/flutter_platform_view_multi_tap_test.

    I'm not entirely familiar with PlatformViews and how they handle gestures, so I'm leaving this to the team for further input.

    flutter doctor -v
    [✓] Flutter (Channel stable, 2.8.1, on macOS 11.6 20G165 darwin-arm, locale en-GB)
        • Flutter version 2.8.1 at /Users/nexus/dev/sdks/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/nexus/Library/Android/sdk
        • Platform android-31, build-tools 31.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-7249189)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 13.0)
        • 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 /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-7249189)
    
    [☠] IntelliJ IDEA Community Edition (the doctor check crashed)
        ✗ Due to an error, the doctor check did not complete. If the error message below is not helpful, please let us know about this issue at https://github.com/flutter/flutter/issues.
        ✗ FormatException: Unexpected extension byte (at offset 5)
        • #0      _Utf8Decoder.convertSingle (dart:convert-patch/convert_patch.dart:1789:7)
          #1      Utf8Decoder.convert (dart:convert/utf.dart:318:42)
          #2      InputStream.readString (package:archive/src/util/input_stream.dart:207:30)
          #3      new ZipDirectory.read (package:archive/src/zip/zip_directory.dart:40:30)
          #4      ZipDecoder.decodeBuffer (package:archive/src/zip_decoder.dart:19:30)
          #5      ZipDecoder.decodeBytes (package:archive/src/zip_decoder.dart:14:12)
          #6      IntelliJPlugins._findPluginXml (package:flutter_tools/src/intellij/intellij.dart:130:44)
          #7      IntelliJPlugins._readPackageVersion (package:flutter_tools/src/intellij/intellij.dart:141:40)
          #8      IntelliJPlugins.validatePackage (package:flutter_tools/src/intellij/intellij.dart:63:35)
          #9      IntelliJValidator.validate (package:flutter_tools/src/intellij/intellij_validator.dart:103:15)
          #10     asyncGuard.<anonymous closure> (package:flutter_tools/src/base/async_guard.dart:111:32)
          #11     asyncGuard.<anonymous closure> (package:flutter_tools/src/base/async_guard.dart:109:18)
          #12     _rootRun (dart:async/zone.dart:1428:13)
          #13     _CustomZone.run (dart:async/zone.dart:1328:19)
          #14     _runZoned (dart:async/zone.dart:1863:10)
          #15     runZonedGuarded (dart:async/zone.dart:1851:12)
          #16     runZoned (dart:async/zone.dart:1782:12)
          #17     asyncGuard (package:flutter_tools/src/base/async_guard.dart:109:3)
          #18     Doctor.startValidatorTasks (package:flutter_tools/src/doctor.dart:197:9)
          #19     Doctor.diagnose (package:flutter_tools/src/doctor.dart:301:47)
          #20     DoctorCommand.runCommand (package:flutter_tools/src/commands/doctor.dart:53:47)
          #21     FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:1290:12)
          <asynchronous suspension>
          #22     FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1140:27)
          <asynchronous suspension>
          #23     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
          <asynchronous suspension>
          #24     CommandRunner.runCommand (package:args/command_runner.dart:209:13)
          <asynchronous suspension>
          #25     FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:288:9)
          <asynchronous suspension>
          #26     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
          <asynchronous suspension>
          #27     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:236:5)
          <asynchronous suspension>
          #28     run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
          <asynchronous suspension>
          #29     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
          <asynchronous suspension>
          #30     main (package:flutter_tools/executable.dart:94:3)
          <asynchronous suspension>
    
    
    [✓] 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)
        • Nexus (mobile)  • 00008020-001875E83A38002E • ios            • iOS 15.0.2 19A404
        • macOS (desktop) • macos                     • darwin-arm64   • macOS 11.6 20G165 darwin-arm
        • Chrome (web)    • chrome                    • web-javascript • Google Chrome 97.0.4692.71
    
    ! Doctor found issues in 1 category.
    [✓] Flutter (Channel master, 2.9.0-1.0.pre.363, on macOS 11.6 20G165 darwin-arm, locale en-GB)
        • Flutter version 2.9.0-1.0.pre.363 at /Users/nexus/dev/sdks/flutters
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 9e9a728667 (6 hours ago), 2022-01-14 09:40:11 +0800
        • Engine revision f121c1fe68
        • Dart version 2.17.0 (build 2.17.0-11.0.dev)
        • DevTools version 2.9.2
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
        • Android SDK at /Users/nexus/Library/Android/sdk
        • Platform android-31, build-tools 31.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-7249189)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 13.0)
        • 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 /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-7249189)
    
    [✓] IntelliJ IDEA Community Edition (version 2021.3)
        • IntelliJ at /Applications/IntelliJ IDEA CE.app
        • Flutter plugin can be installed from:
          🔨 https://plugins.jetbrains.com/plugin/9212-flutter
        • Dart plugin version 213.5744.122
    
    [✓] 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)
        • Nexus (mobile)  • 00008020-001875E83A38002E • ios            • iOS 15.0.2 19A404
        • macOS (desktop) • macos                     • darwin-arm64   • macOS 11.6 20G165 darwin-arm
        • Chrome (web)    • chrome                    • web-javascript • Google Chrome 97.0.4692.71
    
    [✓] HTTP Host Availability
        • All required HTTP hosts are available
    
    • No issues found!
  3. added
    a: platform-viewsEmbedding Android/iOS views in Flutter apps
    f: gesturesflutter/packages/flutter/gestures repository.
    frameworkflutter/packages/flutter repository. See also f: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    platform-androidAndroid applications specifically
    and removed
    in triagePresently being triaged by the triage team
    on Jan 14, 2022
  4. orenwang commented on Jan 16, 2022

    @orenwang
    Author

    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 itspointerIndex and pointerId both being 0 as of the simple example in the original issue).

    Running the experiment branch, it behaves normally now with multi tap:
    flutter-multi-tap-test-experiment

    I think a better fix would be changing MotionEventTracker which somehow ignores the event.action value passed here sometimes.

  5. added
    P2Important issues not at the top of the work list
    on Feb 2, 2022
  6. cc-setwo commented on Feb 9, 2022

    @cc-setwo

    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:

    func createNativeView(view _view: UIView){
            _view.backgroundColor = UIColor.blue
            
            let button = UIButton(frame: CGRect(x: 100, y: 100, width: 100, height: 50))
            button.setTitle("Test Button 1", for: UIControl.State.normal)
            button.frame = CGRect(x: 0, y: 500, width: 180, height: 48.0)
            button.setBackgroundColor(color: UIColor.white, forState: UIControl.State.highlighted)
            _view.addSubview(button)
            
            let button2 = UIButton(frame: CGRect(x: 100, y: 100, width: 100, height: 50))
            button2.setTitle("Test Button 2", for: UIControl.State.normal)
            button2.frame = CGRect(x: 0, y: 250, width: 180, height: 48.0)
            button2.setBackgroundColor(color: UIColor.white, forState: UIControl.State.highlighted)
            _view.addSubview(button2)
        }
    

    And the extension for UIButton:

    extension UIButton {
        func setBackgroundColor(color: UIColor, forState: UIControl.State) {
            self.clipsToBounds = true  // add this to maintain corner radius
            UIGraphicsBeginImageContext(CGSize(width: 1, height: 1))
            if let context = UIGraphicsGetCurrentContext() {
                context.setFillColor(color.cgColor)
                context.fill(CGRect(x: 0, y: 0, width: 1, height: 1))
                let colorImage = UIGraphicsGetImageFromCurrentImageContext()
                UIGraphicsEndImageContext()
                self.setBackgroundImage(colorImage, for: forState)
            }
        }
    }
    
    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? 🙏

  7. orenwang commented on Feb 10, 2022

    @orenwang
    Author

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

  8. 3 remaining items

  9. Linspirit98 commented on Jul 31, 2022

    @Linspirit98

    @guoguoguilai @orenwang

    I have fixed something in flutter/engine that related to gestureRecognizer. By removing it, Multi touch in UIView works well!! But I'm not sure that gesture works correctly..

    Try compiling my engine and running with the engine. https://github.com/flutter/flutter/wiki/Debugging-the-engine https://github.com/flutter/flutter/wiki/Compiling-the-engine

    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!

  10. guoguoguilai commented on Sep 12, 2022

    @guoguoguilai

    Any update on this issue?

  11. gray-seven commented on Nov 30, 2022

    @gray-seven

    Flutter team please fix this issue

  12. wanglairo commented on Apr 27, 2023

    @wanglairo

    https://zhuanlan.zhihu.com/p/429345027
    看的这篇文章,解决了多点触控问题,屏蔽掉flutter侧的手势,用的原生手势

  13. iguangyu commented on Jul 28, 2023

    @iguangyu

    https://zhuanlan.zhihu.com/p/429345027 看的这篇文章,解决了多点触控问题,屏蔽掉flutter侧的手势,用的原生手势

    大佬,请问具体修改后的源码还在吗

  14. mcathena commented on Aug 28, 2023

    @mcathena

    Any update on this issue?

  15. ddrccw commented on Jun 5, 2024

    @ddrccw

    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

    @implementation ForwardingGestureRecognizer
    
    - (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event {
      [_flutterViewController.get() touchesEnded:touches withEvent:event];
      _currentTouchPointersCount -= touches.count;
      // Touches in one touch sequence are sent to the touchesEnded method separately if different
      // fingers stop touching the screen at different time. So one touchesEnded method triggering does
      // not necessarially mean the touch sequence has ended. We Only set the state to
      // UIGestureRecognizerStateFailed when all the touches in the current touch sequence is ended.
      if (_currentTouchPointersCount == 0) {
        self.state = UIGestureRecognizerStateFailed;
        _flutterViewController.reset(nil);
      } else {
        [touches enumerateObjectsUsingBlock:^(UITouch *obj, BOOL * _Nonnull stop) {
          // if _delayingRecognizer.get().state == UIGestureRecognizerStateFailed and obj.view != nil
          // it means the touch is ready to be delivered to the target view
          // the touch should not be handled by the gesture and can be ignore by the gesture
          if (obj.view != nil) {
              [self ignoreTouch:obj forEvent:event];
          }
        }];
      }
    }
    
  16. adrien-gannerie commented on Jun 10, 2024

    @adrien-gannerie

    @ddrccw hi, your modifications only are enough for fixe the multi touch issue ?

    Thanks.

  17. ddrccw commented on Jun 11, 2024

    @ddrccw

    @ddrccw hi, your modifications only are enough for fixe the multi touch issue ?

    Thanks.

    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

  18. adrien-gannerie commented on Jun 12, 2024

    @adrien-gannerie

    Thanks I will try.

  19. kaluli123123 commented on Aug 25, 2026

    @kaluli123123
    Contributor

    This looks like the same root cause as #191105, which is already fixed by an open PR: #191631.

    _AndroidMotionEventConverter.toAndroidMotionEvent builds the pointer array from
    pointerPositions.keys.toList() (Flutter insertion order), while Android's embedded views expect the
    array 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: platform-viewsEmbedding Android/iOS views in Flutter appsf: gesturesflutter/packages/flutter/gestures repository.found in release: 2.8Found to occur in 2.8found in release: 2.9Found to occur in 2.9frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyteam-androidOwned by Android platform teamtriaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions