未验证 提交 2f19645a 编写于 作者: C Chinmay Garde 提交者: GitHub

Wait for Dart VM initialization before the letting the service isolate...

Wait for Dart VM initialization before the letting the service isolate constructor access the VM object. (#6028)

The service isolate creation callback may occur on a background thread before
the call the Dart_Initialize within the DartVM construtor can finish. We store
pointers to various snapshots within the DartVM object. These snapshots are
necessary for to successfully create the service isolate. The isolate creation
callback access the global object within the ForProcessIfInitialized method.
This method can return null if the VM object has not been initialized. This
leads to the service protocol failing to start in a non-deterministic manner.
This patch moves the creation and access of the DartVM object within a critical
section.
上级 9c0c6201
......@@ -257,6 +257,7 @@ fml::RefPtr<DartVM> DartVM::ForProcess(Settings settings) {
}
static std::once_flag gVMInitialization;
static std::mutex gVMMutex;
static fml::RefPtr<DartVM> gVM;
fml::RefPtr<DartVM> DartVM::ForProcess(
......@@ -264,6 +265,7 @@ fml::RefPtr<DartVM> DartVM::ForProcess(
fml::RefPtr<DartSnapshot> vm_snapshot,
fml::RefPtr<DartSnapshot> isolate_snapshot,
fml::RefPtr<DartSnapshot> shared_snapshot) {
std::lock_guard<std::mutex> lock(gVMMutex);
std::call_once(gVMInitialization, [settings, //
vm_snapshot, //
isolate_snapshot, //
......@@ -296,6 +298,7 @@ fml::RefPtr<DartVM> DartVM::ForProcess(
}
fml::RefPtr<DartVM> DartVM::ForProcessIfInitialized() {
std::lock_guard<std::mutex> lock(gVMMutex);
return gVM;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册