From 18ec58629e7d90c89ea98a82f669eaccd5f82bb3 Mon Sep 17 00:00:00 2001 From: "James D. Lin" Date: Fri, 21 Sep 2018 14:05:30 -0700 Subject: [PATCH] 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. --- .../framework/Source/FlutterDartProject.mm | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm index f5d5d80dfe..b1b50ef002 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm @@ -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); } } }