Skip to content

Fix crash when adding ContactShadows to a camera at runtime#24977

Open
voidreamer wants to merge 1 commit into
bevyengine:mainfrom
voidreamer:contact-shadows-view-key
Open

Fix crash when adding ContactShadows to a camera at runtime#24977
voidreamer wants to merge 1 commit into
bevyengine:mainfrom
voidreamer:contact-shadows-view-key

Conversation

@voidreamer

Copy link
Copy Markdown

Objective

Fixes #24951

Solution

Key the view's CONTACT_SHADOWS bit off the extracted ContactShadows component instead of ViewContactShadowsUniformOffset, which is only inserted in PrepareResources, after check_views_need_specialization has already run. Same pattern as the other view key bits (DistanceFog, OIT, atmosphere).

Testing

Ran the repro from #24951: crashes on main, runs clean with this change. Also removed and re-inserted ContactShadows on a live camera, no validation errors either way.

check_views_need_specialization read Has<ViewContactShadowsUniformOffset>,
which is only inserted during PrepareResources, after the check has run.
On a view's first frame with contact shadows the pipeline key missed
CONTACT_SHADOWS while the bind group included binding 16, and wgpu's
validation failure quit the app. Read the extracted ContactShadows
instead, like the fog bit reads DistanceFog.

Fixes bevyengine#24951.
@github-actions

Copy link
Copy Markdown
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide, as well as our policy regarding AI usage, and we look forward to reviewing your pull request shortly ✨

@kfc35 kfc35 added C-Bug An unexpected or incorrect behavior A-Rendering Drawing game state to the screen S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jul 14, 2026
@github-project-automation github-project-automation Bot moved this to Needs SME Triage in Rendering Jul 14, 2026
@kfc35 kfc35 added the P-Crash A sudden unexpected crash label Jul 14, 2026

@kfc35 kfc35 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thorough investigation. I agree with this solution; thanks for the time and thought you put into it, and sorry this caused a fuss for you and your team

@kfc35 kfc35 added the D-Straightforward Simple bug fixes and API improvements, docs, test and examples label Jul 14, 2026
@kfc35 kfc35 requested a review from alice-i-cecile July 14, 2026 02:46
@kfc35 kfc35 added this to the 0.19.1 milestone Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior D-Straightforward Simple bug fixes and API improvements, docs, test and examples P-Crash A sudden unexpected crash S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

Status: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

Adding ContactShadows to a camera at runtime crashes: view bind group has CONTACT_SHADOWS, pipeline layout does not (binding 16)

2 participants