From 394d367b3f95584a03910d46e0c3f6b5a3b0e018 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Thu, 4 May 2017 21:30:39 -0700 Subject: [PATCH] Retrieve the last error from the proper thread (flutter/engine#3649) Previously, the last error was a global static. Now it is a thread-specific value, which means we need to visit the UI thread to read the value. --- engine/src/flutter/shell/platform/linux/main_linux.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/engine/src/flutter/shell/platform/linux/main_linux.cc b/engine/src/flutter/shell/platform/linux/main_linux.cc index 25750fa6fe..cfd08ab243 100644 --- a/engine/src/flutter/shell/platform/linux/main_linux.cc +++ b/engine/src/flutter/shell/platform/linux/main_linux.cc @@ -102,8 +102,14 @@ void RunNonInteractive(ftl::CommandLine initial_command_line, test_runner.platform_view().engine().GetLoadScriptError(); if (error == tonic::kNoError) error = task_observer.last_error(); - if (error == tonic::kNoError) - error = tonic::DartMicrotaskQueue::GetForCurrentThread()->GetLastError(); + if (error == tonic::kNoError) { + ftl::AutoResetWaitableEvent latch; + blink::Threads::UI()->PostTask([&error, &latch] { + error = tonic::DartMicrotaskQueue::GetForCurrentThread()->GetLastError(); + latch.Signal(); + }); + latch.Wait(); + } // The script has completed and the engine may not be in a clean state, // so just stop the process.