From 0956c6a8d38e19792db4d01dd4baefbf27bd7e30 Mon Sep 17 00:00:00 2001 From: Martin Piatka Date: Thu, 20 Mar 2025 13:18:22 +0100 Subject: [PATCH] disp/vulkan: Don't crash when image acquire fails multiple times It is not uncommon for swapchain image acquire to fail multiple times in a row e.g. when the user is continuously resizing the windown with the mouse cursor. There is really no need to raise an exception and crash the whole process. --- src/video_display/vulkan/vulkan_display.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/video_display/vulkan/vulkan_display.cpp b/src/video_display/vulkan/vulkan_display.cpp index 69ca8efea..fdf56ce81 100644 --- a/src/video_display/vulkan/vulkan_display.cpp +++ b/src/video_display/vulkan/vulkan_display.cpp @@ -564,9 +564,12 @@ bool VulkanDisplay::display_queued_image() { int swapchain_recreation_attempt = 0; while (swapchain_image_id == swapchain_image_out_of_date || swapchain_image_id == swapchain_image_timeout) { + const int swapchain_recreation_warn_tries = 50; swapchain_recreation_attempt++; - if (swapchain_recreation_attempt > 3) { - throw VulkanError{"Cannot acquire swapchain image"}; + if (swapchain_image_id == swapchain_image_timeout){ + vulkan_log_msg(LogLevel::warning, "Swapchain image acquire timed out\n"); + } else if (swapchain_recreation_attempt > swapchain_recreation_warn_tries) { + vulkan_log_msg(LogLevel::warning, "Swapchain image acquire failed "s + std::to_string(swapchain_recreation_warn_tries) + "times in a row\n"); } auto window_parameters = window->get_window_parameters();