55 {
57
58
59
60
61
62
63
66
67 bool hasExplicitBundle = bundle != nil;
68 if (bundle == nil) {
70 }
71
73
76 };
77
80 };
81
82 settings.log_message_callback = [](
const std::string& tag,
const std::string&
message) {
83
84
86 if (!tag.empty()) {
88 }
91 syslog(LOG_ALERT,
"%.*s", (
int)
log.size(),
log.c_str());
92 };
93
94 settings.enable_platform_isolates =
true;
95
96
97
98
99
100 if (
settings.icu_data_path.empty()) {
101 NSString* icuDataPath = [engineBundle pathForResource:@"icudtl" ofType:@"dat"];
102 if (icuDataPath.length > 0) {
103 settings.icu_data_path = icuDataPath.UTF8String;
104 }
105 }
106
108 if (hasExplicitBundle) {
109 NSString* executablePath = bundle.executablePath;
110 if ([[NSFileManager defaultManager] fileExistsAtPath:executablePath]) {
111 settings.application_library_path.push_back(executablePath.UTF8String);
112 }
113 }
114
115
116 if (
settings.application_library_path.empty()) {
117 NSString* libraryName = [mainBundle objectForInfoDictionaryKey:@"FLTLibraryPath"];
118 NSString* libraryPath = [mainBundle pathForResource:libraryName ofType:@""];
119 if (libraryPath.length > 0) {
120 NSString* executablePath = [NSBundle bundleWithPath:libraryPath].executablePath;
121 if (executablePath.length > 0) {
122 settings.application_library_path.push_back(executablePath.UTF8String);
123 }
124 }
125 }
126
127
128
129 if (
settings.application_library_path.empty()) {
130 NSString* applicationFrameworkPath = [mainBundle pathForResource:@"Frameworks/App.framework"
131 ofType:@""];
132 if (applicationFrameworkPath.length > 0) {
133 NSString* executablePath =
134 [NSBundle bundleWithPath:applicationFrameworkPath].executablePath;
135 if (executablePath.length > 0) {
136 settings.application_library_path.push_back(executablePath.UTF8String);
137 }
138 }
139 }
140 }
141
142
145
146 if (assetsPath.length == 0) {
147 NSLog(@"Failed to find assets path for \"%@\"", bundle);
148 } else {
149 settings.assets_path = assetsPath.UTF8String;
150
151
152
153
155 NSURL* applicationKernelSnapshotURL =
157 relativeToURL:[NSURL fileURLWithPath:assetsPath]];
159 if ([applicationKernelSnapshotURL checkResourceIsReachableAndReturnError:&
error]) {
160 settings.application_kernel_asset = applicationKernelSnapshotURL.path.UTF8String;
161 } else {
162 NSLog(
@"Failed to find snapshot at %@: %@", applicationKernelSnapshotURL.path,
error);
163 }
164 }
165 }
166 }
167
168
169
170
171 settings.may_insecurely_connect_to_all_domains =
true;
172 settings.domain_network_policy =
"";
173
174
175#if TARGET_OS_SIMULATOR
176
177
179
181#else
182 NSNumber* nsEnableWideGamut = [mainBundle objectForInfoDictionaryKey:@"FLTEnableWideGamut"];
183 BOOL enableWideGamut =
185 settings.enable_wide_gamut = enableWideGamut;
186#endif
187
188
189
190
191
192 if (!command_line.HasOption("enable-impeller")) {
193
194 NSNumber* enableImpeller = [bundle objectForInfoDictionaryKey:@"FLTEnableImpeller"];
195 if (enableImpeller == nil) {
196
197 enableImpeller = [mainBundle objectForInfoDictionaryKey:@"FLTEnableImpeller"];
198 }
199
200 if (enableImpeller != nil) {
201 settings.enable_impeller = enableImpeller.boolValue;
202 }
203 }
204
205 settings.warn_on_impeller_opt_out =
true;
206
207 NSNumber* enableTraceSystrace = [mainBundle objectForInfoDictionaryKey:@"FLTTraceSystrace"];
208
209 if (enableTraceSystrace != nil) {
210 settings.trace_systrace = enableTraceSystrace.boolValue;
211 }
212
213 NSNumber* enableDartAsserts = [mainBundle objectForInfoDictionaryKey:@"FLTEnableDartAsserts"];
214 if (enableDartAsserts != nil) {
215 settings.dart_flags.push_back(
"--enable-asserts");
216 }
217
218 NSNumber* enableDartProfiling = [mainBundle objectForInfoDictionaryKey:@"FLTEnableDartProfiling"];
219
220 if (enableDartProfiling != nil) {
221 settings.enable_dart_profiling = enableDartProfiling.boolValue;
222 }
223
224
225 NSNumber* leakDartVM = [mainBundle objectForInfoDictionaryKey:@"FLTLeakDartVM"];
226
227 if (leakDartVM != nil) {
228 settings.leak_vm = leakDartVM.boolValue;
229 }
230
231#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
232
233
234 auto make_mapping_callback = [](
const uint8_t* mapping,
size_t size) {
235 return [mapping,
size]() {
return std::make_unique<fml::NonOwnedMapping>(mapping, size); };
236 };
237
238 settings.dart_library_sources_kernel =
240#endif
241
242
243
244
245
246
247
248 if (
settings.old_gen_heap_size <= 0) {
249 settings.old_gen_heap_size = std::round([NSProcessInfo processInfo].physicalMemory * .48 /
251 }
252
253
254
255 CGFloat
scale = [UIScreen mainScreen].scale;
256 CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width *
scale;
257 CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height *
scale;
258 settings.resource_cache_max_bytes_threshold = screenWidth * screenHeight * 12 * 4;
259
260
261 NSNumber* enable_embedder_api =
262 [mainBundle objectForInfoDictionaryKey:@"FLTEnableIOSEmbedderAPI"];
263
264 if (enable_embedder_api) {
265 settings.enable_embedder_api = enable_embedder_api.boolValue;
266 }
267
269}
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...
void RemoveTaskObserver(intptr_t key)
void AddTaskObserver(intptr_t key, const fml::closure &callback)
static FML_EMBEDDER_ONLY MessageLoop & GetCurrent()
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
const uint8_t uint32_t uint32_t GError ** error
FLUTTER_ASSERT_NOT_ARC const uint8_t kPlatformStrongDill[]
static const char * kApplicationKernelSnapshotFileName
const intptr_t kPlatformStrongDillSize
static BOOL DoesHardwareSupportWideGamut()
Settings SettingsFromCommandLine(const fml::CommandLine &command_line)
fml::CommandLine CommandLineFromNSProcessInfo(NSProcessInfo *processInfoOrNil=nil)
constexpr double kMegaByteSizeInBytes
it will be possible to load the file into Perfetto s trace viewer 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
std::function< void()> closure