From dfc5a3db4e9194ab5c33f9a730fae37df6a82b64 Mon Sep 17 00:00:00 2001 From: Sebastian Emanuel Dawid Date: Tue, 13 May 2025 11:27:22 +0200 Subject: [PATCH] Fix crash related to failure to acquire next swapchain image during resizing --- examples/swapchain.zig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/examples/swapchain.zig b/examples/swapchain.zig index a8f1c06..db81de0 100644 --- a/examples/swapchain.zig +++ b/examples/swapchain.zig @@ -80,7 +80,11 @@ pub const Swapchain = struct { errdefer gc.dev.destroySemaphore(next_image_acquired, null); const result = try gc.dev.acquireNextImageKHR(handle, std.math.maxInt(u64), next_image_acquired, .null_handle); - if (result.result != .success) { + // event with a .suboptimal_khr we can still go on to present + // if we error even for .suboptimal_khr the example will crash and segfault + // on resize, since even the recreated swapchain can be suboptimal during a + // resize. + if (result.result == .not_ready or result.result == .timeout) { return error.ImageAcquireFailed; }