51 {
53
54
55
56
57
58
59
62
63 bool hasExplicitBundle = bundle != nil;
64 if (bundle == nil) {
66 }
67
69
73 return queue_id;
74 };
75
78 };
79
80 settings.log_message_callback = [](
const std::string& tag,
const std::string&
message) {
81 std::stringstream stream;
82 if (!tag.empty()) {
83 stream << tag << ": ";
84 }
86 std::string log = stream.str();
87 [FlutterLogger logDirect:[NSString stringWithUTF8String:log.c_str()]];
88 };
89
90 settings.enable_platform_isolates = true;
91
92
93
94
95
96 if (settings.icu_data_path.empty()) {
97 NSString* icuDataPath = [engineBundle pathForResource:@"icudtl" ofType:@"dat"];
98 if (icuDataPath.length > 0) {
99 settings.icu_data_path = icuDataPath.UTF8String;
100 }
101 }
102
104 if (hasExplicitBundle) {
105 NSString* executablePath = bundle.executablePath;
106 if ([[NSFileManager defaultManager] fileExistsAtPath:executablePath]) {
107 settings.application_library_paths.push_back(executablePath.UTF8String);
108 }
109 }
110
111
112 if (settings.application_library_paths.empty()) {
113 NSString* libraryName = [mainBundle objectForInfoDictionaryKey:@"FLTLibraryPath"];
114 NSString* libraryPath = [mainBundle pathForResource:libraryName ofType:@""];
115 if (libraryPath.length > 0) {
116 NSString* executablePath = [NSBundle bundleWithPath:libraryPath].executablePath;
117 if (executablePath.length > 0) {
118 settings.application_library_paths.push_back(executablePath.UTF8String);
119 }
120 }
121 }
122
123
124
125 if (settings.application_library_paths.empty()) {
126 NSString* applicationFrameworkPath = [mainBundle pathForResource:@"Frameworks/App.framework"
127 ofType:@""];
128 if (applicationFrameworkPath.length > 0) {
129 NSString* executablePath =
130 [NSBundle bundleWithPath:applicationFrameworkPath].executablePath;
131 if (executablePath.length > 0) {
132 settings.application_library_paths.push_back(executablePath.UTF8String);
133 }
134 }
135 }
136 }
137
138
139 if (settings.assets_path.empty()) {
141
142 if (assetsPath.length == 0) {
143 NSLog(@"Failed to find assets path for \"%@\"", bundle);
144 } else {
145 settings.assets_path = assetsPath.UTF8String;
146
147
148
149
151 NSURL* applicationKernelSnapshotURL =
153 relativeToURL:[NSURL fileURLWithPath:assetsPath]];
155 if ([applicationKernelSnapshotURL checkResourceIsReachableAndReturnError:&
error]) {
156 settings.application_kernel_asset = applicationKernelSnapshotURL.path.UTF8String;
157 } else {
158 NSLog(
@"Failed to find snapshot at %@: %@", applicationKernelSnapshotURL.path,
error);
159 }
160 }
161 }
162 }
163
164
165
166
167 settings.may_insecurely_connect_to_all_domains = true;
168 settings.domain_network_policy = "";
169
170
171#if TARGET_OS_SIMULATOR
172
173
174 settings.enable_wide_gamut = false;
175
177#else
179 BOOL enableWideGamut =
181 settings.enable_wide_gamut = enableWideGamut;
182#endif
183
184 NSNumber* nsAntialiasLines = [mainBundle objectForInfoDictionaryKey:@"FLTAntialiasLines"];
185 settings.impeller_antialiased_lines = (nsAntialiasLines ? nsAntialiasLines.boolValue : NO);
186
187 settings.warn_on_impeller_opt_out = true;
188
189 NSNumber* nsEnableSDFs = [mainBundle objectForInfoDictionaryKey:@"FLTEnableSDFs"];
190 settings.impeller_use_sdfs = (nsEnableSDFs ? nsEnableSDFs.boolValue : NO);
191
192 NSNumber* enableTraceSystrace = [mainBundle objectForInfoDictionaryKey:@"FLTTraceSystrace"];
193
194 if (enableTraceSystrace != nil) {
195 settings.trace_systrace = enableTraceSystrace.boolValue;
196 }
197
198 NSNumber* profileMicrotasks = [mainBundle objectForInfoDictionaryKey:@"FLTProfileMicrotasks"];
199
200 if (profileMicrotasks != nil) {
201 settings.profile_microtasks = profileMicrotasks.boolValue;
202 }
203
204 NSNumber* enableDartAsserts = [mainBundle objectForInfoDictionaryKey:@"FLTEnableDartAsserts"];
205 if (enableDartAsserts != nil) {
206 settings.dart_flags.push_back("--enable-asserts");
207 }
208
209 NSNumber* enableDartProfiling = [mainBundle objectForInfoDictionaryKey:@"FLTEnableDartProfiling"];
210
211 if (enableDartProfiling != nil) {
212 settings.enable_dart_profiling = enableDartProfiling.boolValue;
213 }
214
215 NSNumber* profileStartup = [mainBundle objectForInfoDictionaryKey:@"FLTProfileStartup"];
216
217 if (profileStartup != nil) {
218 settings.profile_startup = profileStartup.boolValue;
219 }
220
221
222 NSNumber* leakDartVM = [mainBundle objectForInfoDictionaryKey:@"FLTLeakDartVM"];
223
224 if (leakDartVM != nil) {
225 settings.leak_vm = leakDartVM.boolValue;
226 }
227
228 NSNumber* enableMergedPlatformUIThread =
229 [mainBundle objectForInfoDictionaryKey:@"FLTEnableMergedPlatformUIThread"];
230 if (enableMergedPlatformUIThread != nil) {
231 FML_CHECK(enableMergedPlatformUIThread.boolValue)
232 << "FLTEnableMergedPlatformUIThread=false is no longer allowed.";
233 }
234
235 NSNumber* enableFlutterGPU = [mainBundle objectForInfoDictionaryKey:@"FLTEnableFlutterGPU"];
236 if (enableFlutterGPU != nil) {
237 settings.enable_flutter_gpu = enableFlutterGPU.boolValue;
238 }
239
240#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
241
242
243 auto make_mapping_callback = [](
const uint8_t* mapping,
size_t size) {
244 return [mapping,
size]() {
return std::make_unique<fml::NonOwnedMapping>(mapping, size); };
245 };
246
247 settings.dart_library_sources_kernel =
249#endif
250
251
252
253
254
255
256
257 if (settings.old_gen_heap_size <= 0) {
258 settings.old_gen_heap_size = std::round([NSProcessInfo processInfo].physicalMemory * .48 /
260 }
261
262
263
264 CGFloat scale = [UIScreen mainScreen].scale;
265 CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width * scale;
266 CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height * scale;
267 settings.resource_cache_max_bytes_threshold = screenWidth * screenHeight * 12 * 4;
268
269
270 NSNumber* enable_embedder_api =
271 [mainBundle objectForInfoDictionaryKey:@"FLTEnableIOSEmbedderAPI"];
272
273 if (enable_embedder_api) {
274 settings.enable_embedder_api = enable_embedder_api.boolValue;
275 }
276
277 return settings;
278}
NSBundle * FLTFrameworkBundleWithIdentifier(NSString *flutterFrameworkBundleID)
NSString * FLTAssetsPathFromBundle(NSBundle *bundle)
NSBundle * FLTGetApplicationBundle()
static bool IsRunningPrecompiledCode()
Checks if VM instances in the process can run precompiled code. This call can be made at any time and...
static TaskQueueId GetCurrentTaskQueueId()
static MessageLoopTaskQueues * GetInstance()
void AddTaskObserver(TaskQueueId queue_id, intptr_t key, const fml::closure &callback)
void RemoveTaskObserver(TaskQueueId queue_id, intptr_t key)
const uint8_t uint32_t uint32_t GError ** error
FlutterDesktopBinaryReply callback
#define FML_CHECK(condition)
NSNumber *_Nullable FLTEnableWideGamutFromBundle(NSBundle *_Nullable bundle, NSBundle *_Nullable mainBundle)
static const char * kApplicationKernelSnapshotFileName
const intptr_t kPlatformStrongDillSize
FLUTTER_ASSERT_ARC const uint8_t kPlatformStrongDill[]
static BOOL DoesHardwareSupportWideGamut()
it will be possible to load the file into Perfetto s trace viewer use test Running tests that layout and measure text will not yield consistent results across various platforms Enabling this option will make font resolution default to the Ahem test font on all disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Settings SettingsFromCommandLine(const fml::CommandLine &command_line, bool require_merged_platform_ui_thread)
fml::CommandLine CommandLineFromNSProcessInfo(NSProcessInfo *processInfoOrNil=nil)
constexpr double kMegaByteSizeInBytes
std::function< void()> closure