Skip to content

Commit

Permalink
Revert "Run Dart VM tasks on the engine's ConcurrentMessageLoop inste…
Browse files Browse the repository at this point in the history
…ad the VM's separate thread pool. (flutter#29819)" (flutter#30332)
  • Loading branch information
rmacnak-google authored Dec 15, 2021
1 parent e444009 commit 41472c3
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 62 deletions.
49 changes: 1 addition & 48 deletions runtime/dart_isolate_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -335,54 +335,7 @@ TEST_F(DartSecondaryIsolateTest, CanLaunchSecondaryIsolates) {
// root isolate will be auto-shutdown
}

static thread_local bool is_engine_worker = false;

TEST_F(DartSecondaryIsolateTest, VMTasksRunOnEngineThreads) {
AddNativeCallback("NotifyNative",
CREATE_NATIVE_ENTRY(([this](Dart_NativeArguments args) {
LatchCountDown();
})));
AddNativeCallback("PassMessage",
CREATE_NATIVE_ENTRY(([this](Dart_NativeArguments args) {
// Child isolate is running on concurrent message loop
// worker.
ASSERT_TRUE(is_engine_worker);
LatchCountDown();
})));
auto settings = CreateSettingsForFixture();
settings.root_isolate_shutdown_callback = [this]() {
RootIsolateShutdownSignal();
};
settings.isolate_shutdown_callback = [this]() { ChildShutdownSignal(); };
auto vm_ref = DartVMRef::Create(settings);

auto loop = vm_ref->GetConcurrentMessageLoop();
fml::CountDownLatch latch(loop->GetWorkerCount());
vm_ref->GetConcurrentMessageLoop()->PostTaskToAllWorkers([&] {
is_engine_worker = true;
latch.CountDown();
});
latch.Wait();

auto thread = CreateNewThread();
TaskRunners task_runners(GetCurrentTestName(), //
thread, //
thread, //
thread, //
thread //
);
auto isolate = RunDartCodeInIsolate(vm_ref, settings, task_runners,
"testCanLaunchSecondaryIsolate", {},
GetDefaultKernelFilePath());
ASSERT_TRUE(isolate);
ASSERT_EQ(isolate->get()->GetPhase(), DartIsolate::Phase::Running);
ChildShutdownWait(); // wait for child isolate to shutdown first
ASSERT_FALSE(RootIsolateIsSignaled());
LatchWait(); // wait for last NotifyNative called by main isolate
// root isolate will be auto-shutdown
}

TEST_F(DartIsolateTest, CanRecieveArguments) {
TEST_F(DartIsolateTest, CanReceiveArguments) {
AddNativeCallback("NotifyNative",
CREATE_NATIVE_ENTRY(([this](Dart_NativeArguments args) {
ASSERT_TRUE(tonic::DartConverter<bool>::FromDart(
Expand Down
14 changes: 0 additions & 14 deletions runtime/dart_vm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,6 @@ Dart_Handle GetVMServiceAssetsArchiveCallback() {
#endif
}

void PostTaskCallback(void* post_task_data,
Dart_Task task,
Dart_TaskData task_data) {
auto* dart_vm = reinterpret_cast<DartVM*>(post_task_data);
dart_vm->GetConcurrentWorkerTaskRunner()->PostTask(
[task] { Dart_RunTask(task); });
}

static const char kStdoutStreamId[] = "Stdout";
static const char kStderrStreamId[] = "Stderr";

Expand Down Expand Up @@ -450,8 +442,6 @@ DartVM::DartVM(std::shared_ptr<const DartVMData> vm_data,
params.thread_exit = ThreadExitCallback;
params.get_service_assets = GetVMServiceAssetsArchiveCallback;
params.entropy_source = dart::bin::GetEntropy;
params.post_task = PostTaskCallback;
params.post_task_data = this;
DartVMInitializer::Initialize(&params);
// Send the earliest available timestamp in the application lifecycle to
// timeline. The difference between this timestamp and the time we render
Expand Down Expand Up @@ -486,10 +476,6 @@ DartVM::DartVM(std::shared_ptr<const DartVMData> vm_data,
Dart_SetDartLibrarySourcesKernel(dart_library_sources->GetMapping(),
dart_library_sources->GetSize());
}

// Update thread names now that the Dart VM is initialized.
concurrent_message_loop_->PostTaskToAllWorkers(
[] { Dart_SetThreadName("FlutterConcurrentMessageLoopWorker"); });
}

DartVM::~DartVM() {
Expand Down

0 comments on commit 41472c3

Please sign in to comment.