Skip to content

Commit 3b81a50

Browse files
committed
Fix crash in headless mode (#4476)
# Objective Fixes #4440. ## Solution Check if `RenderDevice` exists and add CI validation.
1 parent c2a9d58 commit 3b81a50

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
(
2+
exit_after: Some(100)
3+
)

crates/bevy_pbr/src/light.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -642,8 +642,13 @@ pub(crate) fn assign_lights_to_clusters(
642642
lights_query: Query<(Entity, &GlobalTransform, &PointLight, &Visibility)>,
643643
mut lights: Local<Vec<PointLightAssignmentData>>,
644644
mut max_point_lights_warning_emitted: Local<bool>,
645-
render_device: Res<RenderDevice>,
645+
render_device: Option<Res<RenderDevice>>,
646646
) {
647+
let render_device = match render_device {
648+
Some(render_device) => render_device,
649+
None => return,
650+
};
651+
647652
global_lights.entities.clear();
648653
lights.clear();
649654
// collect just the relevant light query data into a persisted vec to avoid reallocating each frame

0 commit comments

Comments
 (0)