Skip to content

[ios][pv] Reland platform view hitTest approach (again) - #185126

Merged
auto-submit[bot] merged 8 commits into
flutter:masterfrom
hellohuanlin:pv_hit_test_2026_again
Apr 21, 2026
Merged

[ios][pv] Reland platform view hitTest approach (again)#185126
auto-submit[bot] merged 8 commits into
flutter:masterfrom
hellohuanlin:pv_hit_test_2026_again

Conversation

@hellohuanlin

@hellohuanlinhellohuanlin commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

This PR tries to reland the previous PR: #183484. Refer to it for more details.

What happened to the previous PR?

2 tests from ios_platform_view_ui_test failed due to edge swipe gesture (https://www.youtube.com/watch?v=MVO5b0eEdw8). Cupertino puts a gesture listener on left edge of screen. When tapping there, the hitTest logic returns the gesture listener as the first hit (instead of our platform view), hence blocking the platform view.

Why we didn't find this issue before?

Because it only happen to iPhone, but I use iPad for testing.

What's the fix?

In flutter, hitTest returns a list of all targets that should be hit tested. So instead of checking if the first hit is the platform view, we check if the result contains any platform view.

I have also created a UIKit app, and verified that the expected behavior is that platform view should still receive touch even if swipe edge back gesture is recognized.

A key info is that during Flutter's hitTest operation, the result list will not contain a target if it is blocked by another target in front (e.g. context menu covering a platform view).

If there are multiple platform views, that's fine too, because UIKit itself will perform hitTest which finds the correct touch intercepting view, which sends the request to framework.

List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.

Fixes#179916
Fixes#175099

If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.

Pre-launch Checklist

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

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

@hellohuanlin
hellohuanlin requested a review from a team as a code ownerApril 16, 2026 00:41
@github-actionsgithub-actionsBot added a: text input Entering text in a text field or keyboard related problems platform-ios iOS applications specifically framework flutter/packages/flutter repository. See also f: labels. engine flutter/engine related. See also e: labels. a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) platform-fuchsia Fuchsia code specifically f: gestures flutter/packages/flutter/gestures repository. platform-web Web applications specifically team-ios Owned by iOS platform team labels Apr 16, 2026
Comment thread.ci.yaml Outdated
- name: Mac_ios native_platform_view_ui_tests_ios
recipe: devicelab/devicelab_drone
presubmit: false
presubmit: true

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Will revert this after verifying it worked on CI.

@gemini-code-assistgemini-code-assistBot left a comment

Copy link
Copy Markdown
Contributor

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 implements a synchronous hit-testing mechanism for iOS platform views, enabling the Flutter framework to decide whether a touch should be delivered to a native view or blocked by overlapping Flutter widgets. Key changes include adding an onHitTest callback to the PlatformDispatcher, introducing the NativeHitTestTarget mixin for render objects, and exposing a new gestureBlockingPolicy for UiKitView. Feedback suggests optimizing the hitTest:withEvent: override in FlutterTouchInterceptingView by checking view visibility and interaction status before performing the framework hit test.

@hellohuanlin

hellohuanlin commented Apr 16, 2026

Copy link
Copy Markdown
ContributorAuthor

@loic-sharma@chunhtai@vashworth FYI the first 6 commits are exactly the same as previous PR landed. I added 2 new commits:

  1. the hitTest logic change which fixes the issue
  2. renamed isPlatformView to hasPlatformView

@hellohuanlinhellohuanlin added the CICD Run CI/CD label Apr 16, 2026
@hellohuanlin

Copy link
Copy Markdown
ContributorAuthor

Mac_ios native_platform_view_ui_tests_iosSuccessful in 9m

Confirmed the fix passes the test. Will disable the pre-submit

@hellohuanlin
hellohuanlinforce-pushed the pv_hit_test_2026_again branch from 226b0de to 38f9074CompareApril 16, 2026 15:28
@github-actionsgithub-actionsBot removed the CICD Run CI/CD label Apr 16, 2026
@hellohuanlinhellohuanlin changed the title [DO_NOT_LAND(disable pre-submit)] Reland platform view hitTest againReland platform view hitTest approach (again)Apr 16, 2026
@hellohuanlinhellohuanlin added the CICD Run CI/CD label Apr 16, 2026
@hellohuanlinhellohuanlin changed the title Reland platform view hitTest approach (again)[ios][pv] Reland platform view hitTest approach (again)Apr 16, 2026
@hellohuanlinhellohuanlin changed the title [ios][pv] Reland platform view hitTest approach (again)[DO_NOT_LAND (pending G3Fix)] [ios][pv] Reland platform view hitTest approach (again)Apr 16, 2026

@chunhtaichunhtai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

