From 326bd99dc95b27728be01a2bc9963df201b53751 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Thu, 5 Sep 2024 13:49:56 -0700 Subject: [PATCH] [engine] always force platform channel responses to schedule a task. (flutter/engine#54975) If we use runNowOrPostTask on platform channel responses, then we may not wake up the dart message loop. If nothing else wakes it up, then the embedder may hang on platform channel responses. This fixes several google3 integration tests when run in merged thread mode. --- engine/src/flutter/shell/common/shell.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/engine/src/flutter/shell/common/shell.cc b/engine/src/flutter/shell/common/shell.cc index 79c532640a..a23bc5498e 100644 --- a/engine/src/flutter/shell/common/shell.cc +++ b/engine/src/flutter/shell/common/shell.cc @@ -1076,10 +1076,10 @@ void Shell::OnPlatformViewDispatchPlatformMessage( // The static leak checker gets confused by the use of fml::MakeCopyable. // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) - fml::TaskRunner::RunNowOrPostTask( - task_runners_.GetUITaskRunner(), - fml::MakeCopyable([engine = engine_->GetWeakPtr(), - message = std::move(message)]() mutable { + // This logic must always explicitly post a task so that we are guaranteed + // to wake up the UI message loop to flush tasks. + task_runners_.GetUITaskRunner()->PostTask(fml::MakeCopyable( + [engine = engine_->GetWeakPtr(), message = std::move(message)]() mutable { if (engine) { engine->DispatchPlatformMessage(std::move(message)); }