From a5e26f1f794ad138d59b3115165ba84ac413e891 Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Wed, 11 Oct 2017 16:04:57 -0700 Subject: [PATCH] Fix RunBundleAndSource to run from kernel. (#4184) * Fix RunBundleAndSource to run from kernel. This is needed to accommodate restarting(rather than reload) of Flutter app from kernel. * Fix formatting --- shell/common/engine.cc | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/shell/common/engine.cc b/shell/common/engine.cc index ce8617c44..9f84087ec 100644 --- a/shell/common/engine.cc +++ b/shell/common/engine.cc @@ -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 platform_kernel; + if (!bundle_path.empty()) { + GetAssetAsBuffer(blink::kPlatformKernelAssetKey, &platform_kernel); + } + ConfigureRuntime(GetScriptUriFromPath(bundle_path), platform_kernel); + + if (!platform_kernel.empty()) { + std::vector 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) { -- GitLab