Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -44573,6 +44573,8 @@ ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatf
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPluginTest.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsController.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsController.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegate.mm + ../../../flutter/LICENSE
Expand Down Expand Up @@ -44634,8 +44636,6 @@ ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/overlay_laye
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/overlay_layer_pool.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/platform_message_response_darwin.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/platform_message_response_darwin.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/platform_views_controller.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/platform_views_controller.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/profiler_metrics_ios.h + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/profiler_metrics_ios.mm + ../../../flutter/LICENSE
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.h + ../../../flutter/LICENSE
Expand Down Expand Up @@ -47518,6 +47518,8 @@ FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatfor
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPluginTest.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsController.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsController.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegate.mm
Expand Down Expand Up @@ -47579,8 +47581,6 @@ FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/overlay_layer_
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/overlay_layer_pool.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/platform_message_response_darwin.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/platform_message_response_darwin.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/platform_views_controller.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/platform_views_controller.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/profiler_metrics_ios.h
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/profiler_metrics_ios.mm
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.h
Expand Down
4 changes: 2 additions & 2 deletions shell/platform/darwin/ios/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ source_set("flutter_framework_source") {
"framework/Source/FlutterPlatformPlugin.h",
"framework/Source/FlutterPlatformPlugin.mm",
"framework/Source/FlutterPlatformViews.mm",
"framework/Source/FlutterPlatformViewsController.h",
"framework/Source/FlutterPlatformViewsController.mm",
"framework/Source/FlutterPlatformViews_Internal.h",
"framework/Source/FlutterPluginAppLifeCycleDelegate.mm",
"framework/Source/FlutterRestorationPlugin.h",
Expand Down Expand Up @@ -120,8 +122,6 @@ source_set("flutter_framework_source") {
"framework/Source/overlay_layer_pool.mm",
"framework/Source/platform_message_response_darwin.h",
"framework/Source/platform_message_response_darwin.mm",
"framework/Source/platform_views_controller.h",
"framework/Source/platform_views_controller.mm",
"framework/Source/profiler_metrics_ios.h",
"framework/Source/profiler_metrics_ios.mm",
"framework/Source/vsync_waiter_ios.h",
Expand Down
39 changes: 18 additions & 21 deletions shell/platform/darwin/ios/framework/Source/FlutterEngine.mm
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ @interface FlutterEngine () <FlutterIndirectScribbleDelegate,
@property(nonatomic, readonly, assign) BOOL allowHeadlessExecution;
@property(nonatomic, readonly, assign) BOOL restorationEnabled;

@property(nonatomic, strong) FlutterPlatformViewsController* platformViewsController;

// Maintains a dictionary of plugin names that have registered with the engine. Used by
// FlutterEngineRegistrar to implement a FlutterPluginRegistrar.
@property(nonatomic, readonly) NSMutableDictionary* pluginPublications;
Expand Down Expand Up @@ -150,7 +152,6 @@ @implementation FlutterEngine {
std::shared_ptr<flutter::ThreadHost> _threadHost;
std::unique_ptr<flutter::Shell> _shell;

std::shared_ptr<flutter::PlatformViewsController> _platformViewsController;
flutter::IOSRenderingAPI _renderingApi;
std::shared_ptr<flutter::SamplingProfiler> _profiler;

Expand Down Expand Up @@ -211,7 +212,7 @@ - (instancetype)initWithName:(NSString*)labelPrefix

_pluginPublications = [[NSMutableDictionary alloc] init];
_registrars = [[NSMutableDictionary alloc] init];
[self recreatePlatformViewController];
[self recreatePlatformViewsController];
_binaryMessenger = [[FlutterBinaryMessengerRelay alloc] initWithParent:self];
_textureRegistry = [[FlutterTextureRegistryRelay alloc] initWithParent:self];
_connections.reset(new flutter::ConnectionCollection());
Expand Down Expand Up @@ -262,9 +263,9 @@ - (void)setUpApplicationLifecycleNotifications:(NSNotificationCenter*)center {
object:nil];
}

- (void)recreatePlatformViewController {
- (void)recreatePlatformViewsController {
_renderingApi = flutter::GetRenderingAPIForProcess(FlutterView.forceSoftwareRendering);
_platformViewsController.reset(new flutter::PlatformViewsController());
_platformViewsController = [[FlutterPlatformViewsController alloc] init];
}

- (flutter::IOSRenderingAPI)platformViewsRenderingAPI {
Expand Down Expand Up @@ -452,11 +453,7 @@ - (void)destroyContext {
_shell.reset();
_profiler.reset();
_threadHost.reset();
_platformViewsController.reset();
}

- (std::shared_ptr<flutter::PlatformViewsController>&)platformViewsController {
return _platformViewsController;
_platformViewsController = nil;
}

- (NSURL*)observatoryUrl {
Expand Down Expand Up @@ -635,7 +632,7 @@ - (void)maybeSetupPlatformViewChannels {
[self.platformViewsChannel
setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
if (weakSelf) {
weakSelf.platformViewsController->OnMethodCall(call, result);
[weakSelf.platformViewsController onMethodCall:call result:result];
}
}];

Expand Down Expand Up @@ -777,11 +774,11 @@ - (BOOL)createShell:(NSString*)entrypoint
if (!strongSelf) {
return std::unique_ptr<flutter::PlatformViewIOS>();
}
[strongSelf recreatePlatformViewController];
strongSelf->_platformViewsController->SetTaskRunner(
shell.GetTaskRunners().GetPlatformTaskRunner());
[strongSelf recreatePlatformViewsController];
strongSelf.platformViewsController.taskRunner =
shell.GetTaskRunners().GetPlatformTaskRunner();
return std::make_unique<flutter::PlatformViewIOS>(
shell, strongSelf->_renderingApi, strongSelf->_platformViewsController,
shell, strongSelf->_renderingApi, strongSelf.platformViewsController,
shell.GetTaskRunners(), shell.GetConcurrentWorkerTaskRunner(),
shell.GetIsGpuDisabledSyncSwitch());
};
Expand Down Expand Up @@ -1103,7 +1100,7 @@ - (void)flutterTextInputView:(FlutterTextInputView*)textInputView
// Have to check in the next run loop, because iOS requests the previous first responder to
// resign before requesting the next view to become first responder.
dispatch_async(dispatch_get_main_queue(), ^(void) {
long platform_view_id = self.platformViewsController->FindFirstResponderPlatformViewId();
long platform_view_id = [self.platformViewsController firstResponderPlatformViewId];
if (platform_view_id == -1) {
return;
}
Expand Down Expand Up @@ -1400,11 +1397,10 @@ - (FlutterEngine*)spawnWithEntrypoint:(/*nullable*/ NSString*)entrypoint
// create call is synchronous.
flutter::Shell::CreateCallback<flutter::PlatformView> on_create_platform_view =
[result, context](flutter::Shell& shell) {
[result recreatePlatformViewController];
result->_platformViewsController->SetTaskRunner(
shell.GetTaskRunners().GetPlatformTaskRunner());
[result recreatePlatformViewsController];
result.platformViewsController.taskRunner = shell.GetTaskRunners().GetPlatformTaskRunner();
return std::make_unique<flutter::PlatformViewIOS>(
shell, context, result->_platformViewsController, shell.GetTaskRunners());
shell, context, result.platformViewsController, shell.GetTaskRunners());
};

flutter::Shell::CreateCallback<flutter::Rasterizer> on_create_rasterizer =
Expand Down Expand Up @@ -1499,8 +1495,9 @@ - (void)registerViewFactory:(NSObject<FlutterPlatformViewFactory>*)factory
withId:(NSString*)factoryId
gestureRecognizersBlockingPolicy:
(FlutterPlatformViewGestureRecognizersBlockingPolicy)gestureRecognizersBlockingPolicy {
[_flutterEngine platformViewsController]->RegisterViewFactory(factory, factoryId,
gestureRecognizersBlockingPolicy);
[_flutterEngine.platformViewsController registerViewFactory:factory
withId:factoryId
gestureRecognizersBlockingPolicy:gestureRecognizersBlockingPolicy];
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ NS_ASSUME_NONNULL_BEGIN
base64Encode:(bool)base64Encode;

- (FlutterPlatformPlugin*)platformPlugin;
- (std::shared_ptr<flutter::PlatformViewsController>&)platformViewsController;
- (FlutterTextInputPlugin*)textInputPlugin;
- (FlutterRestorationPlugin*)restorationPlugin;
- (void)launchEngine:(nullable NSString*)entrypoint
Expand Down Expand Up @@ -81,6 +80,7 @@ NS_ASSUME_NONNULL_BEGIN
userData:(nullable void*)userData;

@property(nonatomic, readonly) FlutterDartProject* project;

@end

NS_ASSUME_NONNULL_END
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,7 @@ @interface FlutterTouchInterceptingView ()

@implementation FlutterTouchInterceptingView
- (instancetype)initWithEmbeddedView:(UIView*)embeddedView
platformViewsController:
(fml::WeakPtr<flutter::PlatformViewsController>)platformViewsController
platformViewsController:(FlutterPlatformViewsController*)platformViewsController
gestureRecognizersBlockingPolicy:
(FlutterPlatformViewGestureRecognizersBlockingPolicy)blockingPolicy {
self = [super initWithFrame:embeddedView.frame];
Expand Down Expand Up @@ -667,7 +666,7 @@ @implementation ForwardingGestureRecognizer {
// outlives the FlutterViewController. And ForwardingGestureRecognizer is owned by a subview of
// FlutterView, so the ForwardingGestureRecognizer never out lives FlutterViewController.
// Therefore, `_platformViewsController` should never be nullptr.
fml::WeakPtr<flutter::PlatformViewsController> _platformViewsController;
__weak FlutterPlatformViewsController* _platformViewsController;
// Counting the pointers that has started in one touch sequence.
NSInteger _currentTouchPointersCount;
// We can't dispatch events to the framework without this back pointer.
Expand All @@ -678,21 +677,20 @@ @implementation ForwardingGestureRecognizer {
}

- (instancetype)initWithTarget:(id)target
platformViewsController:
(fml::WeakPtr<flutter::PlatformViewsController>)platformViewsController {
platformViewsController:(FlutterPlatformViewsController*)platformViewsController {
self = [super initWithTarget:target action:nil];
if (self) {
self.delegate = self;
FML_DCHECK(platformViewsController.get() != nullptr);
_platformViewsController = std::move(platformViewsController);
FML_DCHECK(platformViewsController);
_platformViewsController = platformViewsController;
_currentTouchPointersCount = 0;
}
return self;
}

- (ForwardingGestureRecognizer*)recreateRecognizerWithTarget:(id)target {
return [[ForwardingGestureRecognizer alloc] initWithTarget:target
platformViewsController:std::move(_platformViewsController)];
platformViewsController:_platformViewsController];
}

- (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
Expand All @@ -701,7 +699,7 @@ - (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
// At the start of each gesture sequence, we reset the `_flutterViewController`,
// so that all the touch events in the same sequence are forwarded to the same
// `_flutterViewController`.
_flutterViewController = _platformViewsController->GetFlutterViewController();
_flutterViewController = _platformViewsController.flutterViewController;
}
[_flutterViewController touchesBegan:touches withEvent:event];
_currentTouchPointersCount += touches.count;
Expand Down
Loading