Crash when setting background color via Color::Lcha
Bevy version
0.10.0
[Optional] Relevant system information
rustc 1.68.0
SystemInfo { os: "Linux 22.0.4 Manjaro Linux", kernel: "5.15.94-1-MANJARO", cpu: "AMD Ryzen 7 2700X Eight-Core Processor", core_count: "8", memory: "15.6 GiB" } AdapterInfo { name: "NVIDIA GeForce RTX 2070 SUPER", vendor: 4318, device: 7812, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "525.89.02", backend: Vulkan }
What you did
I set the background color in a project using Color::Lcha {...}.
Minimal example:
fn main() {
App::new()
.insert_resource(
ClearColor(Color::Lcha {
lightness: 80.,
chroma: 20.,
hue: 100.,
alpha: 0.,
}), /*.as_rgba() makes the problem go away */
)
.add_plugins(DefaultPlugins)
.add_startup_system(setup)
.run();
}
fn setup(mut commands: Commands) {
commands.spawn(Camera2dBundle::default());
}
What went wrong
With great anticipation, I awaited the sight of a mesmerizing background color, one that would transport me to a world of beauty and wonder. Alas, my hopes were shattered as the app crashed before my very eyes, leaving me stranded in a void of disappointment and frustration.
Additional information
Console output:
2023-03-10T23:42:39.181041Z INFO bevy_winit::system: Creating new window "Bevy App" (0v0)
2023-03-10T23:42:39.181279Z INFO winit::platform_impl::platform::x11::window: Guessed window scale factor: 1
2023-03-10T23:42:39.254333Z INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce RTX 2070 SUPER", vendor: 4318, device: 7812, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "525.89.02", backend: Vulkan }
2023-03-10T23:42:39.818207Z INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "Linux 22.0.4 Manjaro Linux", kernel: "5.15.94-1-MANJARO", cpu: "AMD Ryzen 7 2700X Eight-Core Processor", core_count: "8", memory: "15.6 GiB" }
thread '<unnamed>' panicked at 'internal error: entered unreachable code', /home/~/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_render-0.10.0/src/color/mod.rs:1155:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'Compute Task Pool (2)' panicked at 'A system has panicked so the executor cannot continue.: RecvError', /home/~/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_ecs-0.10.0/src/schedule/executor/multi_threaded.rs:194:60
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', /home/~/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_tasks-0.10.0/src/task_pool.rs:376:49
thread 'Compute Task Pool (2)' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', /home/~/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_render-0.10.0/src/pipelined_rendering.rs:136:45
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /home/~/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy_tasks-0.10.0/src/task_pool.rs:376:49
Converting the Lcha color to RGBA yielded the expected result, but I found the crash quit surprising, since all other variants of Color can be used to set the background color.
There is a wrong return value in Color::as_rgba_linear. I make a PR