Skip to content

Commit

Permalink
Support hot reload in corejit mode (flutter#5866)
Browse files Browse the repository at this point in the history
Since frontend_server --incremental doesn't support --link-platform, instead of baking host app into the snapshot, load it from kernel file when running in debug mode.
  • Loading branch information
sbaranov authored Jul 26, 2018
1 parent 66f87f4 commit f480e32
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions shell/platform/android/platform_view_android_jni.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,18 +184,26 @@ std::unique_ptr<IsolateConfiguration> CreateIsolateConfiguration(
const auto configuration_from_blob =
[&asset_manager](const std::string& snapshot_name)
-> std::unique_ptr<IsolateConfiguration> {
std::unique_ptr<fml::Mapping> blob =
asset_manager.GetAsMapping(snapshot_name);
auto blob = asset_manager.GetAsMapping(snapshot_name);
auto delta = asset_manager.GetAsMapping("kernel_delta.bin");
if (blob && delta) {
std::vector<std::unique_ptr<fml::Mapping>> kernels;
kernels.emplace_back(std::move(blob));
kernels.emplace_back(std::move(delta));
return IsolateConfiguration::CreateForKernelList(std::move(kernels));
}
if (blob) {
return IsolateConfiguration::CreateForSnapshot(std::move(blob));
}
if (delta) {
return IsolateConfiguration::CreateForSnapshot(std::move(delta));
}
return nullptr;
};

if (auto kernel = configuration_from_blob("kernel_blob.bin")) {
return kernel;
}

if (auto script = configuration_from_blob("snapshot_blob.bin")) {
return script;
}
Expand All @@ -209,14 +217,13 @@ static void RunBundleAndSnapshot(
jobject jcaller,
jlong shell_holder,
jstring jbundlepath,
jstring /* snapshot override (unused) */,
jstring jsnapshotOverride,
jstring jEntrypoint,
jboolean /* reuse runtime controller (unused) */,
jobject jAssetManager) {
auto asset_manager = fml::MakeRefCounted<blink::AssetManager>();

const auto bundlepath = fml::jni::JavaStringToString(env, jbundlepath);

if (bundlepath.size() > 0) {
// If we got a bundle path, attempt to use that as a directory asset
// bundle or a zip asset bundle.
Expand Down Expand Up @@ -244,8 +251,13 @@ static void RunBundleAndSnapshot(
}
}

auto isolate_configuration = CreateIsolateConfiguration(*asset_manager);
const auto defaultpath = fml::jni::JavaStringToString(env, jsnapshotOverride);
if (defaultpath.size() > 0) {
asset_manager->PushBack(std::make_unique<blink::DirectoryAssetBundle>(
fml::OpenFile(defaultpath.c_str(), fml::OpenPermission::kRead, true)));
}

auto isolate_configuration = CreateIsolateConfiguration(*asset_manager);
if (!isolate_configuration) {
FXL_DLOG(ERROR)
<< "Isolate configuration could not be determined for engine launch.";
Expand Down

0 comments on commit f480e32

Please sign in to comment.