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

Minimizing window in the irradiance_volume example causes a crash #15285

Closed
cryscan opened this issue Sep 18, 2024 · 0 comments · Fixed by #15654
Closed

Minimizing window in the irradiance_volume example causes a crash #15285

cryscan opened this issue Sep 18, 2024 · 0 comments · Fixed by #15654
Labels
A-Rendering Drawing game state to the screen A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior P-Crash A sudden unexpected crash S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it!

Comments

@cryscan
Copy link
Contributor

cryscan commented Sep 18, 2024

Bevy version

main (6954146)

[Optional] Relevant system information

Windows 11

What you did

Run the irradiance_volume example, and minimize the window.

What went wrong

The app crashes immediately.

Additional information

2024-09-18T12:43:55.667993Z  INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "Windows 11 Pro", kernel: "22631", cpu: "13th Gen Intel(R) Core(TM) i7-13700H", core_count: "14", memory: "31.6 GiB" }
2024-09-18T12:44:00.968369Z  INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA RTX 2000 Ada Generation Laptop GPU", vendor: 4318, device: 10424, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "529.08", backend: Vulkan }
2024-09-18T12:44:02.627833Z  INFO bevy_winit::system: Creating new window "Bevy Irradiance Volumes Example" (0v1#4294967296)
thread 'Compute Task Pool (2)' panicked at crates\bevy_render\src\camera\projection.rs:194:14:
Failed to update PerspectiveProjection: width and height must be positive, non-zero values: Zero
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\std\src\panicking.rs:665
   1: core::panicking::panic_fmt
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\core\src\panicking.rs:74
   2: core::result::unwrap_failed
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\core\src\result.rs:1679
   3: enum2$<core::result::Result<bevy_math::aspect_ratio::AspectRatio,bevy_math::aspect_ratio::AspectRatioError> >::expect<bevy_math::aspect_ratio::AspectRatio,bevy_math::aspect_ratio::AspectRatioError>
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c\library\core\src\result.rs:1059
   4: bevy_render::camera::projection::impl$6::update
             at .\crates\bevy_render\src\camera\projection.rs:193
   5: bevy_render::camera::projection::impl$4::update
             at .\crates\bevy_render\src\camera\projection.rs:129
   6: bevy_render::camera::camera::camera_system<enum2$<bevy_render::camera::projection::Projection> >
             at .\crates\bevy_render\src\camera\camera.rs:890
   7: core::ops::function::FnMut::call_mut<void (*)(bevy_ecs::event::reader::EventReader<bevy_window::event::WindowResized>,bevy_ecs::event::reader::EventReader<bevy_window::event::WindowCreated>,bevy_ecs::event::reader::EventReader<bevy_window::event::WindowSca
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c\library\core\src\ops\function.rs:166
   8: core::ops::function::impls::impl$3::call_mut<tuple$<bevy_ecs::event::reader::EventReader<bevy_window::event::WindowResized>,bevy_ecs::event::reader::EventReader<bevy_window::event::WindowCreated>,bevy_ecs::event::reader::EventReader<bevy_window::event::Win
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c\library\core\src\ops\function.rs:294
   9: bevy_ecs::system::function_system::impl$45::run::call_inner<tuple$<>,bevy_ecs::event::reader::EventReader<bevy_window::event::WindowResized>,bevy_ecs::event::reader::EventReader<bevy_window::event::WindowCreated>,bevy_ecs::event::reader::EventReader<bevy_w
             at .\crates\bevy_ecs\src\system\function_system.rs:798
  10: bevy_ecs::system::function_system::impl$45::run<tuple$<>,void (*)(bevy_ecs::event::reader::EventReader<bevy_window::event::WindowResized>,bevy_ecs::event::reader::EventReader<bevy_window::event::WindowCreated>,bevy_ecs::event::reader::EventReader<bevy_wind
             at .\crates\bevy_ecs\src\system\function_system.rs:801
  11: bevy_ecs::system::function_system::impl$7::run_unsafe<void (*)(bevy_ecs::event::reader::EventReader<bevy_window::event::WindowResized>,bevy_ecs::event::reader::EventReader<bevy_window::event::WindowCreated>,bevy_ecs::event::reader::EventReader<bevy_window:
             at .\crates\bevy_ecs\src\system\function_system.rs:622
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Encountered a panic in system `bevy_render::camera::camera::camera_system<bevy_render::camera::projection::Projection>`!
thread 'Compute Task Pool (2)' panicked at crates\bevy_pbr\src\cluster\mod.rs:261:22:
Failed to calculate aspect ratio for Cluster: screen dimensions must be positive, non-zero values: Zero
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\std\src\panicking.rs:665
   1: core::panicking::panic_fmt
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\core\src\panicking.rs:74
   2: core::result::unwrap_failed
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\core\src\result.rs:1679
   3: enum2$<core::result::Result<bevy_math::aspect_ratio::AspectRatio,bevy_math::aspect_ratio::AspectRatioError> >::expect<bevy_math::aspect_ratio::AspectRatio,bevy_math::aspect_ratio::AspectRatioError>
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c\library\core\src\result.rs:1059
   4: enum2$<bevy_pbr::cluster::ClusterConfig>::dimensions_for_screen_size
             at .\crates\bevy_pbr\src\cluster\mod.rs:260
   5: bevy_pbr::cluster::assign::assign_objects_to_clusters
             at .\crates\bevy_pbr\src\cluster\assign.rs:217
   6: core::ops::function::FnMut::call_mut<void (*)(bevy_ecs::system::commands::Commands,bevy_ecs::change_detection::ResMut<bevy_pbr::cluster::GlobalVisibleClusterableObjects>,bevy_ecs::system::query::Query<tuple$<bevy_ecs::entity::Entity,ref$<bevy_transform::co
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c\library\core\src\ops\function.rs:166
   7: core::ops::function::impls::impl$3::call_mut<tuple$<bevy_ecs::system::commands::Commands,bevy_ecs::change_detection::ResMut<bevy_pbr::cluster::GlobalVisibleClusterableObjects>,bevy_ecs::system::query::Query<tuple$<bevy_ecs::entity::Entity,ref$<bevy_transfo
             at /rustc/eeb90cda1969383f56a2637cbd3037bdf598841c\library\core\src\ops\function.rs:294
   8: bevy_ecs::system::function_system::impl$45::run::call_inner<tuple$<>,bevy_ecs::system::commands::Commands,bevy_ecs::change_detection::ResMut<bevy_pbr::cluster::GlobalVisibleClusterableObjects>,bevy_ecs::system::query::Query<tuple$<bevy_ecs::entity::Entity,
             at .\crates\bevy_ecs\src\system\function_system.rs:798
   9: bevy_ecs::system::function_system::impl$45::run<tuple$<>,void (*)(bevy_ecs::system::commands::Commands,bevy_ecs::change_detection::ResMut<bevy_pbr::cluster::GlobalVisibleClusterableObjects>,bevy_ecs::system::query::Query<tuple$<bevy_ecs::entity::Entity,ref
             at .\crates\bevy_ecs\src\system\function_system.rs:801
  10: bevy_ecs::system::function_system::impl$7::run_unsafe<void (*)(bevy_ecs::system::commands::Commands,bevy_ecs::change_detection::ResMut<bevy_pbr::cluster::GlobalVisibleClusterableObjects>,bevy_ecs::system::query::Query<tuple$<bevy_ecs::entity::Entity,ref$<b
             at .\crates\bevy_ecs\src\system\function_system.rs:622
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Encountered a panic in system `bevy_pbr::cluster::assign::assign_objects_to_clusters`!
Encountered a panic in system `bevy_app::main_schedule::Main::run_main`!
error: process didn't exit successfully: `target\debug\examples\irradiance_volumes.exe` (exit code: 101)
@cryscan cryscan added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Sep 18, 2024
@cryscan cryscan changed the title Minimizing window in the irradiance_volume causes a crash Minimizing window in the irradiance_volume example causes a crash Sep 18, 2024
@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen A-Windowing Platform-agnostic interface layer to run your app in P-Crash A sudden unexpected crash S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it! and removed S-Needs-Triage This issue needs to be labelled labels Sep 18, 2024
github-merge-queue bot pushed a commit that referenced this issue Oct 8, 2024
… zero (#15654)

# Objective

- Fixes #15285

## Solution

`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 OS~~

Idially, the camera extraction excludes the cameras whose target size
width or height is zero here;


https://github.com/bevyengine/bevy/blob/25bfa80e60e886031dd6eb1a3fe2ea548fc0a6c6/crates/bevy_render/src/camera/camera.rs#L1060-L1074

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` with `cargo 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior P-Crash A sudden unexpected crash S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants