Skip to content

Panic with DirectionalLight+Shadows+Camera #16094

Open
@rs017991

Description

Bevy version

0.15.0-rc.1
Further: I have verified via git bisect that this panic was introduced in de888a373de666ff9d1bbdf8275e7fb625584394 (#15554)
(notable that this commit does not actually change the offending file, though perhaps that is the problem)

What I did

Add DirectionalLight { shadows_enabled: true, ..default() } to an entity that has a Camera.
(You may reproduce by simply adding that snippet when spawning the Camera in the regular 3d/lighting example)

All three of those conditions are necessary to reproduce the bug

  • Does not panic if DirectionalLight is replaced with PointLight
  • Does not panic if shadows are disabled
  • Does not panic if the Camera is removed

What went wrong

thread 'main' panicked at crates\bevy_pbr\src\render\light.rs:1265:18:
called `Option::unwrap()` on a `None` value

https://github.com/bevyengine/bevy/blob/v0.15.0-rc.1/crates/bevy_pbr/src/render/light.rs#L1265

This is a bare unwrap with no comment indicating why it would be unreachable.
Otoh, if it is supposed to be reachable (yet truly catastrophic), then it really ought to be an expect with similar justification in the text.

Absent either of those, one has to trace back through the web of Components and Render World syncing to see why this condition could possibly arise (much less be justified in crashing the program when violated). If it's not clear, I'm on team 'no panic' :)

Additional information

Final note: This issue is not about whether a 'light on camera' setup does/should work (I was just messing around when I ran into this);
I'm only concerned about the fact that it panics.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-BugAn unexpected or incorrect behaviorP-RegressionFunctionality that used to work but no longer does. Add a test for this!S-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions