bevyengine / bevyengine/bevy

Resizing a window with scale factor override of zero panics

Open
#24,273 6 comments 0 reactions 0 assignees View on GitHub
A-Windowing C-Bug D-Straightforward S-Ready-For-Implementation
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## Bevy version and features

0.18.1

## What went wrong

App panics doe to [`.expect`](https://github.com/bevyengine/bevy/blob/v0.18.1/crates/bevy_camera/src/projection.rs#L390) when resizing the window from being a fully expanded to a smaller window with `Window` scale factor override of `Some(0.0)`.

You can get to `Some(0.0)` by having a valid value set in code (in my game it's `.with_scale_factor_override(1.5)`), then modifying the value in editor tooling (egui inspector).

## Additional information

Similar issue https://github.com/bevyengine/bevy/issues/23141.

```
thread 'Compute Task Pool (1)' (1642774) panicked at /home/choc/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bevy_camera-0.18.1/src/projection.rs:390:14:
Failed to update PerspectiveProjection: width and height must be positive, non-zero values: Infinite
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic in system `bevy_render::camera::camera_system`!
```

## Possible solutions

- Ignore [setting aspect_ratio](https://github.com/bevyengine/bevy/blob/v0.18.1/crates/bevy_camera/src/projection.rs#L389) if a valid `AspectRatio` could not be built.
- Somehow tie this error into using Bevys error handling machinery so it's not a straight panic.

Contributor guide

Open the contributing guide

Research direction

Start in crates/bevy_camera/src/projection.rs around the linked setting of aspect_ratio and inspect how PerspectiveProjection updates during bevy_render::camera::camera_system. Reproduce the resize with Window scale factor override Some(0.0), then compare the behavior with issue 23141. Done means this invalid override no longer causes the application to panic during resizing.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
computer-graphics, game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
57/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.