diff --git a/android/app/src/cpp/android_host_interface.cpp b/android/app/src/cpp/android_host_interface.cpp index 8f890041b..ea4ec3dd0 100644 --- a/android/app/src/cpp/android_host_interface.cpp +++ b/android/app/src/cpp/android_host_interface.cpp @@ -754,13 +754,13 @@ void AndroidHostInterface::SurfaceChanged(ANativeWindow* surface, int format, in wi.surface_refresh_rate = GetRefreshRate(); wi.surface_scale = GetSurfaceScale(width, height); - m_display->ChangeRenderWindow(wi); - if (surface) + const bool surface_valid = m_display->ChangeRenderWindow(wi) && surface; + if (surface_valid) OnHostDisplayResized(); - if (surface && System::GetState() == System::State::Paused) + if (surface_valid && System::GetState() == System::State::Paused) PauseSystem(false); - else if (!surface && System::IsRunning()) + else if (!surface_valid && System::IsRunning()) PauseSystem(true); } } diff --git a/src/common/vulkan/swap_chain.cpp b/src/common/vulkan/swap_chain.cpp index 5be3dae05..5a2163e83 100644 --- a/src/common/vulkan/swap_chain.cpp +++ b/src/common/vulkan/swap_chain.cpp @@ -742,7 +742,8 @@ bool SwapChain::ResizeSwapChain(u32 new_width /* = 0 */, u32 new_height /* = 0 * if (!CreateSwapChain() || !SetupSwapChainImages()) { - Panic("Failed to re-configure swap chain images, this is fatal (for now)"); + DestroySwapChainImages(); + DestroySwapChain(); return false; } @@ -755,7 +756,8 @@ bool SwapChain::RecreateSwapChain() if (!CreateSwapChain() || !SetupSwapChainImages()) { - Panic("Failed to re-configure swap chain images, this is fatal (for now)"); + DestroySwapChainImages(); + DestroySwapChain(); return false; } diff --git a/src/frontend-common/vulkan_host_display.cpp b/src/frontend-common/vulkan_host_display.cpp index 84efeaffb..6f1f8e37e 100644 --- a/src/frontend-common/vulkan_host_display.cpp +++ b/src/frontend-common/vulkan_host_display.cpp @@ -576,7 +576,7 @@ bool VulkanHostDisplay::DoneRenderContextCurrent() bool VulkanHostDisplay::Render() { - if (ShouldSkipDisplayingFrame()) + if (ShouldSkipDisplayingFrame() || !m_swap_chain) { if (ImGui::GetCurrentContext()) ImGui::Render(); @@ -602,6 +602,7 @@ bool VulkanHostDisplay::Render() { Log_ErrorPrint("Failed to recreate surface after loss"); g_vulkan_context->ExecuteCommandBuffer(false); + m_swap_chain.reset(); return false; }