Skip to content

Commit d523f96

Browse files
committed
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.
1 parent f648c27 commit d523f96

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/video_display/vulkan/vulkan_display.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,9 +575,12 @@ bool VulkanDisplay::display_queued_image() {
575575
int swapchain_recreation_attempt = 0;
576576
while (swapchain_image_id == swapchain_image_out_of_date || swapchain_image_id == swapchain_image_timeout)
577577
{
578+
const int swapchain_recreation_warn_tries = 50;
578579
swapchain_recreation_attempt++;
579-
if (swapchain_recreation_attempt > 3) {
580-
throw VulkanError{"Cannot acquire swapchain image"};
580+
if (swapchain_image_id == swapchain_image_timeout){
581+
vulkan_log_msg(LogLevel::warning, "Swapchain image acquire timed out\n");
582+
} else if (swapchain_recreation_attempt > swapchain_recreation_warn_tries) {
583+
vulkan_log_msg(LogLevel::warning, "Swapchain image acquire failed "s + std::to_string(swapchain_recreation_warn_tries) + "times in a row\n");
581584
}
582585

583586
auto window_parameters = window->get_window_parameters();

0 commit comments

Comments
 (0)