[Impeller] Do not free a Vulkan command buffer if its command pool has already been destroyed (flutter/engine#41761)

Fixes https://github.com/flutter/flutter/issues/125519
This commit is contained in:
Jason Simmons
2023-05-05 11:49:57 -07:00
committed by GitHub
parent 05036058d7
commit 87a63996d7
2 changed files with 7 additions and 0 deletions

View File

@@ -37,6 +37,8 @@ class TrackedObjectsVK {
if (!pool) {
VALIDATION_LOG
<< "Command pool died before a command buffer could be recycled.";
// The buffer can not be freed if its command pool has been destroyed.
buffer_.release();
return;
}
pool->CollectGraphicsCommandBuffer(std::move(buffer_));

View File

@@ -123,6 +123,11 @@ vk::UniqueCommandBuffer CommandPoolVK::CreateGraphicsCommandBuffer() {
void CommandPoolVK::CollectGraphicsCommandBuffer(
vk::UniqueCommandBuffer buffer) {
Lock lock(buffers_to_collect_mutex_);
if (!graphics_pool_) {
// If the command pool has already been destroyed, then its command buffers
// have been freed and are now invalid.
buffer.release();
}
buffers_to_collect_.insert(MakeSharedVK(std::move(buffer)));
GarbageCollectBuffersIfAble();
}