-
Notifications
You must be signed in to change notification settings - Fork 29.8k
[CP-beta][ios][pv] quick fix to enable and re-enable web view's gesture recognizer #179974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CP-beta][ios][pv] quick fix to enable and re-enable web view's gesture recognizer #179974
Conversation
…izer (flutter#179908) This is a quick fix to the web view/admob not tappable issue. It performs DFS on a platform view hierarchy to find a web view. If found, it performs another DFS into the web view to "fix" a gesture recognizer. Warning: This is just a "quick fix" that patches the bug. However, a real solution should rely on overriding the "hitTest" behavior. For example, there's still a existing bug that a drawing website's touch is not completely blocked (see flutter#179916). This can only be fixed by "hitTest". However, "hitTest" approach requires plugin updates and would take much longer time, so we decided to [revert it](flutter#179895). But we should revisit after putting out the fire. flutter#175099 flutter#165787 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [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 [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
|
@hellohuanlin please fill out the PR description above, afterwards the release team will review this request. |
|
This pull request was opened from and to a release candidate branch. This should only be done as part of the official Flutter release process. If you are attempting to make a regular contribution to the Flutter project, please close this PR and follow the instructions at Tree Hygiene for detailed instructions on contributing to Flutter. Reviewers: Use caution before merging pull requests to release branches. Ensure the proper procedure has been followed. |
There was a problem hiding this 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 introduces a workaround for a gesture recognizer issue in WKWebView on specific iOS versions. The fix involves recursively searching for WKWebView instances and toggling an internal gesture recognizer to reset its state. This behavior is controlled by an iOS version check and can be disabled via a new Info.plist flag. The change is well-supported by new, comprehensive tests covering various view hierarchies. My feedback includes suggestions to improve code clarity in the implementation and reduce code duplication in the tests for better maintainability.
| - (void)searchAndFixWebView:(UIView*)view { | ||
| if ([view isKindOfClass:[WKWebView class]]) { | ||
| return [self searchAndFixWebViewGestureRecognzier:view]; | ||
| } else { | ||
| for (UIView* subview in view.subviews) { | ||
| [self searchAndFixWebView:subview]; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For clarity and to avoid relying on a compiler extension, it's better to separate the void method call from the return statement. While return [self ...] is valid in a void method with Clang, it can be confusing for developers unfamiliar with this extension. Separating them makes the control flow more explicit.
- (void)searchAndFixWebView:(UIView*)view {
if ([view isKindOfClass:[WKWebView class]]) {
[self searchAndFixWebViewGestureRecognzier:view];
return;
} else {
for (UIView* subview in view.subviews) {
[self searchAndFixWebView:subview];
}
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops... tho this is just nit, we are fine here. good job gemini.
| // should rely on overriding the hitTest behavior. | ||
| // See: https://github.com/flutter/flutter/issues/179916. | ||
| if (recognizer.enabled && | ||
| [NSStringFromClass([recognizer class]) hasSuffix:@"TouchEventsGestureRecognizer"]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Relying on string comparison against an internal, private class name (WKTouchEventsGestureRecognizer) is fragile. This could break with any future iOS update that changes this internal class name. While the comments acknowledge this is a quick fix, it's important to recognize the potential for future breakage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is intended
| - (void) | ||
| testFlutterPlatformViewBlockGestureUnderEagerPolicyShouldDisableAndReEnableTouchEventsGestureRecognizerForSimpleWebView { | ||
| if (@available(iOS 26.0, *)) { | ||
| flutter::FlutterPlatformViewsTestMockPlatformViewDelegate mock_delegate; | ||
|
|
||
| flutter::TaskRunners runners(/*label=*/self.name.UTF8String, | ||
| /*platform=*/GetDefaultTaskRunner(), | ||
| /*raster=*/GetDefaultTaskRunner(), | ||
| /*ui=*/GetDefaultTaskRunner(), | ||
| /*io=*/GetDefaultTaskRunner()); | ||
| FlutterPlatformViewsController* flutterPlatformViewsController = | ||
| [[FlutterPlatformViewsController alloc] init]; | ||
| flutterPlatformViewsController.taskRunner = GetDefaultTaskRunner(); | ||
| auto platform_view = std::make_unique<flutter::PlatformViewIOS>( | ||
| /*delegate=*/mock_delegate, | ||
| /*rendering_api=*/flutter::IOSRenderingAPI::kMetal, | ||
| /*platform_views_controller=*/flutterPlatformViewsController, | ||
| /*task_runners=*/runners, | ||
| /*worker_task_runner=*/nil, | ||
| /*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>()); | ||
|
|
||
| FlutterPlatformViewsTestMockWebViewFactory* factory = | ||
| [[FlutterPlatformViewsTestMockWebViewFactory alloc] init]; | ||
| [flutterPlatformViewsController | ||
| registerViewFactory:factory | ||
| withId:@"MockWebView" | ||
| gestureRecognizersBlockingPolicy:FlutterPlatformViewGestureRecognizersBlockingPolicyEager]; | ||
| FlutterResult result = ^(id result) { | ||
| }; | ||
| [flutterPlatformViewsController | ||
| onMethodCall:[FlutterMethodCall | ||
| methodCallWithMethodName:@"create" | ||
| arguments:@{@"id" : @2, @"viewType" : @"MockWebView"}] | ||
| result:result]; | ||
|
|
||
| XCTAssertNotNil(gMockPlatformView); | ||
|
|
||
| // Find touch inteceptor view | ||
| UIView* touchInteceptorView = gMockPlatformView; | ||
| while (touchInteceptorView != nil && | ||
| ![touchInteceptorView isKindOfClass:[FlutterTouchInterceptingView class]]) { | ||
| touchInteceptorView = touchInteceptorView.superview; | ||
| } | ||
| XCTAssertNotNil(touchInteceptorView); | ||
|
|
||
| /* | ||
| Simple Web View at root, with [*] indicating views containing | ||
| MockTouchEventsGestureRecognizer. | ||
| Root (Web View) [*] | ||
| ├── Child 1 | ||
| └── Child 2 | ||
| ├── Child 2.1 | ||
| └── Child 2.2 [*] | ||
| */ | ||
|
|
||
| UIView* root = gMockPlatformView; | ||
| root.gestureRecognizers = nil; | ||
| for (UIView* subview in root.subviews) { | ||
| [subview removeFromSuperview]; | ||
| } | ||
|
|
||
| MockGestureRecognizer* normalRecognizer0 = [[MockGestureRecognizer alloc] init]; | ||
| [root addGestureRecognizer:normalRecognizer0]; | ||
|
|
||
| UIView* child1 = [[UIView alloc] init]; | ||
| [root addSubview:child1]; | ||
| MockGestureRecognizer* normalRecognizer1 = [[MockGestureRecognizer alloc] init]; | ||
| [child1 addGestureRecognizer:normalRecognizer1]; | ||
|
|
||
| UIView* child2 = [[UIView alloc] init]; | ||
| [root addSubview:child2]; | ||
| MockGestureRecognizer* normalRecognizer2 = [[MockGestureRecognizer alloc] init]; | ||
| [child2 addGestureRecognizer:normalRecognizer2]; | ||
|
|
||
| UIView* child2_1 = [[UIView alloc] init]; | ||
| [child2 addSubview:child2_1]; | ||
| MockGestureRecognizer* normalRecognizer2_1 = [[MockGestureRecognizer alloc] init]; | ||
| [child2_1 addGestureRecognizer:normalRecognizer2_1]; | ||
|
|
||
| UIView* child2_2 = [[UIView alloc] init]; | ||
| [child2 addSubview:child2_2]; | ||
| MockGestureRecognizer* normalRecognizer2_2 = [[MockGestureRecognizer alloc] init]; | ||
| [child2_2 addGestureRecognizer:normalRecognizer2_2]; | ||
|
|
||
| // Add the target recognizer at root & child2_2. | ||
| MockTouchEventsGestureRecognizer* targetRecognizer0 = | ||
| [[MockTouchEventsGestureRecognizer alloc] init]; | ||
| [root addGestureRecognizer:targetRecognizer0]; | ||
|
|
||
| MockTouchEventsGestureRecognizer* targetRecognizer2_2 = | ||
| [[MockTouchEventsGestureRecognizer alloc] init]; | ||
| [child2_2 addGestureRecognizer:targetRecognizer2_2]; | ||
|
|
||
| [(FlutterTouchInterceptingView*)touchInteceptorView blockGesture]; | ||
|
|
||
| NSArray* normalRecognizers = @[ | ||
| normalRecognizer0, normalRecognizer1, normalRecognizer2, normalRecognizer2_1, | ||
| normalRecognizer2_2 | ||
| ]; | ||
|
|
||
| NSArray* targetRecognizers = @[ targetRecognizer0, targetRecognizer2_2 ]; | ||
|
|
||
| NSArray* expectedEmptyHistory = @[]; | ||
| NSArray* expectedToggledHistory = @[ @NO, @YES ]; | ||
|
|
||
| for (MockGestureRecognizer* recognizer in normalRecognizers) { | ||
| XCTAssertEqualObjects(recognizer.toggleHistory, expectedEmptyHistory); | ||
| } | ||
| for (MockGestureRecognizer* recognizer in targetRecognizers) { | ||
| XCTAssertEqualObjects(recognizer.toggleHistory, expectedToggledHistory); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| - (void) | ||
| testFlutterPlatformViewBlockGestureUnderEagerPolicyShouldDisableAndReEnableTouchEventsGestureRecognizerForMultipleWebViewInDifferentBranches { | ||
| if (@available(iOS 26.0, *)) { | ||
| flutter::FlutterPlatformViewsTestMockPlatformViewDelegate mock_delegate; | ||
|
|
||
| flutter::TaskRunners runners(/*label=*/self.name.UTF8String, | ||
| /*platform=*/GetDefaultTaskRunner(), | ||
| /*raster=*/GetDefaultTaskRunner(), | ||
| /*ui=*/GetDefaultTaskRunner(), | ||
| /*io=*/GetDefaultTaskRunner()); | ||
| FlutterPlatformViewsController* flutterPlatformViewsController = | ||
| [[FlutterPlatformViewsController alloc] init]; | ||
| flutterPlatformViewsController.taskRunner = GetDefaultTaskRunner(); | ||
| auto platform_view = std::make_unique<flutter::PlatformViewIOS>( | ||
| /*delegate=*/mock_delegate, | ||
| /*rendering_api=*/flutter::IOSRenderingAPI::kMetal, | ||
| /*platform_views_controller=*/flutterPlatformViewsController, | ||
| /*task_runners=*/runners, | ||
| /*worker_task_runner=*/nil, | ||
| /*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>()); | ||
|
|
||
| FlutterPlatformViewsTestMockWrapperWebViewFactory* factory = | ||
| [[FlutterPlatformViewsTestMockWrapperWebViewFactory alloc] init]; | ||
| [flutterPlatformViewsController | ||
| registerViewFactory:factory | ||
| withId:@"MockWrapperWebView" | ||
| gestureRecognizersBlockingPolicy:FlutterPlatformViewGestureRecognizersBlockingPolicyEager]; | ||
| FlutterResult result = ^(id result) { | ||
| }; | ||
| [flutterPlatformViewsController | ||
| onMethodCall:[FlutterMethodCall methodCallWithMethodName:@"create" | ||
| arguments:@{ | ||
| @"id" : @2, | ||
| @"viewType" : @"MockWrapperWebView" | ||
| }] | ||
| result:result]; | ||
|
|
||
| XCTAssertNotNil(gMockPlatformView); | ||
|
|
||
| // Find touch inteceptor view | ||
| UIView* touchInteceptorView = gMockPlatformView; | ||
| while (touchInteceptorView != nil && | ||
| ![touchInteceptorView isKindOfClass:[FlutterTouchInterceptingView class]]) { | ||
| touchInteceptorView = touchInteceptorView.superview; | ||
| } | ||
| XCTAssertNotNil(touchInteceptorView); | ||
|
|
||
| /* | ||
| Platform View with Multiple Web Views in different branches, with [*] indicating views | ||
| containing MockTouchEventsGestureRecognizer. | ||
| Root (Platform View) | ||
| ├── Child 1 | ||
| ├── Child 2 (Web View) | ||
| | ├── Child 2.1 | ||
| | └── Child 2.2 [*] | ||
| └── Child 3 | ||
| └── Child 3.1 (Web View) | ||
| ├── Child 3.1.1 | ||
| └── Child 3.1.2 [*] | ||
| */ | ||
|
|
||
| UIView* root = gMockPlatformView; | ||
| for (UIView* subview in root.subviews) { | ||
| [subview removeFromSuperview]; | ||
| } | ||
|
|
||
| MockGestureRecognizer* normalRecognizer0 = [[MockGestureRecognizer alloc] init]; | ||
| [root addGestureRecognizer:normalRecognizer0]; | ||
|
|
||
| UIView* child1 = [[UIView alloc] init]; | ||
| [root addSubview:child1]; | ||
| MockGestureRecognizer* normalRecognizer1 = [[MockGestureRecognizer alloc] init]; | ||
| [child1 addGestureRecognizer:normalRecognizer1]; | ||
|
|
||
| UIView* child2 = [[WKWebView alloc] init]; | ||
| child2.gestureRecognizers = nil; | ||
| for (UIView* subview in child2.subviews) { | ||
| [subview removeFromSuperview]; | ||
| } | ||
| [root addSubview:child2]; | ||
| MockGestureRecognizer* normalRecognizer2 = [[MockGestureRecognizer alloc] init]; | ||
| [child2 addGestureRecognizer:normalRecognizer2]; | ||
|
|
||
| UIView* child2_1 = [[UIView alloc] init]; | ||
| [child2 addSubview:child2_1]; | ||
| MockGestureRecognizer* normalRecognizer2_1 = [[MockGestureRecognizer alloc] init]; | ||
| [child2_1 addGestureRecognizer:normalRecognizer2_1]; | ||
|
|
||
| UIView* child2_2 = [[UIView alloc] init]; | ||
| [child2 addSubview:child2_2]; | ||
| MockGestureRecognizer* normalRecognizer2_2 = [[MockGestureRecognizer alloc] init]; | ||
| [child2_2 addGestureRecognizer:normalRecognizer2_2]; | ||
|
|
||
| UIView* child3 = [[UIView alloc] init]; | ||
| [root addSubview:child3]; | ||
| MockGestureRecognizer* normalRecognizer3 = [[MockGestureRecognizer alloc] init]; | ||
| [child3 addGestureRecognizer:normalRecognizer3]; | ||
|
|
||
| UIView* child3_1 = [[WKWebView alloc] init]; | ||
| child3_1.gestureRecognizers = nil; | ||
| for (UIView* subview in child3_1.subviews) { | ||
| [subview removeFromSuperview]; | ||
| } | ||
| [child3 addSubview:child3_1]; | ||
| MockGestureRecognizer* normalRecognizer3_1 = [[MockGestureRecognizer alloc] init]; | ||
| [child3_1 addGestureRecognizer:normalRecognizer3_1]; | ||
|
|
||
| UIView* child3_1_1 = [[UIView alloc] init]; | ||
| [child3_1 addSubview:child3_1_1]; | ||
| MockGestureRecognizer* normalRecognizer3_1_1 = [[MockGestureRecognizer alloc] init]; | ||
| [child3_1_1 addGestureRecognizer:normalRecognizer3_1_1]; | ||
|
|
||
| UIView* child3_1_2 = [[UIView alloc] init]; | ||
| [child3_1 addSubview:child3_1_2]; | ||
| MockGestureRecognizer* normalRecognizer3_1_2 = [[MockGestureRecognizer alloc] init]; | ||
| [child3_1_2 addGestureRecognizer:normalRecognizer3_1_2]; | ||
|
|
||
| // Add the target recognizer at child2_2 & child3_1_2 | ||
|
|
||
| MockTouchEventsGestureRecognizer* targetRecognizer2_2 = | ||
| [[MockTouchEventsGestureRecognizer alloc] init]; | ||
| [child2_2 addGestureRecognizer:targetRecognizer2_2]; | ||
|
|
||
| MockTouchEventsGestureRecognizer* targetRecognizer3_1_2 = | ||
| [[MockTouchEventsGestureRecognizer alloc] init]; | ||
| [child3_1_2 addGestureRecognizer:targetRecognizer3_1_2]; | ||
|
|
||
| [(FlutterTouchInterceptingView*)touchInteceptorView blockGesture]; | ||
|
|
||
| NSArray* normalRecognizers = @[ | ||
| normalRecognizer0, normalRecognizer1, normalRecognizer2, normalRecognizer2_1, | ||
| normalRecognizer2_2, normalRecognizer3, normalRecognizer3_1, normalRecognizer3_1_1, | ||
| normalRecognizer3_1_2 | ||
| ]; | ||
| NSArray* targetRecognizers = @[ targetRecognizer2_2, targetRecognizer3_1_2 ]; | ||
|
|
||
| NSArray* expectedEmptyHistory = @[]; | ||
| NSArray* expectedToggledHistory = @[ @NO, @YES ]; | ||
|
|
||
| for (MockGestureRecognizer* recognizer in normalRecognizers) { | ||
| XCTAssertEqualObjects(recognizer.toggleHistory, expectedEmptyHistory); | ||
| } | ||
|
|
||
| for (MockGestureRecognizer* recognizer in targetRecognizers) { | ||
| XCTAssertEqualObjects(recognizer.toggleHistory, expectedToggledHistory); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| - (void) | ||
| testFlutterPlatformViewBlockGestureUnderEagerPolicyShouldDisableAndReEnableTouchEventsGestureRecognizerForNestedMultipleWebView { | ||
| if (@available(iOS 26.0, *)) { | ||
| flutter::FlutterPlatformViewsTestMockPlatformViewDelegate mock_delegate; | ||
|
|
||
| flutter::TaskRunners runners(/*label=*/self.name.UTF8String, | ||
| /*platform=*/GetDefaultTaskRunner(), | ||
| /*raster=*/GetDefaultTaskRunner(), | ||
| /*ui=*/GetDefaultTaskRunner(), | ||
| /*io=*/GetDefaultTaskRunner()); | ||
| FlutterPlatformViewsController* flutterPlatformViewsController = | ||
| [[FlutterPlatformViewsController alloc] init]; | ||
| flutterPlatformViewsController.taskRunner = GetDefaultTaskRunner(); | ||
| auto platform_view = std::make_unique<flutter::PlatformViewIOS>( | ||
| /*delegate=*/mock_delegate, | ||
| /*rendering_api=*/flutter::IOSRenderingAPI::kMetal, | ||
| /*platform_views_controller=*/flutterPlatformViewsController, | ||
| /*task_runners=*/runners, | ||
| /*worker_task_runner=*/nil, | ||
| /*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>()); | ||
|
|
||
| FlutterPlatformViewsTestMockWebViewFactory* factory = | ||
| [[FlutterPlatformViewsTestMockWebViewFactory alloc] init]; | ||
| [flutterPlatformViewsController | ||
| registerViewFactory:factory | ||
| withId:@"MockWebView" | ||
| gestureRecognizersBlockingPolicy:FlutterPlatformViewGestureRecognizersBlockingPolicyEager]; | ||
| FlutterResult result = ^(id result) { | ||
| }; | ||
| [flutterPlatformViewsController | ||
| onMethodCall:[FlutterMethodCall | ||
| methodCallWithMethodName:@"create" | ||
| arguments:@{@"id" : @2, @"viewType" : @"MockWebView"}] | ||
| result:result]; | ||
|
|
||
| XCTAssertNotNil(gMockPlatformView); | ||
|
|
||
| // Find touch inteceptor view | ||
| UIView* touchInteceptorView = gMockPlatformView; | ||
| while (touchInteceptorView != nil && | ||
| ![touchInteceptorView isKindOfClass:[FlutterTouchInterceptingView class]]) { | ||
| touchInteceptorView = touchInteceptorView.superview; | ||
| } | ||
| XCTAssertNotNil(touchInteceptorView); | ||
|
|
||
| /* | ||
| Platform View with nested web views, with [*] indicating views containing | ||
| MockTouchEventsGestureRecognizer. | ||
| Root (Web View) | ||
| ├── Child 1 | ||
| ├── Child 2 | ||
| | ├── Child 2.1 | ||
| | └── Child 2.2 [*] | ||
| └── Child 3 | ||
| └── Child 3.1 (Another Web View) | ||
| └── Child 3.1.1 | ||
| └── Child 3.1.2 | ||
| ├── Child 3.1.2.1 | ||
| └── Child 3.1.2.2 [*] | ||
| */ | ||
|
|
||
| UIView* root = gMockPlatformView; | ||
| root.gestureRecognizers = nil; | ||
| for (UIView* subview in root.subviews) { | ||
| [subview removeFromSuperview]; | ||
| } | ||
|
|
||
| MockGestureRecognizer* normalRecognizer0 = [[MockGestureRecognizer alloc] init]; | ||
| [root addGestureRecognizer:normalRecognizer0]; | ||
|
|
||
| UIView* child1 = [[UIView alloc] init]; | ||
| [root addSubview:child1]; | ||
| MockGestureRecognizer* normalRecognizer1 = [[MockGestureRecognizer alloc] init]; | ||
| [child1 addGestureRecognizer:normalRecognizer1]; | ||
|
|
||
| UIView* child2 = [[UIView alloc] init]; | ||
| [root addSubview:child2]; | ||
| MockGestureRecognizer* normalRecognizer2 = [[MockGestureRecognizer alloc] init]; | ||
| [child2 addGestureRecognizer:normalRecognizer2]; | ||
|
|
||
| UIView* child2_1 = [[UIView alloc] init]; | ||
| [child2 addSubview:child2_1]; | ||
| MockGestureRecognizer* normalRecognizer2_1 = [[MockGestureRecognizer alloc] init]; | ||
| [child2_1 addGestureRecognizer:normalRecognizer2_1]; | ||
|
|
||
| UIView* child2_2 = [[UIView alloc] init]; | ||
| [child2 addSubview:child2_2]; | ||
| MockGestureRecognizer* normalRecognizer2_2 = [[MockGestureRecognizer alloc] init]; | ||
| [child2_2 addGestureRecognizer:normalRecognizer2_2]; | ||
|
|
||
| UIView* child3 = [[UIView alloc] init]; | ||
| [root addSubview:child3]; | ||
| MockGestureRecognizer* normalRecognizer3 = [[MockGestureRecognizer alloc] init]; | ||
| [child3 addGestureRecognizer:normalRecognizer3]; | ||
|
|
||
| UIView* child3_1 = [[WKWebView alloc] init]; | ||
| child3_1.gestureRecognizers = nil; | ||
| for (UIView* subview in child3_1.subviews) { | ||
| [subview removeFromSuperview]; | ||
| } | ||
| [child3 addSubview:child3_1]; | ||
| MockGestureRecognizer* normalRecognizer3_1 = [[MockGestureRecognizer alloc] init]; | ||
| [child3_1 addGestureRecognizer:normalRecognizer3_1]; | ||
|
|
||
| UIView* child3_1_1 = [[UIView alloc] init]; | ||
| [child3_1 addSubview:child3_1_1]; | ||
| MockGestureRecognizer* normalRecognizer3_1_1 = [[MockGestureRecognizer alloc] init]; | ||
| [child3_1_1 addGestureRecognizer:normalRecognizer3_1_1]; | ||
|
|
||
| UIView* child3_1_2 = [[UIView alloc] init]; | ||
| [child3_1 addSubview:child3_1_2]; | ||
| MockGestureRecognizer* normalRecognizer3_1_2 = [[MockGestureRecognizer alloc] init]; | ||
| [child3_1_2 addGestureRecognizer:normalRecognizer3_1_2]; | ||
|
|
||
| UIView* child3_1_2_1 = [[UIView alloc] init]; | ||
| [child3_1_2 addSubview:child3_1_2_1]; | ||
| MockGestureRecognizer* normalRecognizer3_1_2_1 = [[MockGestureRecognizer alloc] init]; | ||
| [child3_1_2_1 addGestureRecognizer:normalRecognizer3_1_2_1]; | ||
|
|
||
| UIView* child3_1_2_2 = [[UIView alloc] init]; | ||
| [child3_1_2 addSubview:child3_1_2_2]; | ||
| MockGestureRecognizer* normalRecognizer3_1_2_2 = [[MockGestureRecognizer alloc] init]; | ||
| [child3_1_2_2 addGestureRecognizer:normalRecognizer3_1_2_2]; | ||
|
|
||
| // Add the target recognizer at child2_2 & child3_1_2_2 | ||
|
|
||
| MockTouchEventsGestureRecognizer* targetRecognizer2_2 = | ||
| [[MockTouchEventsGestureRecognizer alloc] init]; | ||
| [child2_2 addGestureRecognizer:targetRecognizer2_2]; | ||
|
|
||
| MockTouchEventsGestureRecognizer* targetRecognizer3_1_2_2 = | ||
| [[MockTouchEventsGestureRecognizer alloc] init]; | ||
| [child3_1_2_2 addGestureRecognizer:targetRecognizer3_1_2_2]; | ||
|
|
||
| [(FlutterTouchInterceptingView*)touchInteceptorView blockGesture]; | ||
|
|
||
| NSArray* normalRecognizers = @[ | ||
| normalRecognizer0, normalRecognizer1, normalRecognizer2, normalRecognizer2_1, | ||
| normalRecognizer2_2, normalRecognizer3, normalRecognizer3_1, normalRecognizer3_1_1, | ||
| normalRecognizer3_1_2, normalRecognizer3_1_2_1, normalRecognizer3_1_2_2 | ||
| ]; | ||
|
|
||
| NSArray* targetRecognizers = @[ targetRecognizer2_2, targetRecognizer3_1_2_2 ]; | ||
|
|
||
| NSArray* expectedEmptyHistory = @[]; | ||
| NSArray* expectedToggledHistory = @[ @NO, @YES ]; | ||
|
|
||
| for (MockGestureRecognizer* recognizer in normalRecognizers) { | ||
| XCTAssertEqualObjects(recognizer.toggleHistory, expectedEmptyHistory); | ||
| } | ||
|
|
||
| for (MockGestureRecognizer* recognizer in targetRecognizers) { | ||
| XCTAssertEqualObjects(recognizer.toggleHistory, expectedToggledHistory); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a significant amount of duplicated boilerplate code across the three new test cases. This includes setting up the FlutterPlatformViewsController, task runners, platform view, and finding the interceptor view. This repetition makes the tests harder to read and maintain.
Consider refactoring the common setup logic into a helper function or a test fixture to reduce duplication. This would make the tests more concise and focused on their specific scenarios.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is following existing convention.
camsim99
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick fix LGTM :) with this landing, I'm gonna get started on the release. Please let me know if there are any outstanding concerns!
9828a8b
into
flutter:flutter-3.40-candidate.0
…sture recognizer (#180522) Stable CP PR: #180522 Beta CP PR: #179974 Original PR: #179908 The "cherry-pick template" linked in https://github.com/flutter/flutter/wiki/Flutter-Cherrypick-Process/e7b042dd481d4ac66477fb281b6e626e8dba8a4e seems to be broken, so I copied the template from previous CP. ### Issue Link: What is the link to the issue this cherry-pick is addressing? #175099 #165787 ### Impact Description: What is the impact (ex. visual jank on Samsung phones, app crash, cannot ship an iOS app)? Does it impact development (ex. flutter doctor crashes when Android Studio is installed), or the shipping of production apps (the app crashes on launch). This information is for domain experts and release engineers to understand the consequences of saying yes or no to the cherry pick. WebViews (including ads) on iOS 26 are unclickable after being scrolled or after a Flutter menu is open and then closed. This is a serious regression that impacts revenue. This impacts all Flutter apps running on iOS 26 that use WebViews. ### Changelog Description: Explain this cherry pick: * In one line that is accessible to most Flutter developers. * That describes the state prior to the fix. * That includes which platforms are impacted. See [best practices](https://github.com/flutter/flutter/blob/main/docs/releases/Hotfix-Documentation-Best-Practices.md) for examples. < Replace with changelog description here > [flutter/165787, flutter/175099] When WebViews are scrolled on iOS 26, they become unclickable. ### Workaround: Is there a workaround for this issue? None ### Risk: What is the risk level of this cherry-pick? ### Test Coverage: Are you confident that your fix is well-tested by automated tests? ### Validation Steps: What are the steps to validate that this fix works? Use sample project from #165787 (comment). Touch and scroll on an ad, then try to click the ad. The ad will be unclickable. #175099 #165787 **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.
This pull request is created by automatic cherry pick workflow
Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request.
Issue Link:
What is the link to the issue this cherry-pick is addressing?
#175099
#165787
Impact Description:
What is the impact (ex. visual jank on Samsung phones, app crash, cannot ship an iOS app)?
Does it impact development (ex. flutter doctor crashes when Android Studio is installed),
or the shipping of production apps (the app crashes on launch).
This information is for domain experts and release engineers to understand the consequences of saying yes or no to the cherry pick.
WebViews (including ads) on iOS 26 are unclickable after being scrolled or after a Flutter menu is open and then closed. This is a serious regression that impacts revenue. This impacts all Flutter apps running on iOS 26 that use WebViews.
Changelog Description:
Explain this cherry pick:
See best practices for examples.
< Replace with changelog description here >
[flutter/165787, flutter/175099] When WebViews are scrolled on iOS 26, they become unclickable.
Workaround:
Is there a workaround for this issue?
None
Risk:
What is the risk level of this cherry-pick?
Test Coverage:
Are you confident that your fix is well-tested by automated tests?
Validation Steps:
What are the steps to validate that this fix works?
Use sample project from #165787 (comment). Touch and scroll on an ad, then try to click the ad. The ad will be unclickable.