-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
fix: Skip some rendering logics when the viewport width or height is zero #15654
Conversation
Welcome, new contributor! Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨ |
This works by hiding the problem. Would it be possible to stop rendering when the render target is (0,0)? I think this was done in a few places already |
Okay, I'll look into this more |
8c50e16
to
444d15f
Compare
(0, 0)
events when minimizing window on Windows OS
I've changed the approach |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simple change well executed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be off base or incur other kinds of sneaky bugs in the future, but I'm wondering if the methods on camera shouldn't check and return None
in the case of (0,0)
, is this ever a valid size that code would want to support? I guess None
is different than zero sized in the context of viewports, but for some reason I feel like we should try for a fix upstream rather than hard coding the 0 checks everywhere (which will surely also be forgotten in the future).
On the |
Objective
irradiance_volume
example causes a crash #15285Solution
winit
sends resized to zero events when the window is minimized only on Windows OS(rust-windowing/winit#2015).This makes updating window viewport size to
(0, 0)
and panicking when calculating aspect ratio.So, just skip these kinds of events - resizing to (0, 0) when the window is minimized - on Windows OSIdially, the camera extraction excludes the cameras whose target size width or height is zero here;
bevy/crates/bevy_render/src/camera/camera.rs
Lines 1060 to 1074 in 25bfa80
but it seems that winit event loop sends resize events after extraction and before post update schedule, so they might panics before the extraction filters them out.
Alternatively, it might be possible to change event loop evaluating order or defer them to the right schedule but I'm afraid that it might cause some breaking changes, so just skip rendering logics for such windows and they will be all filtered out by the extractions on the next frame and thereafter.
Testing
Running the example in the original issue and minimizing causes panic, or just running
tests/window/minimising.rs
withcargo run --example minimising
panics without this PR and doesn't panics with this PR.I think that we should run it in CI on Windows OS btw