From 9a685756f9fbcad779236a8f7ce0133038065432 Mon Sep 17 00:00:00 2001 From: hellohuanlin <41930132+hellohuanlin@users.noreply.github.com> Date: Tue, 15 Oct 2024 17:04:32 -0700 Subject: [PATCH] =?UTF-8?q?Revert=20"[ios][platform=5Fview]=20Fix=20Platfo?= =?UTF-8?q?rm=20view=20gesture=20recognizer=20wit=E2=80=A6=20(flutter/engi?= =?UTF-8?q?ne#55889)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …h iPad pencil getting stuck (#55724)" This reverts commit 21eb44914c22761f3c8bdb39b1d36b2fc15bde3b. Revert since a customer reported the platform view touch is broken after the change. *List which issues are fixed by this PR. You must list at least one issue.* Reopens https://github.com/flutter/engine/pull/55724 *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].* [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style --- .../Source/FlutterPlatformViewsTest.mm | 73 ------------------- .../Source/FlutterPlatformViews_Internal.mm | 8 +- 2 files changed, 4 insertions(+), 77 deletions(-) diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm index 0013657a6a..904a3eace2 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm @@ -2782,79 +2782,6 @@ fml::RefPtr GetDefaultTaskRunner() { flutterPlatformViewsController->Reset(); } -- (void)testFlutterPlatformViewForwardingAndDelayingRecognizerFailureCondition { - flutter::FlutterPlatformViewsTestMockPlatformViewDelegate mock_delegate; - - flutter::TaskRunners runners(/*label=*/self.name.UTF8String, - /*platform=*/GetDefaultTaskRunner(), - /*raster=*/GetDefaultTaskRunner(), - /*ui=*/GetDefaultTaskRunner(), - /*io=*/GetDefaultTaskRunner()); - auto flutterPlatformViewsController = std::make_shared(); - flutterPlatformViewsController->SetTaskRunner(GetDefaultTaskRunner()); - auto platform_view = std::make_unique( - /*delegate=*/mock_delegate, - /*rendering_api=*/mock_delegate.settings_.enable_impeller - ? flutter::IOSRenderingAPI::kMetal - : flutter::IOSRenderingAPI::kSoftware, - /*platform_views_controller=*/flutterPlatformViewsController, - /*task_runners=*/runners, - /*worker_task_runner=*/nil, - /*is_gpu_disabled_jsync_switch=*/std::make_shared()); - - FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; - flutterPlatformViewsController->RegisterViewFactory( - factory, @"MockFlutterPlatformView", - FlutterPlatformViewGestureRecognizersBlockingPolicyEager); - FlutterResult result = ^(id result) { - }; - flutterPlatformViewsController->OnMethodCall( - [FlutterMethodCall - methodCallWithMethodName:@"create" - arguments:@{@"id" : @2, @"viewType" : @"MockFlutterPlatformView"}], - result); - - XCTAssertNotNil(gMockPlatformView); - - // Find touch inteceptor view - UIView* touchInteceptorView = gMockPlatformView; - while (touchInteceptorView != nil && - ![touchInteceptorView isKindOfClass:[FlutterTouchInterceptingView class]]) { - touchInteceptorView = touchInteceptorView.superview; - } - XCTAssertNotNil(touchInteceptorView); - - // Find ForwardGestureRecognizer - UIGestureRecognizer* forwardingGestureRecognizer = nil; - UIGestureRecognizer* delayingGestureRecognizer = nil; - for (UIGestureRecognizer* gestureRecognizer in touchInteceptorView.gestureRecognizers) { - if ([gestureRecognizer isKindOfClass:NSClassFromString(@"ForwardingGestureRecognizer")]) { - forwardingGestureRecognizer = gestureRecognizer; - } - if ([gestureRecognizer isKindOfClass:NSClassFromString(@"FlutterDelayingGestureRecognizer")]) { - delayingGestureRecognizer = gestureRecognizer; - } - } - UIGestureRecognizer* otherGestureRecognizer = OCMClassMock([UIGestureRecognizer class]); - - id flutterViewContoller = OCMClassMock([FlutterViewController class]); - flutterPlatformViewsController->SetFlutterViewController(flutterViewContoller); - - XCTAssertFalse([delayingGestureRecognizer.delegate - gestureRecognizer:delayingGestureRecognizer - shouldBeRequiredToFailByGestureRecognizer:forwardingGestureRecognizer]); - XCTAssertTrue([delayingGestureRecognizer.delegate gestureRecognizer:delayingGestureRecognizer - shouldBeRequiredToFailByGestureRecognizer:otherGestureRecognizer]); - - XCTAssertTrue([delayingGestureRecognizer.delegate gestureRecognizer:delayingGestureRecognizer - shouldRequireFailureOfGestureRecognizer:forwardingGestureRecognizer]); - XCTAssertFalse([delayingGestureRecognizer.delegate gestureRecognizer:delayingGestureRecognizer - shouldRequireFailureOfGestureRecognizer:otherGestureRecognizer]); - - flutterPlatformViewsController->Reset(); -} - - (void)testFlutterPlatformViewControllerSubmitFrameWithoutFlutterViewNotCrashing { flutter::FlutterPlatformViewsTestMockPlatformViewDelegate mock_delegate; diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm index 90c4d42e1d..5e76654bed 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm @@ -654,14 +654,14 @@ static BOOL _preparedOnce = NO; - (BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer*)otherGestureRecognizer { - // The forwarding gesture recognizer should always get all touch events, so it should not - // require other gesture recognizer to fail. - return otherGestureRecognizer != _forwardingRecognizer; + // The forwarding gesture recognizer should always get all touch events, so it should not be + // required to fail by any other gesture recognizer. + return otherGestureRecognizer != _forwardingRecognizer && otherGestureRecognizer != self; } - (BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer shouldRequireFailureOfGestureRecognizer:(UIGestureRecognizer*)otherGestureRecognizer { - return otherGestureRecognizer == _forwardingRecognizer; + return otherGestureRecognizer == self; } - (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {