[ios][platform_view]Reland hitTest approach (with a few 2026 update)#183484
Conversation
|
For ease of review, I have split this PR into 2 commits: the 1st commit is the original PR landed/reverted from last year; the 2nd commit is the changes in 2026 that we'd like to make. The changes are:
Next up: I will work on an integration test for #179916, which will be fixed by this PR. The integration test likely be a 3rd commit in this PR, or a separate PR afterwards (depending on PR review timing). But anyways the 2nd commit of this PR should be ready for review. Or if you prefer, we can wait till integration test is in. No rush. |
| @@ -476,6 +477,24 @@ class RuntimeController : public PlatformConfigurationClient, | |||
| /// | |||
| bool DispatchPointerDataPacket(const PointerDataPacket& packet); | |||
|
|
|||
| // TODO(hellohuanlin): we should make make this a generic HitTest API. | |||
There was a problem hiding this comment.
Same here - any concern of directly renaming it as HitTest for other platforms?
There was a problem hiding this comment.
Code Review
This pull request re-lands the hit-test approach for iOS platform views, with some updates. The changes are extensive, touching C++, Objective-C, and Dart code across the engine and framework. The core logic involves adding a hitTest mechanism that allows the framework to decide whether a platform view should receive a touch event. This is exposed through a new onHitTest callback on PlatformDispatcher. A new gesture blocking policy, doNotBlockGesture, is introduced to leverage this hit-testing mechanism. The changes are well-tested, with new unit tests covering the hit-testing logic and gesture policy behaviors. I have one suggestion to improve test code maintainability by refactoring duplicated logic into a helper function.
| * https://github.com/flutter/flutter/issues/175099. | ||
| */ | ||
| FlutterPlatformViewGestureRecognizersBlockingPolicyTouchBlockingOnly, | ||
| FlutterPlatformViewGestureRecognizersBlockingPolicyDoNotBlockGesture, |
There was a problem hiding this comment.
I'm also open to these names:
NoGestureBlockingNoUIGestureRecognizerBlockingNoFlutterGestureArenaBlocking- Since the enum type name is already
GestureRecognizersBlockingPolicy, I guess justNoBlockingorDisabledalso works.
4dadc2e to
a9424e7
Compare
12be16a to
8e837d6
Compare
loic-sharma
left a comment
There was a problem hiding this comment.
Re-LGTM for framework + engine. I only lightly reviewed iOS embedder changes.
|
Thanks. The follow up commits are just fixing CI failures. We should be good. |
|
autosubmit label was removed for flutter/flutter/183484, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label. |
…lutter#183484) This PR tries to re-land [the original PR](flutter#179659), which was reverted since we found a quick fix. However, hitTest is still important so we should land it. See ([go/pv-touch-gesture-blocking-changes-2026 (internal golink)](http://goto.google.com/pv-touch-gesture-blocking-changes-2026)), or the [public design doc](https://goto.google.com/ios-platform-view-touch-gesture-blocking). For ease of review, I have split this PR into 2 commits: the 1st commit is the [originally landed/reverted PR from last year](flutter#179659); the 2nd commit is the changes in 2026 that we'd like to make. The changes are: 1. Enable hitTest directly (regardless of policies) 2. Rename `hitTestOnly` to `doNotBlockGesture` policy If you have reviewed the original PR, feel free to only review the 2nd commit. Next up: I will work on an integration test for [drawing website fall-through issue](flutter#179916), which will be fixed by this PR. The integration test likely be a 3rd commit in this PR, or a separate PR afterwards (depending on PR review timing) *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 flutter#179916 Fixes flutter#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 - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). 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. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
|
A reason for requesting a revert of flutter/flutter/183484 could |
|
Reason for revert: Tree is failing: https://ci.chromium.org/ui/p/flutter/builders/prod/Mac_ios%20native_platform_view_ui_tests_ios/20834/overview |
This PR tries to re-land the original PR, which was reverted since we found a quick fix. However, hitTest is still important so we should land it. See (go/pv-touch-gesture-blocking-changes-2026 (internal golink)), or the public design doc.
For ease of review, I have split this PR into 2 commits: the 1st commit is the originally landed/reverted PR from last year; the 2nd commit is the changes in 2026 that we'd like to make. The changes are:
hitTestOnlytodoNotBlockGesturepolicyIf you have reviewed the original PR, feel free to only review the 2nd commit.
Next up: I will work on an integration test for drawing website fall-through issue, which will be fixed by this PR. The integration test likely be a 3rd commit in this PR, or a separate PR afterwards (depending on PR review timing)
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.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot 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.