From b7345ada3c46e0cc8df4194cb8481808dcb266c9 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Tue, 20 Aug 2019 14:11:45 -0700 Subject: [PATCH] Fix a segfault in EmbedderTest.CanSpecifyCustomTaskRunner (flutter/engine#11305) This test queues tasks to a custom task runner that runs the tasks on the platform thread. After shutting down the engine, the test must wait until these tasks are drained before the test exits. --- .../shell/platform/embedder/tests/embedder_unittests.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/shell/platform/embedder/tests/embedder_unittests.cc b/engine/src/flutter/shell/platform/embedder/tests/embedder_unittests.cc index 3d204bd4db..717926691d 100644 --- a/engine/src/flutter/shell/platform/embedder/tests/embedder_unittests.cc +++ b/engine/src/flutter/shell/platform/embedder/tests/embedder_unittests.cc @@ -208,7 +208,11 @@ TEST_F(EmbedderTest, CanSpecifyCustomTaskRunner) { platform_task_runner->PostTask(fml::MakeCopyable([&]() mutable { std::scoped_lock lock(engine_mutex); engine.reset(); - kill_latch.Signal(); + + // There may still be pending tasks on the platform thread that were queued + // by the test_task_runner. Signal the latch after these tasks have been + // consumed. + platform_task_runner->PostTask([&kill_latch] { kill_latch.Signal(); }); })); kill_latch.Wait();