Revert "Replace array<fml::Thread, 3> with ThreadHost. (#27455)" This reverts commit 9e5999d7ca9490060a23d0521c130be3f89fdb25.
diff --git a/shell/platform/fuchsia/flutter/engine.cc b/shell/platform/fuchsia/flutter/engine.cc index 350e0e4..0c5c615 100644 --- a/shell/platform/fuchsia/flutter/engine.cc +++ b/shell/platform/fuchsia/flutter/engine.cc
@@ -34,6 +34,23 @@ namespace flutter_runner { namespace { +void UpdateNativeThreadLabelNames(const std::string& label, + const flutter::TaskRunners& runners) { + auto set_thread_name = [](fml::RefPtr<fml::TaskRunner> runner, + std::string prefix, std::string suffix) { + if (!runner) { + return; + } + fml::TaskRunner::RunNowOrPostTask(runner, [name = prefix + suffix]() { + zx::thread::self()->set_property(ZX_PROP_NAME, name.c_str(), name.size()); + }); + }; + set_thread_name(runners.GetPlatformTaskRunner(), label, ".platform"); + set_thread_name(runners.GetUITaskRunner(), label, ".ui"); + set_thread_name(runners.GetRasterTaskRunner(), label, ".raster"); + set_thread_name(runners.GetIOTaskRunner(), label, ".io"); +} + std::unique_ptr<flutter::PlatformMessage> MakeLocalizationPlatformMessage( const fuchsia::intl::Profile& intl_profile) { return std::make_unique<flutter::PlatformMessage>( @@ -55,10 +72,6 @@ FlutterRunnerProductConfiguration product_config) : delegate_(delegate), thread_label_(std::move(thread_label)), - thread_host_(thread_label_ + ".", - flutter::ThreadHost::Type::RASTER | - flutter::ThreadHost::Type::UI | - flutter::ThreadHost::Type::IO), intercept_all_input_(product_config.get_intercept_all_input()), weak_factory_(this) { // Get the task runners from the managed threads. The current thread will be @@ -67,12 +80,13 @@ fml::MessageLoop::GetCurrent().GetTaskRunner(); const flutter::TaskRunners task_runners( - thread_label_, // Dart thread labels - platform_task_runner, // platform - thread_host_.raster_thread->GetTaskRunner(), // raster - thread_host_.ui_thread->GetTaskRunner(), // ui - thread_host_.io_thread->GetTaskRunner() // io + thread_label_, // Dart thread labels + platform_task_runner, // platform + threads_[0].GetTaskRunner(), // raster + threads_[1].GetTaskRunner(), // ui + threads_[2].GetTaskRunner() // io ); + UpdateNativeThreadLabelNames(thread_label_, task_runners); // Connect to Scenic. auto scenic = svc->Connect<fuchsia::ui::scenic::Scenic>(); @@ -470,6 +484,9 @@ Engine::~Engine() { shell_.reset(); + for (auto& thread : threads_) { + thread.Join(); + } } std::optional<uint32_t> Engine::GetEngineReturnCode() const {
diff --git a/shell/platform/fuchsia/flutter/engine.h b/shell/platform/fuchsia/flutter/engine.h index bc7a66f..33c704f 100644 --- a/shell/platform/fuchsia/flutter/engine.h +++ b/shell/platform/fuchsia/flutter/engine.h
@@ -21,7 +21,6 @@ #include "flutter/flow/surface.h" #include "flutter/fml/macros.h" #include "flutter/shell/common/shell.h" -#include "flutter/shell/common/thread_host.h" #include "flutter/shell/platform/fuchsia/flutter/accessibility_bridge.h" #include "flutter_runner_product_configuration.h" @@ -69,7 +68,7 @@ Delegate& delegate_; const std::string thread_label_; - flutter::ThreadHost thread_host_; + std::array<fml::Thread, 3> threads_; std::shared_ptr<GfxSessionConnection> session_connection_; std::optional<VulkanSurfaceProducer> surface_producer_;