Skip to content

Commit

Permalink
Fix RunBundleAndSource to run from kernel. (flutter#4184)
Browse files Browse the repository at this point in the history
* Fix RunBundleAndSource to run from kernel.

This is needed to accommodate restarting(rather than reload) of Flutter app from kernel.

* Fix formatting
  • Loading branch information
aam authored Oct 11, 2017
1 parent 1793f49 commit a5e26f1
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions shell/common/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,23 @@ void Engine::RunBundleAndSource(const std::string& bundle_path,
std::string packages_path = packages;
if (packages_path.empty())
packages_path = FindPackagesPath(main);
if (!bundle_path.empty())
ConfigureAssetBundle(bundle_path);
ConfigureRuntime(GetScriptUriFromPath(main));
load_script_error_ =
runtime_->dart_controller()->RunFromSource(main, packages_path);

std::vector<uint8_t> platform_kernel;
if (!bundle_path.empty()) {
GetAssetAsBuffer(blink::kPlatformKernelAssetKey, &platform_kernel);
}
ConfigureRuntime(GetScriptUriFromPath(bundle_path), platform_kernel);

if (!platform_kernel.empty()) {
std::vector<uint8_t> kernel;
if (!files::ReadFileToVector(main, &kernel)) {
load_script_error_ = tonic::kUnknownErrorType;
}
load_script_error_ = runtime_->dart_controller()->RunFromKernel(kernel);
} else {
load_script_error_ =
runtime_->dart_controller()->RunFromSource(main, packages_path);
}
}

void Engine::BeginFrame(fxl::TimePoint frame_time) {
Expand Down

0 comments on commit a5e26f1

Please sign in to comment.