46 {
48
49
50
51
52
53
54
57
58 bool hasExplicitBundle = bundle != nil;
59 if (bundle == nil) {
61 }
62
64
67 };
68
71 };
72
73 settings.log_message_callback = [](
const std::string& tag,
const std::string&
message) {
74
75
77 if (!tag.empty()) {
79 }
82 syslog(LOG_ALERT,
"%.*s", (
int)
log.size(),
log.c_str());
83 };
84
85 settings.enable_platform_isolates =
true;
86
87
88
89
90
91 if (
settings.icu_data_path.empty()) {
92 NSString* icuDataPath = [engineBundle pathForResource:@"icudtl" ofType:@"dat"];
93 if (icuDataPath.length > 0) {
94 settings.icu_data_path = icuDataPath.UTF8String;
95 }
96 }
97
99 if (hasExplicitBundle) {
100 NSString* executablePath = bundle.executablePath;
101 if ([[NSFileManager defaultManager] fileExistsAtPath:executablePath]) {
102 settings.application_library_path.push_back(executablePath.UTF8String);
103 }
104 }
105
106
107 if (
settings.application_library_path.empty()) {
108 NSString* libraryName = [mainBundle objectForInfoDictionaryKey:@"FLTLibraryPath"];
109 NSString* libraryPath = [mainBundle pathForResource:libraryName ofType:@""];
110 if (libraryPath.length > 0) {
111 NSString* executablePath = [NSBundle bundleWithPath:libraryPath].executablePath;
112 if (executablePath.length > 0) {
113 settings.application_library_path.push_back(executablePath.UTF8String);
114 }
115 }
116 }
117
118
119
120 if (
settings.application_library_path.empty()) {
121 NSString* applicationFrameworkPath = [mainBundle pathForResource:@"Frameworks/App.framework"
122 ofType:@""];
123 if (applicationFrameworkPath.length > 0) {
124 NSString* executablePath =
125 [NSBundle bundleWithPath:applicationFrameworkPath].executablePath;
126 if (executablePath.length > 0) {
127 settings.application_library_path.push_back(executablePath.UTF8String);
128 }
129 }
130 }
131 }
132
133
136
137 if (assetsPath.length == 0) {
138 NSLog(@"Failed to find assets path for \"%@\"", bundle);
139 } else {
140 settings.assets_path = assetsPath.UTF8String;
141
142
143
144
146 NSURL* applicationKernelSnapshotURL =
148 relativeToURL:[NSURL fileURLWithPath:assetsPath]];
150 if ([applicationKernelSnapshotURL checkResourceIsReachableAndReturnError:&
error]) {
151 settings.application_kernel_asset = applicationKernelSnapshotURL.path.UTF8String;
152 } else {
153 NSLog(
@"Failed to find snapshot at %@: %@", applicationKernelSnapshotURL.path,
error);
154 }
155 }
156 }
157 }
158
159
160
161
162 settings.may_insecurely_connect_to_all_domains =
true;
163 settings.domain_network_policy =
"";
164
165
166#if TARGET_OS_SIMULATOR
167
168
170
172#else
173 NSNumber* nsEnableWideGamut = [mainBundle objectForInfoDictionaryKey:@"FLTEnableWideGamut"];
174 BOOL enableWideGamut =
176 settings.enable_wide_gamut = enableWideGamut;
177#endif
178
179
180
181
182
183 if (!command_line.HasOption("enable-impeller")) {
184
185 NSNumber* enableImpeller = [bundle objectForInfoDictionaryKey:@"FLTEnableImpeller"];
186 if (enableImpeller == nil) {
187
188 enableImpeller = [mainBundle objectForInfoDictionaryKey:@"FLTEnableImpeller"];
189 }
190
191 if (enableImpeller != nil) {
192 settings.enable_impeller = enableImpeller.boolValue;
193 }
194 }
195
196 settings.warn_on_impeller_opt_out =
true;
197
198 NSNumber* enableTraceSystrace = [mainBundle objectForInfoDictionaryKey:@"FLTTraceSystrace"];
199
200 if (enableTraceSystrace != nil) {
201 settings.trace_systrace = enableTraceSystrace.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
216 NSNumber* leakDartVM = [mainBundle objectForInfoDictionaryKey:@"FLTLeakDartVM"];
217
218 if (leakDartVM != nil) {
219 settings.leak_vm = leakDartVM.boolValue;
220 }
221
222#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG
223
224
225 auto make_mapping_callback = [](
const uint8_t* mapping,
size_t size) {
226 return [mapping,
size]() {
return std::make_unique<fml::NonOwnedMapping>(mapping,
size); };
227 };
228
229 settings.dart_library_sources_kernel =
231#endif
232
233
234
235
236
237
238
239 if (
settings.old_gen_heap_size <= 0) {
240 settings.old_gen_heap_size =
std::round([NSProcessInfo processInfo].physicalMemory * .48 /
242 }
243
244
245
246 CGFloat
scale = [UIScreen mainScreen].scale;
247 CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width *
scale;
248 CGFloat screenHeight = [UIScreen mainScreen].bounds.size.height *
scale;
249 settings.resource_cache_max_bytes_threshold = screenWidth * screenHeight * 12 * 4;
250
251
252 NSNumber* enable_embedder_api =
253 [mainBundle objectForInfoDictionaryKey:@"FLTEnableIOSEmbedderAPI"];
254
255 if (enable_embedder_api) {
256 settings.enable_embedder_api = enable_embedder_api.boolValue;
257 }
258
260}
NSBundle * FLTFrameworkBundleWithIdentifier(NSString *flutterFrameworkBundleID)
NSString * FLTAssetsPathFromBundle(NSBundle *bundle)
NSBundle * FLTGetApplicationBundle()
static void round(SkPoint *p)
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
static const char * kApplicationKernelSnapshotFileName
const intptr_t kPlatformStrongDillSize
FLUTTER_ASSERT_ARC const uint8_t kPlatformStrongDill[]
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