Skip to content

Conversation

@gmackall
Copy link
Member

@gmackall gmackall commented Dec 23, 2025

I don't know if there is an issue for this, but without the fix it looks like (in particular see the end of the video)

Screen_recording_20251223_140853.mp4

and with the fix it looks like

Screen_recording_20251223_140519.mp4

Basically, we were using the value passed in by the engine in onDisplayPlatformView(2) to try to calculate the offset for this touch. However, we aren't guaranteed a call to onDisplayPlatformView for each call to FlutterMutatorView.onTouchEvent, and in practice we don't normally get them lined up like that, so the value is stale. Also, the touches are frequently changing by sub pixel values, but the values passed to onDisplayPlatformView are received as ints (we could maybe fix this, if it matters elsewhere). So this is fragile, comparing whole pixel to sub pixel, and also uses stale values. We can instead just ask android where the view is, I believe (this is what the PR does, and it works AFAICT).

I don't know how to test this.

@github-actions github-actions bot added platform-android Android applications specifically engine flutter/engine related. See also e: labels. team-android Owned by Android platform team labels Dec 23, 2025
@gmackall gmackall marked this pull request as ready for review December 23, 2025 22:53
@gmackall gmackall requested a review from a team as a code owner December 23, 2025 22:53
@gmackall
Copy link
Member Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses a scrolling issue with platform views by ensuring touch event coordinates are correctly translated. The change from using potentially stale left and top fields to calling getLeft() and getTop() for ACTION_MOVE events is a good step. The addition of requestUnbufferedDispatch(event) for smoother scrolling is also a nice improvement.

My main feedback is to apply the coordinate fix more consistently. The reasoning for using getLeft() and getTop() applies to all touch events, not just ACTION_MOVE. I've left a suggestion to simplify the logic and make it more robust.

Additionally, it appears the canDragViews test in FlutterMutatorViewTest.java may no longer be valid with these changes and will likely need to be updated to align with the new behavior. The test currently seems to assert the old behavior of using coordinates from the start of the gesture.

return super.onTouchEvent(event);
}

requestUnbufferedDispatch(event);
Copy link
Member Author

@gmackall gmackall Dec 23, 2025

Choose a reason for hiding this comment

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

This may have an impact on platform views that themselves are handling touches, as we will be sending them unbuffered inputs after we pipe them through the framework. We could alternatively make this

if (event.getAction() == MotionEvent.ACTION_MOVE) {
  requestUnbufferedDispatch(event);
}

as currently I think the move case is the place where we get the benefit, and this would then not have an impact on taps.

Copy link
Member Author

Choose a reason for hiding this comment

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

I removed this, as it is a logically separate change. Can consider in a different PR.

@gmackall

This comment was marked as resolved.

@gmackall gmackall marked this pull request as draft January 5, 2026 18:29
@flutter-dashboard
Copy link

This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again.

For more guidance, visit Writing a golden file test for package:flutter.

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

@gmackall
Copy link
Member Author

gmackall commented Jan 5, 2026

Confirmed this works with TLHC/VD

Removed unbuffered dispatch request from onTouchEvent.
@gmackall gmackall marked this pull request as ready for review January 5, 2026 19:44
@gmackall gmackall added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 7, 2026
@auto-submit auto-submit bot added this pull request to the merge queue Jan 7, 2026
Merged via the queue into flutter:master with commit 519dcdc Jan 7, 2026
179 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jan 7, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 8, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 8, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 8, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 8, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 9, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 9, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 9, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 9, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 10, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 10, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jan 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engine flutter/engine related. See also e: labels. platform-android Android applications specifically team-android Owned by Android platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants