Skip to content

Fix crash when do multifinger gesture in XiaoMi or Huawei - #82013

Closed
haohongwei wants to merge 1 commit into
flutter:masterfrom
haohongwei:android_multifinger_cancel
Closed

haohongwei wants to merge 1 commit into
flutter:masterfrom
haohongwei:android_multifinger_cancel

Conversation

@haohongwei

@haohongwei haohongwei commented May 7, 2021 •

Copy link
Copy Markdown

Fixes #69431

When three finger moving in some android mobile(XiaoMi or Huawei), the MIUI in XiaoMi or EMUI in Huawei will cancel some of the finger moving. Then if flutter get the pointer cancel event ,it should remove the pointer which is canceled instead of cancel all the pointer.

When user moving three fingers in a webview which is shown on webview_flutter in Huawei or XiaoMi , there is an error in logcat, and the webview can not handle any touches any more:

I/flutter: Null check operator used on a null value
#0 _AndroidMotionEventConverter.toAndroidMotionEvent (package:flutter/src/services/platform_views.dart:605:31)
#1 AndroidViewController.dispatchPointerEvent (package:flutter/src/services/platform_views.dart:873:31)
#2 _PlatformViewGestureRecognizer.handleEvent (package:flutter/src/rendering/platform_view.dart:535:26)
#3 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:77:12)
#4 PointerRouter._dispatchEventToRoutes. (package:flutter/src/gestures/pointer_router.dart:122:9)
#5 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
#6 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:120:18)
#7 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:106:7)
#8 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:358:19)
#9 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart

After change the cancel method in platform_view.dart this error disappear, and webview can handle all the touches.

101620369674_ pic

Fix crash when do three finger gesture #72611

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

When three finger moving in some android mobile(XiaoMi or Huawei), the MIUI in XiaoMi  or EMUI in Huawei will cancel some of the finger moving. Then if flutter get the pointer cancel event ,it should remove the pointer which is canceled instead of cancel all the pointer.
@flutter-dashboard flutter-dashboard Bot added the framework flutter/packages/flutter repository. See also f: labels. label May 7, 2021
@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@google-cla google-cla Bot added the cla: yes label May 7, 2021
@haohongwei haohongwei changed the title Update platform_views.dart Fix crash when do multifinger gesture in XiaoMi or Huawei May 7, 2021
@xu-baolin

Copy link
Copy Markdown
Member

Can you add a test to prevent future regressions?

@ThexXTURBOXx

ThexXTURBOXx commented May 10, 2021 •

Copy link
Copy Markdown

This is not a fix, but a workaround. As already discussed in #69431, a fix inside the engine is needed.

For reference, see @Hixie's comment here: #78874 (comment)

@Hixie

Hixie commented May 11, 2021

Copy link
Copy Markdown
Contributor

I don't think we should check in workarounds. Let's just fix the real problem.

@haohongwei

haohongwei commented May 11, 2021 •

Copy link
Copy Markdown
Author

I don't think we should check in workarounds. Let's just fix the real problem.

Thank you for all of the people who reply about my commit.
But sorry, I have not read enough engine code to resolve the problem now.
I’d be grateful if anyone have some suggestion about the engine code related to the problem.

I still think the original code about cancel pointer may have problem.
Cancel one pointer should not clear all the pointers information.

@goderbauer

Copy link
Copy Markdown
Member

I am going to close this one since this is the wrong place for the fix (see discussion above).

@goderbauer goderbauer closed this May 19, 2021
@blasten

blasten commented Jun 8, 2021

Copy link
Copy Markdown

I think this is the correct fix. MotionEvent#ACTION_CANCEL should be handled as an up event.

The framework also treats CANCEL and UP similarly, although I didn't check for all cases.

@blasten blasten reopened this Jun 8, 2021
@blasten

blasten commented Jun 8, 2021

Copy link
Copy Markdown

@haohongwei thanks for the PR. #69431 is marked as P2 - this means is likely blocking customers. Any chance you could add tests?

@blasten
blasten self-requested a review June 8, 2021 18:44
pointerProperties.clear();
usedAndroidPointerIds.clear();
downTimeMillis = null;
pointerPositions.remove(event.pointer);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: consider reducing the duplicated logic

@xu-baolin

Copy link
Copy Markdown
Member

I have posted PR #84257 to continue the test work.

@blasten blasten closed this Jun 9, 2021
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.

[engine] Three (or more) finger gestures on certain widgets make app unusable

6 participants