Skip to content

Commit

Permalink
Reapply "Don't link the core snapshot in the Android engine." (flutte…
Browse files Browse the repository at this point in the history
…r#5353)

Add back the core snapshot to runtime_unittests and embedder_unittests.
  • Loading branch information
rmacnak-google authored May 24, 2018
1 parent 1ef8cd2 commit 86d96fd
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
8 changes: 0 additions & 8 deletions runtime/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,6 @@ source_set("runtime") {

public_configs = [ "$flutter_root:config" ]

# In AOT mode, precompiled snapshots contain the instruction buffer.
# Generation of the same requires all application specific script code to be
# specified up front. In such cases, there can be no generic snapshot.
# In Fuchsia, we load from a file instead of linking.
if (!flutter_aot && !is_fuchsia) {
deps += [ "$flutter_root/lib/snapshot" ]
}

if (flutter_runtime_mode != "release" && !is_fuchsia) {
# Only link in Observatory in non-release modes on non-Fuchsia. Fuchsia
# instead puts Observatory into the runner's package.
Expand Down
35 changes: 22 additions & 13 deletions shell/platform/android/io/flutter/view/FlutterMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private static String fromFlutterAssets(String filePath) {

private static boolean sInitialized = false;
private static ResourceExtractor sResourceExtractor;
private static boolean sIsPrecompiled;
private static boolean sIsPrecompiledAsBlobs;
private static boolean sIsPrecompiledAsSharedLibrary;
private static Settings sSettings;

Expand Down Expand Up @@ -201,19 +201,24 @@ public static void ensureInitializationComplete(Context applicationContext, Stri
if (args != null) {
Collections.addAll(shellArgs, args);
}
if (sIsPrecompiled) {
shellArgs.add("--" + AOT_SNAPSHOT_PATH_KEY + "=" +
PathUtils.getDataDirectory(applicationContext));
if (sIsPrecompiledAsSharedLibrary) {
shellArgs.add("--" + AOT_SHARED_LIBRARY_PATH + "=" +
new File(PathUtils.getDataDirectory(applicationContext), sAotSharedLibraryPath));
} else {
if (sIsPrecompiledAsBlobs) {
shellArgs.add("--" + AOT_SNAPSHOT_PATH_KEY + "=" +
PathUtils.getDataDirectory(applicationContext));
} else {
shellArgs.add("--cache-dir-path=" +
PathUtils.getCacheDirectory(applicationContext));

shellArgs.add("--" + AOT_SNAPSHOT_PATH_KEY + "=" +
PathUtils.getDataDirectory(applicationContext) + "/" + sFlutterAssetsDir);
}
shellArgs.add("--" + AOT_VM_SNAPSHOT_DATA_KEY + "=" + sAotVmSnapshotData);
shellArgs.add("--" + AOT_VM_SNAPSHOT_INSTR_KEY + "=" + sAotVmSnapshotInstr);
shellArgs.add("--" + AOT_ISOLATE_SNAPSHOT_DATA_KEY + "=" + sAotIsolateSnapshotData);
shellArgs.add("--" + AOT_ISOLATE_SNAPSHOT_INSTR_KEY + "=" + sAotIsolateSnapshotInstr);
} else if (sIsPrecompiledAsSharedLibrary) {
shellArgs.add("--" + AOT_SHARED_LIBRARY_PATH + "=" +
new File(PathUtils.getDataDirectory(applicationContext), sAotSharedLibraryPath));
} else {
shellArgs.add("--cache-dir-path=" +
PathUtils.getCacheDirectory(applicationContext));
}

if (sSettings.getLogTag() != null) {
Expand Down Expand Up @@ -264,6 +269,10 @@ private static void initResources(Context applicationContext) {
.addResources(SKY_RESOURCES)
.addResource(fromFlutterAssets(sFlx))
.addResource(fromFlutterAssets(sSnapshotBlob))
.addResource(fromFlutterAssets(sAotVmSnapshotData))
.addResource(fromFlutterAssets(sAotVmSnapshotInstr))
.addResource(fromFlutterAssets(sAotIsolateSnapshotData))
.addResource(fromFlutterAssets(sAotIsolateSnapshotInstr))
.addResource(fromFlutterAssets(DEFAULT_KERNEL_BLOB))
.addResource(fromFlutterAssets(DEFAULT_PLATFORM_DILL));
if (sIsPrecompiledAsSharedLibrary) {
Expand Down Expand Up @@ -298,21 +307,21 @@ private static Set<String> listRootAssets(Context applicationContext) {

private static void initAot(Context applicationContext) {
Set<String> assets = listRootAssets(applicationContext);
sIsPrecompiled = assets.containsAll(Arrays.asList(
sIsPrecompiledAsBlobs = assets.containsAll(Arrays.asList(
sAotVmSnapshotData,
sAotVmSnapshotInstr,
sAotIsolateSnapshotData,
sAotIsolateSnapshotInstr
));
sIsPrecompiledAsSharedLibrary = assets.contains(sAotSharedLibraryPath);
if (sIsPrecompiled && sIsPrecompiledAsSharedLibrary) {
if (sIsPrecompiledAsBlobs && sIsPrecompiledAsSharedLibrary) {
throw new RuntimeException(
"Found precompiled app as shared library and as Dart VM snapshots.");
}
}

public static boolean isRunningPrecompiledCode() {
return sIsPrecompiled || sIsPrecompiledAsSharedLibrary;
return sIsPrecompiledAsBlobs || sIsPrecompiledAsSharedLibrary;
}

public static String findAppBundlePath(Context applicationContext) {
Expand Down
1 change: 1 addition & 0 deletions shell/platform/embedder/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ executable("embedder_unittests") {
deps = [
":embedder",
":fixtures",
"$flutter_root/lib/snapshot",
"$flutter_root/testing",
]

Expand Down
1 change: 1 addition & 0 deletions shell/testing/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ executable("testing") {
"$flutter_root/assets",
"$flutter_root/common",
"$flutter_root/fml",
"$flutter_root/lib/snapshot",
"$flutter_root/shell/common",
"//garnet/public/lib/fxl",
"//third_party/dart/runtime:libdart_jit",
Expand Down

0 comments on commit 86d96fd

Please sign in to comment.