未验证 提交 613abf2d 编写于 作者: C Chinmay Garde 提交者: GitHub

Terminate the engine immediately if there are isolate launch errors. (#5244)

上级 b34ab183
......@@ -204,12 +204,27 @@ Engine::Engine(Delegate& delegate,
auto run_configuration =
shell::RunConfiguration::InferFromSettings(settings_);
auto on_run_failure = [weak = weak_factory_.GetWeakPtr(), //
runner =
fsl::MessageLoop::GetCurrent()->task_runner() //
]() {
// The engine could have been killed by the caller right after the
// constructor was called but before it could run on the UI thread.
if (weak) {
weak->Terminate();
}
};
shell_->GetTaskRunners().GetUITaskRunner()->PostTask(
fxl::MakeCopyable([engine = shell_->GetEngine(), //
run_configuration = std::move(run_configuration) //
fxl::MakeCopyable([engine = shell_->GetEngine(), //
run_configuration = std::move(run_configuration), //
on_run_failure //
]() mutable {
if (!engine || !engine->Run(std::move(run_configuration))) {
FXL_LOG(ERROR) << "Could not (re)launch the engine in configuration";
if (!engine) {
return;
}
if (!engine->Run(std::move(run_configuration))) {
on_run_failure();
}
}));
}
......
......@@ -109,6 +109,7 @@ bool Engine::Run(RunConfiguration configuration) {
}
if (!PrepareAndLaunchIsolate(std::move(configuration))) {
FXL_LOG(ERROR) << "Engine not prepare and launch isolate.";
return false;
}
......@@ -143,12 +144,12 @@ bool Engine::PrepareAndLaunchIsolate(RunConfiguration configuration) {
auto isolate = runtime_controller_->GetRootIsolate();
if (!isolate_configuration->PrepareIsolate(isolate)) {
FXL_DLOG(ERROR) << "Could not prepare to run the isolate.";
FXL_LOG(ERROR) << "Could not prepare to run the isolate.";
return false;
}
if (!isolate->Run(configuration.GetEntrypoint())) {
FXL_DLOG(ERROR) << "Could not run the isolate.";
FXL_LOG(ERROR) << "Could not run the isolate.";
return false;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册