From 22a0517fb6091e68e04adaa9519b8a3d2acbcc65 Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Wed, 17 Apr 2019 17:25:16 -0700 Subject: [PATCH] Assert that all VM launches in the process have the same opinion on whether the VM should be leaked in the process. (flutter/engine#8622) There is a possibility for a VM launch to not have a requisite shutdown if a previous launch asked to leak the VM instance in the process. Embedders have to ensure (via their Embedding APIs) that all instances of VM launch use consistent settings. --- engine/src/flutter/runtime/dart_vm_lifecycle.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/engine/src/flutter/runtime/dart_vm_lifecycle.cc b/engine/src/flutter/runtime/dart_vm_lifecycle.cc index ba6debf5d4..fc0721a30a 100644 --- a/engine/src/flutter/runtime/dart_vm_lifecycle.cc +++ b/engine/src/flutter/runtime/dart_vm_lifecycle.cc @@ -50,6 +50,14 @@ DartVMRef DartVMRef::Create(Settings settings, fml::RefPtr shared_snapshot) { std::lock_guard lifecycle_lock(gVMMutex); + if (!settings.leak_vm) { + FML_CHECK(!gVMLeak) + << "Launch settings indicated that the VM should shut down in the " + "process when done but a previous launch asked the VM to leak in " + "the same process. For proper VM shutdown, all VM launches must " + "indicate that they should shut down when done."; + } + // If there is already a running VM in the process, grab a strong reference to // it. if (auto vm = gVM.lock()) {