From 4fcf481fb392b12ebddaaaee7c2247f3f18fe238 Mon Sep 17 00:00:00 2001 From: Ben Bergkamp Date: Thu, 22 Sep 2022 14:46:38 -0500 Subject: [PATCH] [fuchsia] Write trace profiles for v2 components (flutter/engine#36186) --- .../shell/platform/fuchsia/flutter/runner.cc | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/runner.cc b/engine/src/flutter/shell/platform/fuchsia/flutter/runner.cc index eaf8f6ed51c..97cb8dda9b8 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/runner.cc +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/runner.cc @@ -398,17 +398,20 @@ void Runner::SetupTraceObserver() { runner->prolonged_context_ = trace_acquire_prolonged_context(); Dart_StartProfiling(); } else if (trace_state() == TRACE_STOPPING) { - for (auto& it : runner->active_components_v1_) { - fml::AutoResetWaitableEvent latch; - fml::TaskRunner::RunNowOrPostTask( - it.second.platform_thread->GetTaskRunner(), [&]() { - it.second.component->WriteProfileToTrace(); - latch.Signal(); - }); - latch.Wait(); - } - // TODO(fxb/50694): Write v2 component profiles to trace once we're - // convinced they're stable. + auto write_profile_trace_for_components = [](auto& components) { + for (auto& it : components) { + fml::AutoResetWaitableEvent latch; + fml::TaskRunner::RunNowOrPostTask( + it.second.platform_thread->GetTaskRunner(), [&]() { + it.second.component->WriteProfileToTrace(); + latch.Signal(); + }); + latch.Wait(); + } + }; + write_profile_trace_for_components(runner->active_components_v1_); + write_profile_trace_for_components(runner->active_components_v2_); + Dart_StopProfiling(); trace_release_prolonged_context(runner->prolonged_context_); }