Read snapshot directly from data dir instead of FLX (flutter/engine#4214)

This commit is contained in:
Sarah Zakarias 2017-10-17 15:06:03 +02:00 committed by GitHub
parent 0226fef0e6
commit f7660f8d9c
4 changed files with 12 additions and 2 deletions

View File

@ -488,6 +488,8 @@ void Engine::ConfigureAssetBundle(const std::string& path) {
if (S_ISREG(stat_result.st_mode)) {
asset_store_ = fxl::MakeRefCounted<blink::ZipAssetStore>(
blink::GetUnzipperProviderForPath(path));
directory_asset_bundle_ = std::make_unique<blink::DirectoryAssetBundle>(
files::GetDirectoryName(path));
return;
}
}

View File

@ -43,7 +43,7 @@ class Engine : public blink::RuntimeDelegate {
void RunBundleAndSnapshot(const std::string& bundle_path,
const std::string& snapshot_override);
// Uses the given source code instead of looking inside the bindle for the
// Uses the given source code instead of looking inside the bundle for the
// source code.
void RunBundleAndSource(const std::string& bundle_path,
const std::string& main,

View File

@ -68,7 +68,7 @@ DEF_SWITCH(EnableSoftwareRendering,
DEF_SWITCH(EnableTxt,
"enable-txt",
"Enable libtxt as the text shaping library instead of Blink.")
DEF_SWITCH(FLX, "flx", "Specify the the FLX path.")
DEF_SWITCH(FLX, "flx", "Specify the FLX path.")
DEF_SWITCH(Help, "help", "Display this help text.")
DEF_SWITCH(LogTag, "log-tag", "Tag associated with log messages.")
DEF_SWITCH(MainDartFile, "dart-main", "The path to the main Dart file.")
@ -77,6 +77,7 @@ DEF_SWITCH(NonInteractive,
"Make the shell non-interactive. By default, the shell attempts "
"to setup a window and create an OpenGL context.")
DEF_SWITCH(Packages, "packages", "Specify the path to the packages.")
DEF_SWITCH(Snapshot, "snapshot-blob", "Specify the path to the snapshot blob")
DEF_SWITCH(StartPaused,
"start-paused",
"Start the application paused in the Dart debugger.")

View File

@ -36,6 +36,7 @@ public class FlutterMain {
private static final String AOT_ISOLATE_SNAPSHOT_DATA_KEY = "isolate-snapshot-data";
private static final String AOT_ISOLATE_SNAPSHOT_INSTR_KEY = "isolate-snapshot-instr";
private static final String FLX_KEY = "flx";
private static final String SNAPSHOT_BLOB_KEY = "snapshot-blob";
// XML Attribute keys supported in AndroidManifest.xml
public static final String PUBLIC_AOT_VM_SNAPSHOT_DATA_KEY =
@ -48,6 +49,8 @@ public class FlutterMain {
FlutterMain.class.getName() + '.' + AOT_ISOLATE_SNAPSHOT_INSTR_KEY;
public static final String PUBLIC_FLX_KEY =
FlutterMain.class.getName() + '.' + FLX_KEY;
public static final String PUBLIC_SNAPSHOT_BLOB_KEY =
FlutterMain.class.getName() + '.' + SNAPSHOT_BLOB_KEY;
// Resource names used for components of the precompiled snapshot.
private static final String DEFAULT_AOT_VM_SNAPSHOT_DATA = "vm_snapshot_data";
@ -55,6 +58,7 @@ public class FlutterMain {
private static final String DEFAULT_AOT_ISOLATE_SNAPSHOT_DATA = "isolate_snapshot_data";
private static final String DEFAULT_AOT_ISOLATE_SNAPSHOT_INSTR = "isolate_snapshot_instr";
private static final String DEFAULT_FLX = "app.flx";
private static final String DEFAULT_SNAPSHOT_BLOB = "snapshot_blob.bin";
private static final String MANIFEST = "flutter.yaml";
@ -69,6 +73,7 @@ public class FlutterMain {
private static String sAotIsolateSnapshotData = DEFAULT_AOT_ISOLATE_SNAPSHOT_DATA;
private static String sAotIsolateSnapshotInstr = DEFAULT_AOT_ISOLATE_SNAPSHOT_INSTR;
private static String sFlx = DEFAULT_FLX;
private static String sSnapshotBlob = DEFAULT_SNAPSHOT_BLOB;
private static boolean sInitialized = false;
private static ResourceExtractor sResourceExtractor;
@ -209,6 +214,7 @@ public class FlutterMain {
sAotIsolateSnapshotData = metadata.getString(PUBLIC_AOT_ISOLATE_SNAPSHOT_DATA_KEY, DEFAULT_AOT_ISOLATE_SNAPSHOT_DATA);
sAotIsolateSnapshotInstr = metadata.getString(PUBLIC_AOT_ISOLATE_SNAPSHOT_INSTR_KEY, DEFAULT_AOT_ISOLATE_SNAPSHOT_INSTR);
sFlx = metadata.getString(PUBLIC_FLX_KEY, DEFAULT_FLX);
sSnapshotBlob = metadata.getString(PUBLIC_SNAPSHOT_BLOB_KEY, DEFAULT_SNAPSHOT_BLOB);
}
} catch (PackageManager.NameNotFoundException e) {
throw new RuntimeException(e);
@ -225,6 +231,7 @@ public class FlutterMain {
.addResource(sAotIsolateSnapshotData)
.addResource(sAotIsolateSnapshotInstr)
.addResource(sFlx)
.addResource(sSnapshotBlob)
.start();
}