Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Platform Views support Verified Input Events #49268

Merged
merged 1 commit into from
Jan 2, 2024

Conversation

johnmccutchan
Copy link
Contributor

@johnmccutchan johnmccutchan commented Dec 20, 2023

Android Platform Views process MotionEvents in a complicated way:

  1. MotionEvent is captured and delivered to PlatformViewWrapper.onTouchEvent (TLHC) or FlutterMutatorView.onTouchEvent (HC)
  2. MotionEvent is transformed by the AndroidTouchProcessor into a PointerEvent
  3. AndroidTouchProcessor sends the PointerEvent over the PlatformViewChannel
  4. Framework processes the PointerEvent
  5. Framework sends the PointerEvent over the PlatformViewChannel.
  6. in PlatformViewsController.onTouch a new MotionEvent is synthesized
  7. The MotionEvent is delivered to the platform view

After step (6) the MotionEvent will fail Verification (android.hardware.input.InputManager.verifyInputEvent).

The fix requires that in step (6) we use the original motion event delivered in step (1) instead of synthesizing a new instance.

@flutter-dashboard
Copy link

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 "@text-exemption-reviewers" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!).

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.

@johnmccutchan
Copy link
Contributor Author

johnmccutchan commented Jan 2, 2024

test-exempt: Test will be checked into the flutter repository.

See flutter/flutter#140806

Copy link
Contributor

@camsim99 camsim99 left a comment

Choose a reason for hiding this comment

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

LGTM, just left a question concerning my own understanding

// We are in virtual display mode or don't have a reference to the original MotionEvent.
// In this case we manually recreate a MotionEvent to be delivered. This MotionEvent
// will fail the verifiable input check.

Copy link
Contributor

Choose a reason for hiding this comment

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

What are the cases are where we don't have the original event if virtual display isn't being used (if we know them)? And why won't we have it when virtual display is used? Do these cases warrant warning users here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IIUC, the only case where this will happen (when not using virtual display) is when a gesture detector runs and creates new events related to the detected gesture.

1. MotionEvent is captured and delivered to PlatformViewWrapper.onTouchEvent
   (TLHC) or FlutterMutatorView.onTouchEvent (HC)
2. MotionEvent is transformed by the AndroidTouchProcessor into a PointerEvent
3. AndroidTouchProcessor sends the PointerEvent over the PlatformViewChannel
4. Framework processes the PointerEvent
5. Framework sends the PointerEvent over the PlatformViewChannel.
6. in PlatformViewsController.onTouch a new MotionEvent is synthesized
7. The MotionEvent is delivered to the platform view

After step (6) the MotionEvent will fail Verification
(android.hardware.input.InputManager.verifyInputEvent).

The fix requires that in step (6) we use the original motion event delivered
in step (1) instead of synthesizing a new instance.
@johnmccutchan johnmccutchan added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 2, 2024
@johnmccutchan johnmccutchan merged commit b02d59a into flutter:main Jan 2, 2024
26 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 2, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jan 2, 2024
…140824)

flutter/engine@9d89f87...b02d59a

2024-01-02 [email protected] Android Platform Views support Verified Input Events (flutter/engine#49268)

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

To file a bug in Flutter: 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
johnmccutchan added a commit to flutter/flutter that referenced this pull request Jan 2, 2024
This is an integration test associated with
flutter/engine#49268
auto-submit bot added a commit to flutter/flutter that referenced this pull request Jan 2, 2024
Reverts #140806
Initiated by: zanderso
This change reverts the following previous change:
Original Description:
This is an integration test associated with flutter/engine#49268
auto-submit bot pushed a commit that referenced this pull request May 14, 2024
Fixes flutter/flutter#146570, which tracks a regression from #49268 regarding platform view inputs in some specific cases.

This PR translates the input event location to be the same as the location we calculated before #49268, returning to the previous behavior, while maintaining the input event's verified status (I checked this manually with the `InputManager`).

Tested manually with the reproduction in the linked issue.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
flutteractionsbot pushed a commit to flutteractionsbot/engine that referenced this pull request May 22, 2024
Fixes flutter/flutter#146570, which tracks a regression from flutter#49268 regarding platform view inputs in some specific cases.

This PR translates the input event location to be the same as the location we calculated before flutter#49268, returning to the previous behavior, while maintaining the input event's verified status (I checked this manually with the `InputManager`).

Tested manually with the reproduction in the linked issue.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App platform-android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants