Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Fix unexpected pointer change issue and Add test case #43949

Merged
merged 1 commit into from
Aug 10, 2023

Conversation

LoveJello
Copy link
Contributor

@LoveJello LoveJello commented Jul 24, 2023

Fix issue 129765 and Add test case, see issue
Fixes flutter/flutter#129765

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 and the C++, Objective-C, Java style guides.
  • [✓] I listed at least one issue that this PR fixes in the description above.
  • [✓] I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • [✓] I updated/added relevant documentation (doc comments with ///).
  • [✓] I signed the CLA.
  • [ ✓] All existing and new tests are passing.

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

@flutter-dashboard flutter-dashboard bot changed the base branch from master to main July 24, 2023 08:16
@flutter-dashboard
Copy link

This pull request was opened against a branch other than main. Since Flutter pull requests should not normally be opened against branches other than main, I have changed the base to main. If this was intended, you may modify the base back to master. See the Release Process for information about how other branches get updated.

Reviewers: Use caution before merging pull requests to branches other than main, unless this is an intentional hotfix/cherrypick.

@google-cla
Copy link

google-cla bot commented Jul 24, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link
Contributor

@moffatman moffatman left a comment

Choose a reason for hiding this comment

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

My question -- what happens to the data in the ACTION_SCROLL here? Is it important we should turn that into an actual scroll update? Or it's OK just to throw it away and ignore this event? Looks like your change now will just ignore it, the new event (PAN_ZOOM_UPDATE) will (should?) have fields of zero-- being a no-op.

@LoveJello
Copy link
Contributor Author

My question -- what happens to the data in the ACTION_SCROLL here? Is it important we should turn that into an actual scroll update? Or it's OK just to throw it away and ignore this event? Looks like your change now will just ignore it, the new event (PAN_ZOOM_UPDATE) will (should?) have fields of zero-- being a no-op.

Map scroll event for PointerChange.HOVER and finaly PointerChange.PAN_ZOOM_UPDATE. just as your advise before.

@@ -396,12 +411,12 @@ public class AndroidTouchProcessor {
private int getPointerChangeForPanZoom(int pointerChange) {
if (pointerChange == PointerChange.DOWN) {
return PointerChange.PAN_ZOOM_START;

  • } else if (pointerChange == PointerChange.MOVE) {
  • } else if (pointerChange == PointerChange.MOVE || pointerChange == PointerChange.HOVER) {
    return PointerChange.PAN_ZOOM_UPDATE;
    } else if (pointerChange == PointerChange.UP || pointerChange == PointerChange.CANCEL) {
    return PointerChange.PAN_ZOOM_END;
    }

@LoveJello LoveJello force-pushed the master branch 3 times, most recently from fcbf66f to f0f00ec Compare July 28, 2023 02:52
@LoveJello
Copy link
Contributor Author

@moffatman Any update or comment?

.verify(mockRenderer)
.dispatchPointerDataPacket(packetCaptor.capture(), packetSizeCaptor.capture());
packet = packetCaptor.getValue();
assertEquals(0.0, readPointerPhysicalX(packet));
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you test, what are the deviceKind, signalKind, and pointerChange 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.

Done

@moffatman
Copy link
Contributor

Does the ACTION_SCROLL generic motion event contain any useful data? Such as some scroll delta which isn't in any other event? Maybe it's best just to skip this event altogether. Follow same approach as if (pointerChange == -1), check this pan-zoom mapping earlier and return without modifying the packet if we get this weird event.

I would like to see, if you can print out the exact events and field values from the real device? Thanks :)

Also, you will have to use the formatting script I think to get all the checks to pass.

@LoveJello
Copy link
Contributor Author

Does the ACTION_SCROLL generic motion event contain any useful data? Such as some scroll delta which isn't in any other event? Maybe it's best just to skip this event altogether. Follow same approach as if (pointerChange == -1), check this pan-zoom mapping earlier and return without modifying the packet if we get this weird event.

I would like to see, if you can print out the exact events and field values from the real device? Thanks :)

Also, you will have to use the formatting script I think to get all the checks to pass.

For events in that wired device, please refer to flutter/flutter#129765. Copy them here:

06-29 19:19:42.562 4919 4919 V AndroidTouchProcessor: onGenericMotionEvent, event MotionEvent { action=ACTION_HOVER_ENTER, actionButton=0, id[0]=0, x[0]=1296.2535, y[0]=398.5768, toolType[0]=TOOL_TYPE_MOUSE, buttonState=
0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=628215, downTime=144832, deviceId=7, source=0x2002, displayId=0 }
06-29 19:19:42.567 4919 4919 V AndroidTouchProcessor: onGenericMotionEvent, event MotionEvent { action=ACTION_HOVER_MOVE, actionButton=0, id[0]=0, x[0]=1296.2535, y[0]=398.5768, toolType[0]=TOOL_TYPE_MOUSE, buttonState=0
, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=628215, downTime=144832, deviceId=7, source=0x2002, displayId=0 }
06-29 19:19:42.575 4919 4919 V AndroidTouchProcessor: onGenericMotionEvent, event MotionEvent { action=ACTION_HOVER_EXIT, actionButton=0, id[0]=0, x[0]=1296.2535, y[0]=398.5768, toolType[0]=TOOL_TYPE_MOUSE, buttonState=0
, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=628222, downTime=628222, deviceId=7, source=0x2002, displayId=0 }
06-29 19:19:42.578 4919 4919 V AndroidTouchProcessor: onTouchEvent, event MotionEvent { action=ACTION_DOWN, actionButton=0, id[0]=0, x[0]=1296.2535, y[0]=398.5768, toolType[0]=TOOL_TYPE_MOUSE, buttonState=0, classificati
on=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=628222, downTime=628222, deviceId=7, source=0x2002, displayId=0 }
06-29 19:19:42.673 4919 4919 V AndroidTouchProcessor: onTouchEvent, event MotionEvent { action=ACTION_MOVE, actionButton=0, id[0]=0, x[0]=1277.6, y[0]=448.00885, toolType[0]=TOOL_TYPE_MOUSE, buttonState=0, classification
=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=628328, downTime=628222, deviceId=7, source=0x2002, displayId=0 }
06-29 19:19:42.675 4919 4919 V AndroidTouchProcessor: onGenericMotionEvent, event MotionEvent { action=ACTION_SCROLL, actionButton=0, id[0]=0, x[0]=0.0, y[0]=0.0, toolType[0]=TOOL_TYPE_MOUSE, buttonState=0, classificatio
n=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=628328, downTime=628222, deviceId=7, source=0x2002, displayId=0 }

drop this ACTION_SCROLL is not a good choice I think .

@LoveJello
Copy link
Contributor Author

LoveJello commented Jul 28, 2023

Also, you will have to use the formatting script I think to get all the checks to pass.

Already done. That Linux linux_unopt case is not related to this patch, and I don't known how to fix it.

@moffatman
Copy link
Contributor

@moffatman
Copy link
Contributor

Looking at the log above, there is no useful info in the ACTION_SCROLL. All fields zero. What happens afterwards? Is there ACTION_UP on this "scroll pointer"?

@LoveJello
Copy link
Contributor Author

Yes, it is related to your patch, see the mismatch in formatting here: https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8774350301251168225/+/u/test:_test:format_and_dart_test__3_/stdout

Done.

@LoveJello
Copy link
Contributor Author

Looking at the log above, there is no useful info in the ACTION_SCROLL. All fields zero. What happens afterwards? Is there ACTION_UP on this "scroll pointer"?

Sorry, I don't have that device any more.

Drop that event or send that event to flutter, it's a question...

@moffatman
Copy link
Contributor

OK. I propose we can just drop the event. At the beginning of addPointerForIndex, we can just check isTrackpadPan. Then if getPointerChangeForPanZoom is -1, return without creating the packet.

@LoveJello
Copy link
Contributor Author

OK. I propose we can just drop the event. At the beginning of addPointerForIndex, we can just check isTrackpadPan. Then if getPointerChangeForPanZoom is -1, return without creating the packet.

Done.

@moffatman
Copy link
Contributor

Btw, I think you have to rebase to fix the test failure

@LoveJello
Copy link
Contributor Author

Btw, I think you have to rebase to fix the test failure

Done.

@moffatman
Copy link
Contributor

I just tried running locally, you don't need the changes for testing, you can add when(event.isFromSource(InputDevice.SOURCE_CLASS_POINTER)).thenReturn(true); into the list of mocks for MotionEventMocker::mockEvent

Signed-off-by: Xiaohu Hu <huxiaohu2007@gmail.com>
@LoveJello
Copy link
Contributor Author

when(event.isFromSource(InputDevice.SOURCE_CLASS_POINTER)).thenReturn(true);

Yes,you are right. I have changed the code .

Copy link
Contributor

@moffatman moffatman left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for all the changes 👍

@chinmaygarde
Copy link
Member

cc @reidbaker for second approval.

@LoveJello
Copy link
Contributor Author

cc @reidbaker for second approval.

Any update ?

@reidbaker reidbaker requested review from Piinks and reidbaker August 8, 2023 21:26
@reidbaker
Copy link
Contributor

Sorry I wasn't actually added as a reviewer and I triage pings slower than review requests.

I don't see anything obviously wrong but I am going to defer to @Piinks. I am not as comfortable as I should be with the scroll logic.

Thank you for your contribution

@LoveJello
Copy link
Contributor Author

Sorry I wasn't actually added as a reviewer and I triage pings slower than review requests.

I don't see anything obviously wrong but I am going to defer to @Piinks. I am not as comfortable as I should be with the scroll logic.

Thank you for your contribution

@Piinks Any update or comment ?

Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

Hey @LoveJello welcome, thanks for contributing! I see you found and reported the issue as well, many thanks . :)

LGTM!

@Piinks Piinks added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 10, 2023
@auto-submit auto-submit bot merged commit 0795adf into flutter:main Aug 10, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Aug 10, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Aug 10, 2023
…132332)

flutter/engine@a9be77e...16b01b9

2023-08-10 skia-flutter-autoroll@skia.org Roll Dart SDK from 46da53e7abe2 to a2eac00da6b8 (1 revision) (flutter/engine#44601)
2023-08-10 huxiaohu2007@gmail.com Fix unexpected pointer change issue and Add test case (flutter/engine#43949)
2023-08-10 47866232+chunhtai@users.noreply.github.com Reland "Android a11y bridge sets importantness" (flutter/engine#44589)
2023-08-10 john@johnmccutchan.com Support for Android Platform Views under Impeller/Vulkan (flutter/engine#44571)
2023-08-10 109111084+yaakovschectman@users.noreply.github.com Reintroduce Windows lifecycle with guard for posthumous `OnWindowStateEvent` (flutter/engine#44344)
2023-08-10 skia-flutter-autoroll@skia.org Roll Skia from 92e6f52b0fa8 to b6492f5ce8c3 (1 revision) (flutter/engine#44597)

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 chinmaygarde@google.com,rmistry@google.com,zra@google.com 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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
@reidbaker reidbaker mentioned this pull request Aug 16, 2023
14 tasks
gaaclarke pushed a commit to gaaclarke/engine that referenced this pull request Aug 30, 2023
Fix issue 129765 and Add test case, see  issue
Fixes flutter/flutter#129765

- [�] 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] and the [C++, Objective-C, Java style guides].
- [�] I listed at least one issue that this PR fixes in the description above.
- [�] I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See [testing the engine] for instructions on writing and running engine tests.
- [�] I updated/added relevant documentation (doc comments with `///`).
- [�] I signed the [CLA].
- [ �] All existing and new tests are passing.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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.

Engine may crash when two fingers tap and move on some special devices - Unexpected pointer change
5 participants