Fix crash on exit In RendererImpl::~RendererImpl, we have the following indirect call stack: * teardownGlobalVkEmulation * FrameBuffer::~FrameBuffer * FrameBuffer::finalize * RenderWindow::~RenderWindow Triggers FrameBuffer::finalize indirectly by sending the finalize command * RendererImpl::~RendererImpl However, teardownGlobalVkEmulation shouldn't be called until mCleanupThread has exited, because we may have queued Vulkan objects cleanups on that thread by calling FrameBuffer::registerProcessCleanupCallback in on_vkCreateInstance, and the clean up may depend on the global Vulkan emulation object. Test: build Change-Id: I667f2685dd9dc5749244844a3259e51a3250de7b
diff --git a/host/RendererImpl.cpp b/host/RendererImpl.cpp index bd224ef..c1fb7dd 100644 --- a/host/RendererImpl.cpp +++ b/host/RendererImpl.cpp
@@ -184,6 +184,7 @@ for (const auto& c : mStoppedChannels) { c->renderThread()->wait(); } + mCleanupThread->waitForCleanup(); mStoppedChannels.clear(); }