From 3b81a50a1a445c919194fc73f9f5549198f74a09 Mon Sep 17 00:00:00 2001 From: Hennadii Chernyshchyk Date: Fri, 15 Apr 2022 07:13:37 +0000 Subject: [PATCH] Fix crash in headless mode (#4476) # Objective Fixes #4440. ## Solution Check if `RenderDevice` exists and add CI validation. --- .github/example-run/headless_defaults.ron | 3 +++ crates/bevy_pbr/src/light.rs | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .github/example-run/headless_defaults.ron diff --git a/.github/example-run/headless_defaults.ron b/.github/example-run/headless_defaults.ron new file mode 100644 index 0000000000..22e43495b5 --- /dev/null +++ b/.github/example-run/headless_defaults.ron @@ -0,0 +1,3 @@ +( + exit_after: Some(100) +) diff --git a/crates/bevy_pbr/src/light.rs b/crates/bevy_pbr/src/light.rs index d05d5c44c5..0f67399e5e 100644 --- a/crates/bevy_pbr/src/light.rs +++ b/crates/bevy_pbr/src/light.rs @@ -642,8 +642,13 @@ pub(crate) fn assign_lights_to_clusters( lights_query: Query<(Entity, &GlobalTransform, &PointLight, &Visibility)>, mut lights: Local>, mut max_point_lights_warning_emitted: Local, - render_device: Res, + render_device: Option>, ) { + let render_device = match render_device { + Some(render_device) => render_device, + None => return, + }; + global_lights.entities.clear(); lights.clear(); // collect just the relevant light query data into a persisted vec to avoid reallocating each frame