address comments and nits
inverse dep and rename
rename policy to touch blocking only
support passing via widget
format
update dart ui api
update some comments and fix dart test
add a warning
add a warning
fix tests
nit
duplicate hit test request/response types on web
fix web platofrm
nit
update fallback
format
address comments
format
use runZonedGuarded
autoformatter bad
remove unused code
linter error
address comments
final comment nit
remove & recommended by loic
optional comment nit
@hellohuanlin
hellohuanlinforce-pushed the pv_hit_test_2026_again branch from 38f9074 to 91ac645CompareApril 20, 2026 04:04
@github-actionsgithub-actionsBot removed the CICD Run CI/CD label Apr 20, 2026
@hellohuanlinhellohuanlin changed the title [DO_NOT_LAND (pending G3Fix)] [ios][pv] Reland platform view hitTest approach (again)[ios][pv] Reland platform view hitTest approach (again)Apr 20, 2026
@hellohuanlinhellohuanlin added CICD Run CI/CD autosubmit Merge PR when tree becomes green via auto submit App labels Apr 20, 2026
@auto-submit
auto-submitBot added this pull request to the merge queueApr 20, 2026
Merged via the queue into flutter:master with commit 7266dd5Apr 21, 2026
199 checks passed
@flutter-dashboardflutter-dashboardBot removed the autosubmit Merge PR when tree becomes green via auto submit App label Apr 21, 2026
auto-submitBot pushed a commit to flutter/packages that referenced this pull request Apr 21, 2026
flutter/flutter@2844af6...3d0e822
2026-04-21 goderbauer@google.com Reland "Unpin google_mobile_ads" (flutter/flutter#180838)
2026-04-21 ishaquehassan@gmail.com fix: correct LicenseRegistry docs to reference NOTICES instead of LICENSE (flutter/flutter#184572)
2026-04-21 engine-flutter-autoroll@skia.org Roll Skia from f8637ade3d92 to a234f0ed7245 (2 revisions) (flutter/flutter#185334)
2026-04-21 engine-flutter-autoroll@skia.org Roll Skia from 3b338913f623 to f8637ade3d92 (9 revisions) (flutter/flutter#185331)
2026-04-21 kevmoo@users.noreply.github.com Fix non-minimal relative imports in flutter_tools (flutter/flutter#183971)
2026-04-21 sigurdm@google.com Reapply "Unpin sdk package dependencies" (flutter/flutter#185268)
2026-04-21 robert.ancell@canonical.com Remove unused private header (flutter/flutter#185260)
2026-04-20 chris@bracken.jp [iOS] Improve LaunchEngine implementation/API/docs (flutter/flutter#185200)
2026-04-20 41930132+hellohuanlin@users.noreply.github.com [ios][pv] Reland platform view hitTest approach (again) (flutter/flutter#185126)
2026-04-20 engine-flutter-autoroll@skia.org Roll Skia from 75c2791c6274 to 3b338913f623 (3 revisions) (flutter/flutter#185304)
2026-04-20 srawlins@google.com ignore avoid_type_to_string lint rule (flutter/flutter#184765)
2026-04-20 jacksongardner@google.com Fix race condition in modifying release manifest. (flutter/flutter#185185)
2026-04-20 jason-simmons@users.noreply.github.com In the dev/bots/analyze.dart script, obtain the relevant set of paths from Git instead of crawling the filesystem (flutter/flutter#185058)
2026-04-20 jacksongardner@google.com [wimp] Implement images for wimp. (flutter/flutter#183913)
2026-04-20 47866232+chunhtai@users.noreply.github.com add the next batch for VPAT assessment (flutter/flutter#185053)
2026-04-20 engine-flutter-autoroll@skia.org Roll Packages from c2e3d1f to 01c505f (21 revisions) (flutter/flutter#185287)
2026-04-20 jacksongardner@google.com Avoid use of direct string injection in GitHub Workflow "run" steps. (flutter/flutter#185301)
2026-04-20 bkonyi@google.com Regenerate pubspec.lock (flutter/flutter#185290)
2026-04-20 jason-simmons@users.noreply.github.com Report an error if the git ls-tree command fails in the content_aware_hash script (flutter/flutter#185170)
2026-04-20 engine-flutter-autoroll@skia.org Roll Skia from d8415c5d7b91 to 75c2791c6274 (40 revisions) (flutter/flutter#185284)
2026-04-20 bkonyi@google.com Move widget_preview_scaffold into pub workspace (flutter/flutter#185176)
2026-04-20 dacoharkes@google.com [record_use] Run build hooks and link hooks in separate targets (flutter/flutter#184880)
2026-04-20 arpitgandhi9@users.noreply.github.com feat: add reloadIsRestart to handle hot reload as a restart for web #179448 (flutter/flutter#183233)
2026-04-20 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from aDbXQm6WA0wFCAUp-... to LPa7NLiXEZP2A7IwZ... (flutter/flutter#185269)
If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.
To file a bug in Packages: 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
creatorpiyush pushed a commit to creatorpiyush/packages that referenced this pull request Jun 10, 2026
…r#11548)
flutter/flutter@2844af6...3d0e822
2026-04-21 goderbauer@google.com Reland "Unpin google_mobile_ads" (flutter/flutter#180838)
2026-04-21 ishaquehassan@gmail.com fix: correct LicenseRegistry docs to reference NOTICES instead of LICENSE (flutter/flutter#184572)
2026-04-21 engine-flutter-autoroll@skia.org Roll Skia from f8637ade3d92 to a234f0ed7245 (2 revisions) (flutter/flutter#185334)
2026-04-21 engine-flutter-autoroll@skia.org Roll Skia from 3b338913f623 to f8637ade3d92 (9 revisions) (flutter/flutter#185331)
2026-04-21 kevmoo@users.noreply.github.com Fix non-minimal relative imports in flutter_tools (flutter/flutter#183971)
2026-04-21 sigurdm@google.com Reapply "Unpin sdk package dependencies" (flutter/flutter#185268)
2026-04-21 robert.ancell@canonical.com Remove unused private header (flutter/flutter#185260)
2026-04-20 chris@bracken.jp [iOS] Improve LaunchEngine implementation/API/docs (flutter/flutter#185200)
2026-04-20 41930132+hellohuanlin@users.noreply.github.com [ios][pv] Reland platform view hitTest approach (again) (flutter/flutter#185126)
2026-04-20 engine-flutter-autoroll@skia.org Roll Skia from 75c2791c6274 to 3b338913f623 (3 revisions) (flutter/flutter#185304)
2026-04-20 srawlins@google.com ignore avoid_type_to_string lint rule (flutter/flutter#184765)
2026-04-20 jacksongardner@google.com Fix race condition in modifying release manifest. (flutter/flutter#185185)
2026-04-20 jason-simmons@users.noreply.github.com In the dev/bots/analyze.dart script, obtain the relevant set of paths from Git instead of crawling the filesystem (flutter/flutter#185058)
2026-04-20 jacksongardner@google.com [wimp] Implement images for wimp. (flutter/flutter#183913)
2026-04-20 47866232+chunhtai@users.noreply.github.com add the next batch for VPAT assessment (flutter/flutter#185053)
2026-04-20 engine-flutter-autoroll@skia.org Roll Packages from c2e3d1f to 01c505f (21 revisions) (flutter/flutter#185287)
2026-04-20 jacksongardner@google.com Avoid use of direct string injection in GitHub Workflow "run" steps. (flutter/flutter#185301)
2026-04-20 bkonyi@google.com Regenerate pubspec.lock (flutter/flutter#185290)
2026-04-20 jason-simmons@users.noreply.github.com Report an error if the git ls-tree command fails in the content_aware_hash script (flutter/flutter#185170)
2026-04-20 engine-flutter-autoroll@skia.org Roll Skia from d8415c5d7b91 to 75c2791c6274 (40 revisions) (flutter/flutter#185284)
2026-04-20 bkonyi@google.com Move widget_preview_scaffold into pub workspace (flutter/flutter#185176)
2026-04-20 dacoharkes@google.com [record_use] Run build hooks and link hooks in separate targets (flutter/flutter#184880)
2026-04-20 arpitgandhi9@users.noreply.github.com feat: add reloadIsRestart to handle hot reload as a restart for web #179448 (flutter/flutter#183233)
2026-04-20 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from aDbXQm6WA0wFCAUp-... to LPa7NLiXEZP2A7IwZ... (flutter/flutter#185269)
If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.
To file a bug in Packages: 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
@chenenyu

Copy link
Copy Markdown

Hello, when will this pr be merged into the stable branch?

@thamtumeoden13

Copy link
Copy Markdown

Thanks for merging this fix.
Could you share whether PR #185126 is planned for an upcoming stable release (or cherry-pick), and if so, which version?

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

Labels

a: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)a: text inputEntering text in a text field or keyboard related problemsCICDRun CI/CDengineflutter/engine related. See also e: labels.f: gesturesflutter/packages/flutter/gestures repository.frameworkflutter/packages/flutter repository. See also f: labels.platform-fuchsiaFuchsia code specificallyplatform-iosiOS applications specificallyplatform-webWeb applications specificallyteam-iosOwned by iOS platform team

Projects

None yet

5 participants

@hellohuanlin@chenenyu@thamtumeoden13@loic-sharma@chunhtai