From 5a78bd2f4d662485696d0130e3f195906c1b0438 Mon Sep 17 00:00:00 2001 From: chenjianguang Date: Tue, 2 Jun 2020 07:13:02 +0800 Subject: [PATCH] Fix BM_ShellShutdown regression (flutter/engine#18676) --- engine/src/flutter/shell/common/shell_benchmarks.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/engine/src/flutter/shell/common/shell_benchmarks.cc b/engine/src/flutter/shell/common/shell_benchmarks.cc index 9d3a1a36f9..2232997a38 100644 --- a/engine/src/flutter/shell/common/shell_benchmarks.cc +++ b/engine/src/flutter/shell/common/shell_benchmarks.cc @@ -66,6 +66,17 @@ static void StartupAndShutdownShell(benchmark::State& state, FML_CHECK(shell); + { + // The ui thread could be busy processing tasks after shell created, e.g., + // default font manager setup. The measurement of shell shutdown should be + // considered after those ui tasks have been done. + benchmarking::ScopedPauseTiming pause(state, true); + fml::AutoResetWaitableEvent latch; + fml::TaskRunner::RunNowOrPostTask(thread_host->ui_thread->GetTaskRunner(), + [&latch]() { latch.Signal(); }); + latch.Wait(); + } + { benchmarking::ScopedPauseTiming pause(state, !measure_shutdown); // Shutdown must occur synchronously on the platform thread.