Skip to content

[DO_NOT_LAND (pending G3Fix)] [ios][pv] Reland platform view hitTest approach (again)#185126

Open
hellohuanlin wants to merge 8 commits intoflutter:masterfrom
hellohuanlin:pv_hit_test_2026_again
Open

[DO_NOT_LAND (pending G3Fix)] [ios][pv] Reland platform view hitTest approach (again)#185126
hellohuanlin wants to merge 8 commits intoflutter:masterfrom
hellohuanlin:pv_hit_test_2026_again

Conversation

@hellohuanlin
Copy link
Copy Markdown
Contributor

@hellohuanlin hellohuanlin commented Apr 16, 2026

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.

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 hellohuanlin requested a review from a team as a code owner April 16, 2026 00:41
@github-actions github-actions bot 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
Contributor Author

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.

Copy link
Copy Markdown
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 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
Copy link
Copy Markdown
Contributor Author

hellohuanlin commented Apr 16, 2026

@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

@hellohuanlin hellohuanlin added the CICD Run CI/CD label Apr 16, 2026
@hellohuanlin
Copy link
Copy Markdown
Contributor Author

Mac_ios native_platform_view_ui_tests_iosSuccessful in 9m

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

@hellohuanlin hellohuanlin force-pushed the pv_hit_test_2026_again branch from 226b0de to 38f9074 Compare April 16, 2026 15:28
@github-actions github-actions bot removed the CICD Run CI/CD label Apr 16, 2026
@hellohuanlin hellohuanlin changed the title [DO_NOT_LAND(disable pre-submit)] Reland platform view hitTest again Reland platform view hitTest approach (again) Apr 16, 2026
@hellohuanlin hellohuanlin added the CICD Run CI/CD label Apr 16, 2026
@hellohuanlin hellohuanlin changed the title Reland platform view hitTest approach (again) [ios][pv] Reland platform view hitTest approach (again) Apr 16, 2026
@hellohuanlin hellohuanlin 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) a: text input Entering text in a text field or keyboard related problems CICD Run CI/CD engine flutter/engine related. See also e: labels. f: gestures flutter/packages/flutter/gestures repository. framework flutter/packages/flutter repository. See also f: labels. platform-fuchsia Fuchsia code specifically platform-ios iOS applications specifically platform-web Web applications specifically team-ios Owned by iOS platform team

Projects

None yet

2 participants