Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Don't resize when viewport 0x0 #545

Closed
wants to merge 4 commits into from
Closed

Don't resize when viewport 0x0 #545

wants to merge 4 commits into from

Conversation

Dispersia
Copy link
Contributor

@Dispersia Dispersia commented Sep 21, 2020

This is a hack to prevent wgpu from crashing bevy when size set to a width or height of 0. Wgpu currently crashes on its swapchain under this condition, winit sends a resize event (of 0x0) on minimize, and if the user click and drag resizes to 0 width or 0 height it crashes as well.

You will not get an event of a 0 width or 0 height resize, so if you want to check for minimized you would need to check window flags on the winit window (I don't think you should check 0x0 for minimized regardless)

This should be removed when gfx-rs/wgpu-rs#316 is fixed

Fixes #170

@karroffel karroffel added C-Bug An unexpected or incorrect behavior P-Crash A sudden unexpected crash C-Dependencies A change to the crates that Bevy depends on A-Windowing Platform-agnostic interface layer to run your app in labels Sep 21, 2020
@DJMcNab
Copy link
Member

DJMcNab commented Sep 21, 2020

I feel like we should fix this in the rendering pipeline side (i.e. in bevy_wgpu), by just not rendering anything to the surface at all.
I don't know how feasible this is however

@cart
Copy link
Member

cart commented Sep 21, 2020

Its a tough call. I agree that doing it in bevy_wgpu is nice because it scopes the problem, but it also means that render state is then out of sync with window state. This hack seems fine because it makes "bevy's view of the world" consistent.

@Dispersia I'm down to merge this, but can we add a comment to the code that explains the hack and links to the wgpu issue?

@DJMcNab
Copy link
Member

DJMcNab commented Sep 21, 2020

I feel like gfx-rs/wgpu-rs#531 or gfx-rs/wgpu-rs#316 are perhaps more relevant; that is I don't think gfx-rs/wgpu-rs#352 is actually persuant to this issue, as that is about any resizing on vulkan, not this issue which is resizing to a zero-dimensioned window.

@cart
Copy link
Member

cart commented Sep 21, 2020

Hmm looks like Wgpu worked around this in their examples by ensuring swap chain textures are always > 0 (basically what @DJMcNab suggested). I guess we should probably use their approach and link to the issues @DJMcNab called out.

@Dispersia
Copy link
Contributor Author

Sounds good, I will make that change instead. Seems strange since we can try to manipulate the view in a different state, but this is a weird issue in the first place

@alice-i-cecile
Copy link
Member

I think this should be closed in favor of #1409.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior C-Dependencies A change to the crates that Bevy depends on P-Crash A sudden unexpected crash
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Decreasing window height to 0 causes crash
5 participants