From 25430a170b30f7ed645554849aecd81dacdf608b Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Mon, 13 Apr 2020 14:26:40 -0700 Subject: [PATCH 1/3] Run dart code on ui(rather than on platform) thread. Fixes https://github.com/flutter/flutter/issues/52576 --- testing/dart_isolate_runner.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/testing/dart_isolate_runner.cc b/testing/dart_isolate_runner.cc index 7212879d18407..137eb08476384 100644 --- a/testing/dart_isolate_runner.cc +++ b/testing/dart_isolate_runner.cc @@ -139,8 +139,11 @@ void RunDartCodeInIsolate(DartVMRef& vm_ref, return; } - if (!root_isolate->get()->Run(entrypoint, args, - settings.root_isolate_create_callback)) { + if (!root_isolate->RunInIsolateScope( + [&] { + return root_isolate->get()->Run(entrypoint, args, + settings.root_isolate_create_callback); + })) { FML_LOG(ERROR) << "Could not run the method \"" << entrypoint << "\" in the isolate."; return; From 457c6324146dfc4962280603068de9b288df41bf Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Mon, 13 Apr 2020 14:35:39 -0700 Subject: [PATCH 2/3] format --- testing/dart_isolate_runner.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/testing/dart_isolate_runner.cc b/testing/dart_isolate_runner.cc index 137eb08476384..333d5f63104e1 100644 --- a/testing/dart_isolate_runner.cc +++ b/testing/dart_isolate_runner.cc @@ -139,11 +139,10 @@ void RunDartCodeInIsolate(DartVMRef& vm_ref, return; } - if (!root_isolate->RunInIsolateScope( - [&] { - return root_isolate->get()->Run(entrypoint, args, - settings.root_isolate_create_callback); - })) { + if (!root_isolate->RunInIsolateScope([&] { + return root_isolate->get()->Run(entrypoint, args, + settings.root_isolate_create_callback); + })) { FML_LOG(ERROR) << "Could not run the method \"" << entrypoint << "\" in the isolate."; return; From 62442d5315d73969f3629e6c2f03666a515f9534 Mon Sep 17 00:00:00 2001 From: Alexander Aprelev Date: Mon, 13 Apr 2020 15:02:56 -0700 Subject: [PATCH 3/3] Move all code that sets up and isolate to UI thread as well --- testing/dart_isolate_runner.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/testing/dart_isolate_runner.cc b/testing/dart_isolate_runner.cc index 333d5f63104e1..8fe1d1f5ee09b 100644 --- a/testing/dart_isolate_runner.cc +++ b/testing/dart_isolate_runner.cc @@ -55,7 +55,7 @@ void RunDartCodeInIsolate(DartVMRef& vm_ref, const std::vector& args, const std::string& fixtures_path, fml::WeakPtr io_manager) { - FML_CHECK(task_runners.GetPlatformTaskRunner()->RunsTasksOnCurrentThread()); + FML_CHECK(task_runners.GetUITaskRunner()->RunsTasksOnCurrentThread()); if (!vm_ref) { return; @@ -139,10 +139,8 @@ void RunDartCodeInIsolate(DartVMRef& vm_ref, return; } - if (!root_isolate->RunInIsolateScope([&] { - return root_isolate->get()->Run(entrypoint, args, - settings.root_isolate_create_callback); - })) { + if (!root_isolate->get()->Run(entrypoint, args, + settings.root_isolate_create_callback)) { FML_LOG(ERROR) << "Could not run the method \"" << entrypoint << "\" in the isolate."; return; @@ -165,7 +163,7 @@ std::unique_ptr RunDartCodeInIsolate( std::unique_ptr result; fml::AutoResetWaitableEvent latch; fml::TaskRunner::RunNowOrPostTask( - task_runners.GetPlatformTaskRunner(), fml::MakeCopyable([&]() mutable { + task_runners.GetUITaskRunner(), fml::MakeCopyable([&]() mutable { RunDartCodeInIsolate(vm_ref, result, settings, task_runners, entrypoint, args, fixtures_path, io_manager); latch.Signal();