From a656286e39e58e1b259dbadb64552564671faf15 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Tue, 13 Feb 2024 14:33:16 -0800 Subject: [PATCH] [Impeller] fix cmd buffer recycling bug in test. (flutter/engine#50615) Speculative fix for a flake seen by @matanlurey . In the past we've seen race conditions when a single DeathRattle is used, because it actually gets destructed before the cmd pool state. By adding two and waiting we guaranteee that everything has completed in the resource manager. --- .../backend/vulkan/command_pool_vk_unittests.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/engine/src/flutter/impeller/renderer/backend/vulkan/command_pool_vk_unittests.cc b/engine/src/flutter/impeller/renderer/backend/vulkan/command_pool_vk_unittests.cc index e3a330552f7..880c40d664b 100644 --- a/engine/src/flutter/impeller/renderer/backend/vulkan/command_pool_vk_unittests.cc +++ b/engine/src/flutter/impeller/renderer/backend/vulkan/command_pool_vk_unittests.cc @@ -128,13 +128,15 @@ TEST(CommandPoolRecyclerVKTest, CommandBuffersAreRecycled) { } // Wait for the pool to be reclaimed. - auto waiter = fml::AutoResetWaitableEvent(); - auto rattle = DeathRattle([&waiter]() { waiter.Signal(); }); - { - UniqueResourceVKT resource(context->GetResourceManager(), - std::move(rattle)); + for (auto i = 0u; i < 2u; i++) { + auto waiter = fml::AutoResetWaitableEvent(); + auto rattle = DeathRattle([&waiter]() { waiter.Signal(); }); + { + UniqueResourceVKT resource(context->GetResourceManager(), + std::move(rattle)); + } + waiter.Wait(); } - waiter.Wait(); { // Create a second pool and command buffer, which should reused the existing