diff --git a/engine/flutter/common/settings.h b/engine/flutter/common/settings.h index 37b199bbaedae178b73aecf611e1f6d48616e6e8..18360c6698cf1c45b5e4ee40d90ec258218b6cc9 100644 --- a/engine/flutter/common/settings.h +++ b/engine/flutter/common/settings.h @@ -22,6 +22,7 @@ namespace flutter { enum class AcePlatform : int32_t { ACE_PLATFORM_INVALID = -1, ACE_PLATFORM_ANDROID, + ACE_PLATFORM_IOS, ACE_PLATFORM_OHOS, }; diff --git a/engine/flutter/shell/common/switches.cc b/engine/flutter/shell/common/switches.cc index dfea70a0eae29a7e7a9991b9618947e5f7d273ae..a0ea6d97be5a61682c34e43eae1c83e279f5eba1 100644 --- a/engine/flutter/shell/common/switches.cc +++ b/engine/flutter/shell/common/switches.cc @@ -199,59 +199,9 @@ std::unique_ptr GetSymbolMapping(std::string symbol_prefix, Settings SettingsFromCommandLine(const fml::CommandLine& command_line) { Settings settings = {}; - // Enable Observatory - settings.enable_observatory = - !command_line.HasOption(FlagForSwitch(Switch::DisableObservatory)); - - // Set Observatory Host - if (command_line.HasOption(FlagForSwitch(Switch::DeviceObservatoryHost))) { - command_line.GetOptionValue(FlagForSwitch(Switch::DeviceObservatoryHost), - &settings.observatory_host); - } - // Default the observatory port based on --ipv6 if not set. - if (settings.observatory_host.empty()) { - settings.observatory_host = - command_line.HasOption(FlagForSwitch(Switch::IPv6)) ? "::1" - : "127.0.0.1"; - } - - // Set Observatory Port - if (command_line.HasOption(FlagForSwitch(Switch::DeviceObservatoryPort))) { - if (!GetSwitchValue(command_line, Switch::DeviceObservatoryPort, - &settings.observatory_port)) { - FML_LOG(INFO) - << "Observatory port specified was malformed. Will default to " - << settings.observatory_port; - } - } - - // Disable need for authentication codes for VM service communication, if - // specified. - settings.disable_service_auth_codes = - command_line.HasOption(FlagForSwitch(Switch::DisableServiceAuthCodes)); - - // Checked mode overrides. - settings.disable_dart_asserts = - command_line.HasOption(FlagForSwitch(Switch::DisableDartAsserts)); - - settings.start_paused = - command_line.HasOption(FlagForSwitch(Switch::StartPaused)); - - settings.enable_checked_mode = - command_line.HasOption(FlagForSwitch(Switch::EnableCheckedMode)); - - settings.enable_dart_profiling = - command_line.HasOption(FlagForSwitch(Switch::EnableDartProfiling)); - settings.enable_software_rendering = command_line.HasOption(FlagForSwitch(Switch::EnableSoftwareRendering)); - settings.endless_trace_buffer = - command_line.HasOption(FlagForSwitch(Switch::EndlessTraceBuffer)); - - settings.trace_startup = - command_line.HasOption(FlagForSwitch(Switch::TraceStartup)); - settings.skia_deterministic_rendering_on_cpu = command_line.HasOption(FlagForSwitch(Switch::SkiaDeterministicRendering)); @@ -285,24 +235,6 @@ Settings SettingsFromCommandLine(const fml::CommandLine& command_line) { FlagForSwitch(Switch::IsolateSnapshotInstructions), &isolate_snapshot_instr_filename); - if (aot_shared_library_name.size() > 0) { - for (std::string_view name : aot_shared_library_name) { - settings.application_library_path.emplace_back(name); - } - } else if (snapshot_asset_path.size() > 0) { - settings.vm_snapshot_data_path = - fml::paths::JoinPaths({snapshot_asset_path, vm_snapshot_data_filename}); - settings.vm_snapshot_instr_path = fml::paths::JoinPaths( - {snapshot_asset_path, vm_snapshot_instr_filename}); - settings.isolate_snapshot_data_path = fml::paths::JoinPaths( - {snapshot_asset_path, isolate_snapshot_data_filename}); - settings.isolate_snapshot_instr_path = fml::paths::JoinPaths( - {snapshot_asset_path, isolate_snapshot_instr_filename}); - } - - command_line.GetOptionValue(FlagForSwitch(Switch::CacheDirPath), - &settings.temp_directory_path); - if (settings.icu_initialization_required) { command_line.GetOptionValue(FlagForSwitch(Switch::ICUDataFilePath), &settings.icu_data_path); @@ -326,32 +258,6 @@ Settings SettingsFromCommandLine(const fml::CommandLine& command_line) { settings.use_test_fonts = command_line.HasOption(FlagForSwitch(Switch::UseTestFonts)); -#if FLUTTER_RUNTIME_MODE != FLUTTER_RUNTIME_MODE_RELEASE - command_line.GetOptionValue(FlagForSwitch(Switch::LogTag), &settings.log_tag); - std::string all_dart_flags; - if (command_line.GetOptionValue(FlagForSwitch(Switch::DartFlags), - &all_dart_flags)) { - std::stringstream stream(all_dart_flags); - std::string flag; - - // Assume that individual flags are comma separated. - while (std::getline(stream, flag, ',')) { - if (!IsWhitelistedDartVMFlag(flag)) { - FML_LOG(FATAL) << "Encountered blacklisted Dart VM flag: " << flag; - } - settings.dart_flags.push_back(flag); - } - } - - settings.trace_skia = - command_line.HasOption(FlagForSwitch(Switch::TraceSkia)); - settings.trace_systrace = - command_line.HasOption(FlagForSwitch(Switch::TraceSystrace)); -#endif - - settings.dump_skp_on_shader_compilation = - command_line.HasOption(FlagForSwitch(Switch::DumpSkpOnShaderCompilation)); - return settings; } diff --git a/engine/flutter/shell/platform/darwin/ios/framework/Headers/Flutter.h b/engine/flutter/shell/platform/darwin/ios/framework/Headers/Flutter.h index 9135c8200603c6526aa1efae026e9fc9a7c04b2c..bdd23c35590caccb46f1590ff7dc8aa1fe09074a 100644 --- a/engine/flutter/shell/platform/darwin/ios/framework/Headers/Flutter.h +++ b/engine/flutter/shell/platform/darwin/ios/framework/Headers/Flutter.h @@ -53,7 +53,6 @@ #include "FlutterAppDelegate.h" #include "FlutterBinaryMessenger.h" -#include "FlutterCallbackCache.h" #include "FlutterChannels.h" #include "FlutterCodecs.h" #include "FlutterDartProject.h" diff --git a/engine/flutter/shell/platform/darwin/ios/framework/Headers/FlutterEngine.h b/engine/flutter/shell/platform/darwin/ios/framework/Headers/FlutterEngine.h index c65bef707b78c548036c09be525390103f20854a..bd243e52a451ef203cb236fa9232316962f814a7 100644 --- a/engine/flutter/shell/platform/darwin/ios/framework/Headers/FlutterEngine.h +++ b/engine/flutter/shell/platform/darwin/ios/framework/Headers/FlutterEngine.h @@ -8,8 +8,6 @@ #import #import -#include "FlutterBinaryMessenger.h" -#include "FlutterDartProject.h" #include "FlutterMacros.h" #include "FlutterPlugin.h" #include "FlutterTexture.h" @@ -58,7 +56,7 @@ FLUTTER_EXPORT * the threads used by this FlutterEngine. * @param projectOrNil The `FlutterDartProject` to run. */ -- (instancetype)initWithName:(NSString*)labelPrefix project:(FlutterDartProject*)projectOrNil; +- (instancetype)initWithName:(NSString*)labelPrefix; /** * Initialize this FlutterEngine with a `FlutterDartProject`. @@ -78,7 +76,6 @@ FLUTTER_EXPORT * running after passing a nil `FlutterViewController` to `-setViewController:`. */ - (instancetype)initWithName:(NSString*)labelPrefix - project:(FlutterDartProject*)projectOrNil allowHeadlessExecution:(BOOL)allowHeadlessExecution NS_DESIGNATED_INITIALIZER; /** @@ -156,7 +153,7 @@ FLUTTER_EXPORT * update. This will asynchronously fire after a semantics tree has actually * built (which may be some time after the frame has been rendered). */ -- (void)ensureSemanticsEnabled; + /** * Sets the `FlutterViewController` for this instance. The FlutterEngine must be diff --git a/engine/flutter/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h b/engine/flutter/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h index ddbb87aa62e1429447baca851e4f79c7fab8745e..b655fc7474fb16907a2cd1a77b7a43fc035c961f 100644 --- a/engine/flutter/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h +++ b/engine/flutter/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h @@ -8,8 +8,6 @@ #import #include -#include "FlutterBinaryMessenger.h" -#include "FlutterDartProject.h" #include "FlutterEngine.h" #include "FlutterMacros.h" #include "FlutterPlugin.h" @@ -66,8 +64,7 @@ FLUTTER_EXPORT * @param nibNameOrNil The NIB name to initialize this UIViewController with. * @param nibBundleOrNil The NIB bundle. */ -- (instancetype)initWithProject:(FlutterDartProject*)projectOrNil - nibName:(NSString*)nibNameOrNil +- (instancetype)initWithName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil NS_DESIGNATED_INITIALIZER; - (void)handleStatusBarTouches:(UIEvent*)event; diff --git a/engine/flutter/shell/platform/darwin/ios/framework/Source/FlutterCallbackCache.mm b/engine/flutter/shell/platform/darwin/ios/framework/Source/FlutterCallbackCache.mm index 4e97b4e6d1d1f5c1681a332af3282a59612db828..e719e062b9d6fa3930112dbfb49ed1188b466c69 100644 --- a/engine/flutter/shell/platform/darwin/ios/framework/Source/FlutterCallbackCache.mm +++ b/engine/flutter/shell/platform/darwin/ios/framework/Source/FlutterCallbackCache.mm @@ -4,8 +4,6 @@ #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterCallbackCache_Internal.h" -#include "flutter/lib/ui/plugins/callback_cache.h" - @implementation FlutterCallbackInformation @end diff --git a/engine/flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm b/engine/flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm index 279a3249c5eb4a76580bcb3d82b01ca5cd392aef..2910060b75062685f9fe179adf3ea88096bfbb5a 100644 --- a/engine/flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm +++ b/engine/flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm @@ -9,7 +9,6 @@ #include "flutter/common/task_runners.h" #include "flutter/fml/message_loop.h" #include "flutter/fml/platform/darwin/scoped_nsobject.h" -#include "flutter/runtime/dart_vm.h" #include "flutter/shell/common/shell.h" #include "flutter/shell/common/switches.h" #include "flutter/shell/platform/darwin/common/command_line.h" @@ -66,41 +65,6 @@ static flutter::Settings DefaultSettingsForProcess(NSBundle* bundle = nil) { } } - if (flutter::DartVM::IsRunningPrecompiledCode()) { - if (hasExplicitBundle) { - NSString* executablePath = bundle.executablePath; - if ([[NSFileManager defaultManager] fileExistsAtPath:executablePath]) { - settings.application_library_path.push_back(executablePath.UTF8String); - } - } - - // No application bundle specified. Try a known location from the main bundle's Info.plist. - if (settings.application_library_path.size() == 0) { - NSString* libraryName = [mainBundle objectForInfoDictionaryKey:@"FLTLibraryPath"]; - NSString* libraryPath = [mainBundle pathForResource:libraryName ofType:@""]; - if (libraryPath.length > 0) { - NSString* executablePath = [NSBundle bundleWithPath:libraryPath].executablePath; - if (executablePath.length > 0) { - settings.application_library_path.push_back(executablePath.UTF8String); - } - } - } - - // In case the application bundle is still not specified, look for the App.framework in the - // Frameworks directory. - if (settings.application_library_path.size() == 0) { - NSString* applicationFrameworkPath = [mainBundle pathForResource:@"Frameworks/App.framework" - ofType:@""]; - if (applicationFrameworkPath.length > 0) { - NSString* executablePath = - [NSBundle bundleWithPath:applicationFrameworkPath].executablePath; - if (executablePath.length > 0) { - settings.application_library_path.push_back(executablePath.UTF8String); - } - } - } - } - // Checks to see if the flutter assets directory is already present. if (settings.assets_path.size() == 0) { NSString* assetsName = [FlutterDartProject flutterAssetsName:bundle]; @@ -114,20 +78,6 @@ static flutter::Settings DefaultSettingsForProcess(NSBundle* bundle = nil) { NSLog(@"Failed to find assets path for \"%@\"", assetsName); } else { settings.assets_path = assetsPath.UTF8String; - - // Check if there is an application kernel snapshot in the assets directory we could - // potentially use. Looking for the snapshot makes sense only if we have a VM that can use - // it. - if (!flutter::DartVM::IsRunningPrecompiledCode()) { - NSURL* applicationKernelSnapshotURL = - [NSURL URLWithString:@(kApplicationKernelSnapshotFileName) - relativeToURL:[NSURL fileURLWithPath:assetsPath]]; - if ([[NSFileManager defaultManager] fileExistsAtPath:applicationKernelSnapshotURL.path]) { - settings.application_kernel_asset = applicationKernelSnapshotURL.path.UTF8String; - } else { - NSLog(@"Failed to find snapshot: %@", applicationKernelSnapshotURL.path); - } - } } } @@ -185,14 +135,7 @@ static flutter::Settings DefaultSettingsForProcess(NSBundle* bundle = nil) { - (flutter::RunConfiguration)runConfigurationForEntrypoint:(NSString*)entrypointOrNil libraryOrNil:(NSString*)dartLibraryOrNil { - auto config = flutter::RunConfiguration::InferFromSettings(_settings); - if (dartLibraryOrNil && entrypointOrNil) { - config.SetEntrypointAndLibrary(std::string([entrypointOrNil UTF8String]), - std::string([dartLibraryOrNil UTF8String])); - - } else if (entrypointOrNil) { - config.SetEntrypoint(std::string([entrypointOrNil UTF8String])); - } + flutter::RunConfiguration config; return config; } diff --git a/engine/flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm b/engine/flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm index ad7cfc263ee5d70d42632f3013e2031a4e520b15..c54d6818fd01db76370a0bc4e808cbdb7739f4e3 100644 --- a/engine/flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm +++ b/engine/flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm @@ -18,8 +18,6 @@ #include "flutter/shell/common/thread_host.h" #include "flutter/shell/platform/darwin/common/command_line.h" #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterBinaryMessengerRelay.h" -#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h" -#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterObservatoryPublisher.h" #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.h" #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h" #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h" @@ -40,14 +38,12 @@ @end @implementation FlutterEngine { - fml::scoped_nsobject _dartProject; flutter::ThreadHost _threadHost; std::unique_ptr _shell; NSString* _labelPrefix; std::unique_ptr> _weakFactory; fml::WeakPtr _viewController; - fml::scoped_nsobject _publisher; std::unique_ptr _platformViewsController; @@ -69,12 +65,11 @@ FlutterBinaryMessengerRelay* _binaryMessenger; } -- (instancetype)initWithName:(NSString*)labelPrefix project:(FlutterDartProject*)projectOrNil { - return [self initWithName:labelPrefix project:projectOrNil allowHeadlessExecution:YES]; +- (instancetype)initWithName:(NSString*)labelPrefix { + return [self initWithName:labelPrefix allowHeadlessExecution:YES]; } - (instancetype)initWithName:(NSString*)labelPrefix - project:(FlutterDartProject*)projectOrNil allowHeadlessExecution:(BOOL)allowHeadlessExecution { self = [super init]; NSAssert(self, @"Super init cannot be nil"); @@ -85,11 +80,6 @@ _weakFactory = std::make_unique>(self); - if (projectOrNil == nil) - _dartProject.reset([[FlutterDartProject alloc] init]); - else - _dartProject.reset([projectOrNil retain]); - _pluginPublications = [NSMutableDictionary new]; _platformViewsController.reset(new flutter::FlutterPlatformViewsController()); @@ -159,10 +149,6 @@ return _shell->GetTaskRunners().GetGPUTaskRunner(); } -- (void)ensureSemanticsEnabled { - self.iosPlatformView->SetSemanticsEnabled(true); -} - - (void)setViewController:(FlutterViewController*)viewController { FML_DCHECK(self.iosPlatformView); _viewController = [viewController getWeakPtr]; @@ -223,7 +209,7 @@ } - (NSURL*)observatoryUrl { - return [_publisher.get() url]; + return nil; } - (void)resetChannels { @@ -240,59 +226,9 @@ // If you add a channel, be sure to also update `resetChannels`. // Channels get a reference to the engine, and therefore need manual // cleanup for proper collection. -- (void)setupChannels { - // This will be invoked once the shell is done setting up and the isolate ID - // for the UI isolate is available. - [_binaryMessenger setMessageHandlerOnChannel:@"flutter/isolate" - binaryMessageHandler:^(NSData* message, FlutterBinaryReply reply) { - self.isolateId = [[FlutterStringCodec sharedInstance] decode:message]; - }]; - - _localizationChannel.reset([[FlutterMethodChannel alloc] - initWithName:@"flutter/localization" - binaryMessenger:self.binaryMessenger - codec:[FlutterJSONMethodCodec sharedInstance]]); - - _navigationChannel.reset([[FlutterMethodChannel alloc] - initWithName:@"flutter/navigation" - binaryMessenger:self.binaryMessenger - codec:[FlutterJSONMethodCodec sharedInstance]]); - - _platformChannel.reset([[FlutterMethodChannel alloc] - initWithName:@"flutter/platform" - binaryMessenger:self.binaryMessenger - codec:[FlutterJSONMethodCodec sharedInstance]]); - - _platformViewsChannel.reset([[FlutterMethodChannel alloc] - initWithName:@"flutter/platform_views" - binaryMessenger:self.binaryMessenger - codec:[FlutterStandardMethodCodec sharedInstance]]); - - _textInputChannel.reset([[FlutterMethodChannel alloc] - initWithName:@"flutter/textinput" - binaryMessenger:self.binaryMessenger - codec:[FlutterJSONMethodCodec sharedInstance]]); - - _lifecycleChannel.reset([[FlutterBasicMessageChannel alloc] - initWithName:@"flutter/lifecycle" - binaryMessenger:self.binaryMessenger - codec:[FlutterStringCodec sharedInstance]]); - - _systemChannel.reset([[FlutterBasicMessageChannel alloc] - initWithName:@"flutter/system" - binaryMessenger:self.binaryMessenger - codec:[FlutterJSONMessageCodec sharedInstance]]); - - _settingsChannel.reset([[FlutterBasicMessageChannel alloc] - initWithName:@"flutter/settings" - binaryMessenger:self.binaryMessenger - codec:[FlutterJSONMessageCodec sharedInstance]]); - - _textInputPlugin.reset([[FlutterTextInputPlugin alloc] init]); - _textInputPlugin.get().textInputDelegate = self; - - _platformPlugin.reset([[FlutterPlatformPlugin alloc] initWithEngine:[self getWeakPtr]]); -} + - (void)setupChannels { + + } - (void)maybeSetupPlatformViewChannels { if (_shell && self.shell.IsSetup()) { @@ -308,7 +244,6 @@ [_textInputChannel.get() setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) { [_textInputPlugin.get() handleMethodCall:call result:result]; }]; - self.iosPlatformView->SetTextInputPlugin(_textInputPlugin); } } @@ -318,9 +253,7 @@ } - (void)launchEngine:(NSString*)entrypoint libraryURI:(NSString*)libraryOrNil { - // Launch the Dart application with the inferred run configuration. - self.shell.RunEngine([_dartProject.get() runConfigurationForEntrypoint:entrypoint - libraryOrNil:libraryOrNil]); + } - (BOOL)createShell:(NSString*)entrypoint libraryURI:(NSString*)libraryURI { @@ -331,18 +264,15 @@ static size_t shellCount = 1; - auto settings = [_dartProject.get() settings]; + flutter::Settings settings = {};;// = [_dartProject.get() settings]; if (libraryURI) { FML_DCHECK(entrypoint) << "Must specify entrypoint if specifying library"; - settings.advisory_script_entrypoint = entrypoint.UTF8String; - settings.advisory_script_uri = libraryURI.UTF8String; + settings.assets_path = entrypoint.UTF8String; } else if (entrypoint) { - settings.advisory_script_entrypoint = entrypoint.UTF8String; - settings.advisory_script_uri = std::string("main.dart"); + settings.assets_path = entrypoint.UTF8String; } else { - settings.advisory_script_entrypoint = std::string("main"); - settings.advisory_script_uri = std::string("main.dart"); + settings.assets_path = std::string("main"); } const auto threadLabel = [NSString stringWithFormat:@"%@.%zu", _labelPrefix, shellCount++]; @@ -412,7 +342,7 @@ if (!_platformViewsController) { _platformViewsController.reset(new flutter::FlutterPlatformViewsController()); } - _publisher.reset([[FlutterObservatoryPublisher alloc] init]); + [self maybeSetupPlatformViewChannels]; } @@ -563,11 +493,11 @@ } - (NSString*)lookupKeyForAsset:(NSString*)asset { - return [FlutterDartProject lookupKeyForAsset:asset]; + return nil; } - (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package { - return [FlutterDartProject lookupKeyForAsset:asset fromPackage:package]; + return nil; } - (id)pluginRegistry { diff --git a/engine/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm b/engine/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm index 4fa0d46942854dc6e5e1d270ce3815274eec1121..62b37ae2bd45508beefd26ee5069557ab336fa9c 100644 --- a/engine/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm +++ b/engine/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm @@ -87,7 +87,7 @@ using namespace flutter; [self setClipboardData:args]; result(nil); } else { - result(FlutterMethodNotImplemented); + result(nil); } } diff --git a/engine/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm b/engine/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm index 5bb5b411ef7be559340064a96c18e9a6b6df03dc..dcdac0c6c842f9b00bea0d56fb5c2c301fea7868 100644 --- a/engine/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm +++ b/engine/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm @@ -37,18 +37,11 @@ void FlutterPlatformViewsController::OnMethodCall(FlutterMethodCall* call, Flutt } else if ([[call method] isEqualToString:@"rejectGesture"]) { OnRejectGesture(call, result); } else { - result(FlutterMethodNotImplemented); } } void FlutterPlatformViewsController::OnCreate(FlutterMethodCall* call, FlutterResult& result) { if (!flutter_view_.get()) { - // Right now we assume we have a reference to FlutterView when creating a new view. - // TODO(amirh): support this by setting the reference to FlutterView when it becomes available. - // https://github.com/flutter/flutter/issues/23787 - result([FlutterError errorWithCode:@"create_failed" - message:@"can't create a view on a headless engine" - details:nil]); return; } NSDictionary* args = [call arguments]; @@ -56,18 +49,8 @@ void FlutterPlatformViewsController::OnCreate(FlutterMethodCall* call, FlutterRe long viewId = [args[@"id"] longValue]; std::string viewType([args[@"viewType"] UTF8String]); - if (views_.count(viewId) != 0) { - result([FlutterError errorWithCode:@"recreating_view" - message:@"trying to create an already created view" - details:[NSString stringWithFormat:@"view id: '%ld'", viewId]]); - } - NSObject* factory = factories_[viewType].get(); if (factory == nil) { - result([FlutterError errorWithCode:@"unregistered_view_type" - message:@"trying to create a view with an unregistered type" - details:[NSString stringWithFormat:@"unregistered view type: '%@'", - args[@"viewType"]]]); return; } @@ -101,9 +84,6 @@ void FlutterPlatformViewsController::OnDispose(FlutterMethodCall* call, FlutterR int64_t viewId = [arg longLongValue]; if (views_.count(viewId) == 0) { - result([FlutterError errorWithCode:@"unknown_view" - message:@"trying to dispose an unknown" - details:[NSString stringWithFormat:@"view id: '%lld'", viewId]]); return; } // We wait for next submitFrame to dispose views. @@ -117,9 +97,6 @@ void FlutterPlatformViewsController::OnAcceptGesture(FlutterMethodCall* call, int64_t viewId = [args[@"id"] longLongValue]; if (views_.count(viewId) == 0) { - result([FlutterError errorWithCode:@"unknown_view" - message:@"trying to set gesture state for an unknown view" - details:[NSString stringWithFormat:@"view id: '%lld'", viewId]]); return; } @@ -135,9 +112,6 @@ void FlutterPlatformViewsController::OnRejectGesture(FlutterMethodCall* call, int64_t viewId = [args[@"id"] longLongValue]; if (views_.count(viewId) == 0) { - result([FlutterError errorWithCode:@"unknown_view" - message:@"trying to set gesture state for an unknown view" - details:[NSString stringWithFormat:@"view id: '%lld'", viewId]]); return; } diff --git a/engine/flutter/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegate.mm b/engine/flutter/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegate.mm index b0ab5b5a849b8d3367eab8880dc0858eba6b437c..90a59361367b2c642f21f64f63cd4ffae12d38d7 100644 --- a/engine/flutter/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegate.mm +++ b/engine/flutter/shell/platform/darwin/ios/framework/Source/FlutterPluginAppLifeCycleDelegate.mm @@ -5,9 +5,7 @@ #include "flutter/shell/platform/darwin/ios/framework/Headers/FlutterPluginAppLifeCycleDelegate.h" #include "flutter/fml/logging.h" #include "flutter/fml/paths.h" -#include "flutter/lib/ui/plugins/callback_cache.h" #include "flutter/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h" -#include "flutter/shell/platform/darwin/ios/framework/Source/FlutterCallbackCache_Internal.h" static const char* kCallbackCacheSubDir = "Library/Caches/"; @@ -44,7 +42,6 @@ static const SEL selectorsHandledByPlugins[] = { if (self = [super init]) { _notificationUnsubscribers = [[NSMutableArray alloc] init]; std::string cachePath = fml::paths::JoinPaths({getenv("HOME"), kCallbackCacheSubDir}); - [FlutterCallbackCache setCachePath:[NSString stringWithUTF8String:cachePath.c_str()]]; [self addObserverFor:UIApplicationDidEnterBackgroundNotification selector:@selector(handleDidEnterBackground:)]; [self addObserverFor:UIApplicationWillEnterForegroundNotification @@ -118,7 +115,6 @@ static BOOL isPowerOfTwo(NSUInteger x) { - (BOOL)application:(UIApplication*)application willFinishLaunchingWithOptions:(NSDictionary*)launchOptions { - flutter::DartCallbackCache::LoadCacheFromDisk(); for (NSObject* delegate in [_delegates allObjects]) { if (!delegate) { continue; diff --git a/engine/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm b/engine/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm index 1c6b6b354a416bbef20da4bbf0bdcb9d2fca6616..0edf111db89982c56efa9df7cdf7c68e27eba95b 100644 --- a/engine/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm +++ b/engine/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm @@ -88,15 +88,14 @@ typedef enum UIAccessibilityContrast : NSInteger { return self; } -- (instancetype)initWithProject:(FlutterDartProject*)projectOrNil - nibName:(NSString*)nibNameOrNil - bundle:(NSBundle*)nibBundleOrNil { +- (instancetype)initWithName:(NSString*)nibNameOrNil + bundle:(NSBundle*)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { _viewOpaque = YES; _weakFactory = std::make_unique>(self); _engine.reset([[FlutterEngine alloc] initWithName:@"io.flutter" - project:projectOrNil +// project:projectOrNil allowHeadlessExecution:NO]); _flutterView.reset([[FlutterView alloc] initWithDelegate:_engine opaque:self.isViewOpaque]); [_engine.get() createShell:nil libraryURI:nil]; @@ -109,16 +108,28 @@ typedef enum UIAccessibilityContrast : NSInteger { return self; } +- (void) setIdleCallBack:(std::function)idleCallback { +// void setIdleCallBack(IdleCallback idleCallback){ + flutter::Shell& shell = [_engine.get() shell]; + + + auto platform_view = shell.GetPlatformView(); + if (!platform_view) { + return; + } + platform_view->SetIdleNotificationCallback(std::move(idleCallback)); +} + - (instancetype)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil { - return [self initWithProject:nil nibName:nil bundle:nil]; + return [self initWithName:nil bundle:nil]; } - (instancetype)initWithCoder:(NSCoder*)aDecoder { - return [self initWithProject:nil nibName:nil bundle:nil]; + return [self initWithName:nil bundle:nil]; } - (instancetype)init { - return [self initWithProject:nil nibName:nil bundle:nil]; + return [self initWithName:nil bundle:nil]; } - (BOOL)isViewOpaque { @@ -202,36 +213,6 @@ typedef enum UIAccessibilityContrast : NSInteger { name:NSCurrentLocaleDidChangeNotification object:nil]; - [center addObserver:self - selector:@selector(onAccessibilityStatusChanged:) - name:UIAccessibilityVoiceOverStatusChanged - object:nil]; - - [center addObserver:self - selector:@selector(onAccessibilityStatusChanged:) - name:UIAccessibilitySwitchControlStatusDidChangeNotification - object:nil]; - - [center addObserver:self - selector:@selector(onAccessibilityStatusChanged:) - name:UIAccessibilitySpeakScreenStatusDidChangeNotification - object:nil]; - - [center addObserver:self - selector:@selector(onAccessibilityStatusChanged:) - name:UIAccessibilityInvertColorsStatusDidChangeNotification - object:nil]; - - [center addObserver:self - selector:@selector(onAccessibilityStatusChanged:) - name:UIAccessibilityReduceMotionStatusDidChangeNotification - object:nil]; - - [center addObserver:self - selector:@selector(onAccessibilityStatusChanged:) - name:UIAccessibilityBoldTextStatusDidChangeNotification - object:nil]; - [center addObserver:self selector:@selector(onUserSettingsChanged:) name:UIContentSizeCategoryDidChangeNotification @@ -465,7 +446,6 @@ typedef enum UIAccessibilityContrast : NSInteger { TRACE_EVENT0("flutter", "viewDidAppear"); [self onLocaleUpdated:nil]; [self onUserSettingsChanged:nil]; - [self onAccessibilityStatusChanged:nil]; [[_engine.get() lifecycleChannel] sendMessage:@"AppLifecycleState.resumed"]; [super viewDidAppear:animated]; @@ -698,22 +678,6 @@ static flutter::PointerData::DeviceKind DeviceKindFromTouchType(UITouch* touch) [_engine.get() dispatchPointerDataPacket:std::move(packet)]; } -- (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event { - [self dispatchTouches:touches pointerDataChangeOverride:nullptr]; -} - -- (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event { - [self dispatchTouches:touches pointerDataChangeOverride:nullptr]; -} - -- (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event { - [self dispatchTouches:touches pointerDataChangeOverride:nullptr]; -} - -- (void)touchesCancelled:(NSSet*)touches withEvent:(UIEvent*)event { - [self dispatchTouches:touches pointerDataChangeOverride:nullptr]; -} - #pragma mark - Handle view resizing - (void)updateViewportMetrics { @@ -832,32 +796,6 @@ static flutter::PointerData::DeviceKind DeviceKindFromTouchType(UITouch* touch) return _orientationPreferences; } -#pragma mark - Accessibility - -- (void)onAccessibilityStatusChanged:(NSNotification*)notification { - auto platformView = [_engine.get() platformView]; - int32_t flags = 0; - if (UIAccessibilityIsInvertColorsEnabled()) - flags |= static_cast(flutter::AccessibilityFeatureFlag::kInvertColors); - if (UIAccessibilityIsReduceMotionEnabled()) - flags |= static_cast(flutter::AccessibilityFeatureFlag::kReduceMotion); - if (UIAccessibilityIsBoldTextEnabled()) - flags |= static_cast(flutter::AccessibilityFeatureFlag::kBoldText); -#if TARGET_OS_SIMULATOR - // There doesn't appear to be any way to determine whether the accessibility - // inspector is enabled on the simulator. We conservatively always turn on the - // accessibility bridge in the simulator, but never assistive technology. - platformView->SetSemanticsEnabled(true); - platformView->SetAccessibilityFeatures(flags); -#else - bool enabled = UIAccessibilityIsVoiceOverRunning() || UIAccessibilityIsSwitchControlRunning(); - if (enabled) - flags |= static_cast(flutter::AccessibilityFeatureFlag::kAccessibleNavigation); - platformView->SetSemanticsEnabled(enabled || UIAccessibilityIsSpeakScreenEnabled()); - platformView->SetAccessibilityFeatures(flags); -#endif -} - #pragma mark - Locale updates - (void)onLocaleUpdated:(NSNotification*)notification { @@ -1126,11 +1064,11 @@ constexpr CGFloat kStandardStatusBarHeight = 20.0; } - (NSString*)lookupKeyForAsset:(NSString*)asset { - return [FlutterDartProject lookupKeyForAsset:asset]; + return nil; } - (NSString*)lookupKeyForAsset:(NSString*)asset fromPackage:(NSString*)package { - return [FlutterDartProject lookupKeyForAsset:asset fromPackage:package]; + return nil; } - (id)pluginRegistry { diff --git a/engine/flutter/shell/platform/darwin/ios/platform_view_ios.h b/engine/flutter/shell/platform/darwin/ios/platform_view_ios.h index 38fc2a9f30b280fec81fe9d6701287f73d4e955e..79e5437f3592c11657199f0a89727a8da4ce0c0c 100644 --- a/engine/flutter/shell/platform/darwin/ios/platform_view_ios.h +++ b/engine/flutter/shell/platform/darwin/ios/platform_view_ios.h @@ -41,15 +41,11 @@ class PlatformViewIOS final : public PlatformView { void SetTextInputPlugin(fml::scoped_nsprotocol plugin); - // |PlatformView| - void SetSemanticsEnabled(bool enabled) override; - private: fml::WeakPtr owner_controller_; std::unique_ptr ios_surface_; std::shared_ptr gl_context_; PlatformMessageRouter platform_message_router_; - std::unique_ptr accessibility_bridge_; fml::scoped_nsprotocol text_input_plugin_; fml::closure firstFrameCallback_; @@ -63,14 +59,10 @@ class PlatformViewIOS final : public PlatformView { sk_sp CreateResourceContext() const override; // |PlatformView| - void SetAccessibilityFeatures(int32_t flags) override; - - // |PlatformView| - void UpdateSemantics(flutter::SemanticsNodeUpdates update, - flutter::CustomAccessibilityActionUpdates actions) override; + void SetAccessibilityFeatures(int32_t flags); // |PlatformView| - std::unique_ptr CreateVSyncWaiter() override; + std::unique_ptr CreateVSyncWaiter(int32_t platform) override; // |PlatformView| void OnPreEngineRestart() const override; diff --git a/engine/flutter/shell/platform/darwin/ios/platform_view_ios.mm b/engine/flutter/shell/platform/darwin/ios/platform_view_ios.mm index c80ae377c03a158fde7da68a7c254383fdf2851e..68666d6188d23dbe80033a54ab5baaac83f245dc 100644 --- a/engine/flutter/shell/platform/darwin/ios/platform_view_ios.mm +++ b/engine/flutter/shell/platform/darwin/ios/platform_view_ios.mm @@ -46,23 +46,12 @@ void PlatformViewIOS::SetOwnerViewController(fml::WeakPtr if (ios_surface_ || !owner_controller) { NotifyDestroyed(); ios_surface_.reset(); - accessibility_bridge_.reset(); } owner_controller_ = owner_controller; if (owner_controller_) { ios_surface_ = [static_cast(owner_controller.get().view) createSurface:gl_context_]; FML_DCHECK(ios_surface_ != nullptr); - - if (accessibility_bridge_) { - accessibility_bridge_.reset( - new AccessibilityBridge(static_cast(owner_controller_.get().view), this, - [owner_controller.get() platformViewsController])); - } - // Do not call `NotifyCreated()` here - let FlutterViewController take care - // of that when its Viewport is sized. If `NotifyCreated()` is called here, - // it can occasionally get invoked before the viewport is sized resulting in - // a framebuffer that will not be able to completely attach. } } @@ -95,59 +84,19 @@ sk_sp PlatformViewIOS::CreateResourceContext() const { } // |PlatformView| -void PlatformViewIOS::SetSemanticsEnabled(bool enabled) { - if (!owner_controller_) { - FML_LOG(WARNING) << "Could not set semantics to enabled, this " - "PlatformViewIOS has no ViewController."; - return; - } - if (enabled && !accessibility_bridge_) { - accessibility_bridge_ = std::make_unique( - static_cast(owner_controller_.get().view), this, - [owner_controller_.get() platformViewsController]); - } else if (!enabled && accessibility_bridge_) { - accessibility_bridge_.reset(); - } - PlatformView::SetSemanticsEnabled(enabled); -} - -// |shell:PlatformView| -void PlatformViewIOS::SetAccessibilityFeatures(int32_t flags) { - PlatformView::SetAccessibilityFeatures(flags); -} - -// |PlatformView| -void PlatformViewIOS::UpdateSemantics(flutter::SemanticsNodeUpdates update, - flutter::CustomAccessibilityActionUpdates actions) { - FML_DCHECK(owner_controller_); - if (accessibility_bridge_) { - accessibility_bridge_->UpdateSemantics(std::move(update), std::move(actions)); - [[NSNotificationCenter defaultCenter] postNotificationName:FlutterSemanticsUpdateNotification - object:owner_controller_.get()]; - } -} - -// |PlatformView| -std::unique_ptr PlatformViewIOS::CreateVSyncWaiter() { - return std::make_unique(task_runners_); +std::unique_ptr PlatformViewIOS::CreateVSyncWaiter(int32_t platform) { +// if (platform == static_cast(AcePlatform::ACE_PLATFORM_IOS)) { + return std::make_unique(task_runners_); +// } +// +// return nullptr; } void PlatformViewIOS::OnPreEngineRestart() const { - if (accessibility_bridge_) { - accessibility_bridge_->clearState(); - } if (!owner_controller_) { return; } [owner_controller_.get() platformViewsController] -> Reset(); } -fml::scoped_nsprotocol PlatformViewIOS::GetTextInputPlugin() const { - return text_input_plugin_; -} - -void PlatformViewIOS::SetTextInputPlugin(fml::scoped_nsprotocol plugin) { - text_input_plugin_ = plugin; -} - } // namespace flutter diff --git a/skia/third_party/externals/icu/source/common/unistr.cpp b/skia/third_party/externals/icu/source/common/unistr.cpp index c8b6c0a3a46319219b7e9d15a220dc5930786401..1e20a8d8974eb299fa7e956cc3de5ebd99c16e23 100644 --- a/skia/third_party/externals/icu/source/common/unistr.cpp +++ b/skia/third_party/externals/icu/source/common/unistr.cpp @@ -1564,8 +1564,11 @@ UnicodeString::doAppend(const UChar *srcChars, int32_t srcStart, int32_t srcLeng } int32_t oldLength = length(); - int32_t newLength = oldLength + srcLength; - + int32_t newLength; + if (uprv_add32_overflow(oldLength, srcLength, &newLength)) { + setToBogus(); + return *this; + } // Check for append onto ourself const UChar* oldArray = getArrayStart(); if (isBufferWritable() && diff --git a/skia/third_party/externals/icu/source/tools/pkgdata/pkgdata.cpp b/skia/third_party/externals/icu/source/tools/pkgdata/pkgdata.cpp index b2cd0ab5eb9709a5294f5c6226908dfdade105e7..8a2259271a2f335892a7ab3b36ad7a7ab6eee9f2 100644 --- a/skia/third_party/externals/icu/source/tools/pkgdata/pkgdata.cpp +++ b/skia/third_party/externals/icu/source/tools/pkgdata/pkgdata.cpp @@ -66,6 +66,8 @@ U_DEFINE_LOCAL_OPEN_POINTER(LocalPipeFilePointer, FILE, pclose); #endif +using icu::LocalMemory; + static void loadLists(UPKGOptions *o, UErrorCode *status); static int32_t pkg_executeOptions(UPKGOptions *o); @@ -1507,9 +1509,7 @@ static int32_t pkg_generateLibraryFile(const char *targetDir, const char mode, c static int32_t pkg_createWithAssemblyCode(const char *targetDir, const char mode, const char *gencFilePath) { char tempObjectFile[SMALL_BUFFER_MAX_SIZE] = ""; - char *cmd; int32_t result = 0; - int32_t length = 0; /* Remove the ending .s and replace it with .o for the new object file. */ @@ -1519,22 +1519,22 @@ static int32_t pkg_createWithAssemblyCode(const char *targetDir, const char mode length = uprv_strlen(pkgDataFlags[COMPILER]) + uprv_strlen(pkgDataFlags[LIBFLAGS]) + uprv_strlen(tempObjectFile) + uprv_strlen(gencFilePath) + BUFFER_PADDING_SIZE; - cmd = (char *)uprv_malloc(sizeof(char) * length); - if (cmd == NULL) { + LocalMemory cmd((char *)uprv_malloc(sizeof(char) * length)); + if (cmd.isNull()) { return -1; } /* Generate the object file. */ - sprintf(cmd, "%s %s -o %s %s", + sprintf(cmd.getAlias(), "%s %s -o %s %s", pkgDataFlags[COMPILER], pkgDataFlags[LIBFLAGS], tempObjectFile, gencFilePath); - result = runCommand(cmd); - uprv_free(cmd); + result = runCommand(cmd.getAlias()); + if (result != 0) { - fprintf(stderr, "Error creating with assembly code. Failed command: %s\n", cmd); + fprintf(stderr, "Error creating with assembly code. Failed command: %s\n", cmd.getAlias()); return result; }