Don't send platform messages to isolates that are not running. (flutter/engine#5031)

Isolates may be launched and awaiting snapshot association. We don't
want to send such isolates any messages before their "main" method is
called. In such cases, the engine may intercept and store certain
launch specific information.
This commit is contained in:
Chinmay Garde
2018-04-17 17:10:17 -07:00
committed by GitHub
parent 94586c2dac
commit e45e1c17b2
3 changed files with 11 additions and 1 deletions

View File

@@ -78,6 +78,13 @@ RuntimeController::~RuntimeController() {
}
}
bool RuntimeController::IsRootIsolateRunning() const {
if (root_isolate_) {
return root_isolate_->GetPhase() == DartIsolate::Phase::Running;
}
return false;
}
std::unique_ptr<RuntimeController> RuntimeController::Clone() const {
return std::unique_ptr<RuntimeController>(new RuntimeController(
client_, //

View File

@@ -46,6 +46,8 @@ class RuntimeController final : public WindowClient {
bool NotifyIdle(int64_t deadline);
bool IsRootIsolateRunning() const;
bool DispatchPlatformMessage(fxl::RefPtr<PlatformMessage> message);
bool DispatchPointerDataPacket(const PointerDataPacket& packet);

View File

@@ -259,7 +259,8 @@ void Engine::DispatchPlatformMessage(
return;
}
if (runtime_controller_->DispatchPlatformMessage(std::move(message))) {
if (runtime_controller_->IsRootIsolateRunning() &&
runtime_controller_->DispatchPlatformMessage(std::move(message))) {
return;
}