From f7660f8d9cf3b7258fabbc35caad9be050e5ca6d Mon Sep 17 00:00:00 2001 From: Sarah Zakarias Date: Tue, 17 Oct 2017 15:06:03 +0200 Subject: [PATCH] Read snapshot directly from data dir instead of FLX (flutter/engine#4214) --- engine/src/flutter/shell/common/engine.cc | 2 ++ engine/src/flutter/shell/common/engine.h | 2 +- engine/src/flutter/shell/common/switches.h | 3 ++- .../platform/android/io/flutter/view/FlutterMain.java | 7 +++++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/engine/src/flutter/shell/common/engine.cc b/engine/src/flutter/shell/common/engine.cc index 7bc70016fd2..9a1910863fe 100644 --- a/engine/src/flutter/shell/common/engine.cc +++ b/engine/src/flutter/shell/common/engine.cc @@ -488,6 +488,8 @@ void Engine::ConfigureAssetBundle(const std::string& path) { if (S_ISREG(stat_result.st_mode)) { asset_store_ = fxl::MakeRefCounted( blink::GetUnzipperProviderForPath(path)); + directory_asset_bundle_ = std::make_unique( + files::GetDirectoryName(path)); return; } } diff --git a/engine/src/flutter/shell/common/engine.h b/engine/src/flutter/shell/common/engine.h index fbb64cccb8d..dc8887fa78c 100644 --- a/engine/src/flutter/shell/common/engine.h +++ b/engine/src/flutter/shell/common/engine.h @@ -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, diff --git a/engine/src/flutter/shell/common/switches.h b/engine/src/flutter/shell/common/switches.h index 856dd9bde76..a47471be913 100644 --- a/engine/src/flutter/shell/common/switches.h +++ b/engine/src/flutter/shell/common/switches.h @@ -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.") diff --git a/engine/src/flutter/shell/platform/android/io/flutter/view/FlutterMain.java b/engine/src/flutter/shell/platform/android/io/flutter/view/FlutterMain.java index abe5794e877..2450744abd4 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/view/FlutterMain.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/view/FlutterMain.java @@ -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(); }