Add logging if FlutterDartProject fails to load the application kernel snapshot (flutter/engine#6257)

To make "Engine run configuration was invalid." failures (e.g.
https://github.com/flutter/flutter/issues/20777) a bit easier to
diagnose, add some more logging to `FlutterDartProject` to verify
that snapshot assets were properly bundled.
This commit is contained in:
James D. Lin
2018-09-21 14:05:30 -07:00
committed by GitHub
parent 6e159af6f2
commit 18ec58629e

View File

@@ -98,21 +98,22 @@ static blink::Settings DefaultSettingsForProcess(NSBundle* bundle = nil) {
NSString* assetsName = [FlutterDartProject flutterAssetsName:bundle];
NSString* assetsPath = [mainBundle pathForResource:assetsName ofType:@""];
if (assetsPath.length > 0) {
if (assetsPath.length == 0) {
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 (!blink::DartVM::IsRunningPrecompiledCode()) {
// Looking for the various script and kernel snapshot buffers only makes sense if we have a
// VM that can use these buffers.
{
// Check if there is an application kernel snapshot in the assets directory we could
// potentially use.
NSURL* applicationKernelSnapshotURL =
[NSURL URLWithString:@(kApplicationKernelSnapshotFileName)
relativeToURL:[NSURL fileURLWithPath:assetsPath]];
if ([[NSFileManager defaultManager] fileExistsAtPath:applicationKernelSnapshotURL.path]) {
settings.application_kernel_asset = applicationKernelSnapshotURL.path.UTF8String;
}
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);
}
}
}