Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Triangle example panics when minimizing the window #1892

Closed
jedel1043 opened this issue May 7, 2022 · 4 comments
Closed

Triangle example panics when minimizing the window #1892

jedel1043 opened this issue May 7, 2022 · 4 comments

Comments

@jedel1043
Copy link

Issue

Running the triangle example and minimizing the window makes the program crash with the message:

thread 'main' panicked at 'assertion failed: image_extent[0] != 0 || image_extent[1] != 0'

The stacktrace points to the Swapchain::validate method as the culprit:

// VUID-VkSwapchainCreateInfoKHR-imageExtent-01689
// Shouldn't be possible with a properly behaving device
assert!(image_extent[0] != 0 || image_extent[1] != 0);

System Info

@ryco117
Copy link
Contributor

ryco117 commented May 7, 2022

@jedel1043 I can reaffirm that this is the behavior when minimizing on Windows, which coincidentally is why my new example from yesterday contains the check

let dimensions = surface.window().inner_size();
if dimensions.width == 0 && dimensions.height == 0 {
    return; // On Windows, minimizing sets surface to 0x0. Do not draw frame.
}

I'd be willing to shotgun this into the other examples so they don't crash on minimize.

@Rua @AustinJ235 I'm also curious if it makes sense to change the above assert into returning SwapchainCreationError::ImageExtentNotSupported since there is a plausible runtime condition for someone to pass a zero by zero dimensions. I will concede that it is still the callers responsibility to not attempt to create a zero by zero swapchain.

@AustinJ235
Copy link
Member

It might be more ergonomic to return an error in this case. Basalt has had this check in place for a while now, but from a new user perspective it might be confusing why their program panics.

@Rua
Copy link
Contributor

Rua commented May 7, 2022

I think turning this into a proper error makes sense, and adding it to the other examples. Do you want to make a PR for it?

@ryco117
Copy link
Contributor

ryco117 commented May 7, 2022

@AustinJ235 @Rua Thanks for the quick responses.

Curious. The assert statement references VUID-VkSwapchainCreateInfoKHR-imageExtent-01689, but the language of "width and height must both be non-zero" (emphasis theirs) suggests that neither dimension can be zero, whereas the code asserts at least one non-zero dim. Whoops.

Will make the appropriate validation and code-sample changes. Cheers

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants