Skip to content

Fix AutoExposure buffers never being removed - #26400

Open
kamicoder wants to merge 1 commit into
bevyengine:mainfrom
kamicoder:fix-auto-exposure-buffer-removal
Open

kamicoder wants to merge 1 commit into
bevyengine:mainfrom
kamicoder:fix-auto-exposure-buffer-removal

Conversation

@kamicoder

Copy link
Copy Markdown

Objective

  • Removing AutoExposure from a camera leaves the auto-exposure effect still applied.
  • It only disappears if the camera is recreated.

Solution

  • Two worlds exist: the main world and the render world. Each camera is assigned a different ID in each.
  • The buffer table is indexed by render-world IDs.
  • Removal events arrive using main-world IDs (via RemovedComponents); consequently, the lookup fails, and the buffer persists.
  • Additions work correctly because they go through RenderEntity. Only removals were missing the necessary ID translation.
  • The fix: retain only those buffers whose corresponding render entity still possesses an AutoExposure component (checked via a view query).
  • This works because SyncComponentPlugin already removes the component from the render entity.
  • Bonus: when a camera is destroyed, it is no longer present in the views, so its buffer—which was previously leaking—is also cleaned up.

Testing

  • Verified in my own engine; the image returns to a neutral state.
  • Validated on Bevy 0.19 using a copy of the module; the PR applies this same change to the main branch.
  • To reproduce: add AutoExposure to an HDR camera, then remove it during runtime.

AI Disclosure

The AI ​​found the root cause within the Bevy source code and wrote a patch, which I validated in my own engine and reviewed, while ensuring I fully grasped all the implications.

@github-actions

github-actions Bot commented Nov 1, 2026

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 ✨

@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-Rendering Drawing game state to the screen labels Nov 1, 2026
@github-project-automation github-project-automation Bot moved this to Needs SME Triage in Rendering Nov 1, 2026
@alice-i-cecile alice-i-cecile added X-Uncontroversial This work is generally agreed upon D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward AI-Assisted Discloses the use of AI in any way labels Nov 1, 2026

@alice-i-cecile alice-i-cecile left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a lot less complex and more reliable: good!

@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Nov 1, 2026

This branch has not been deployed

No deployments
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 AI-Assisted Discloses the use of AI in any way C-Bug An unexpected or incorrect behavior D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it X-Uncontroversial This work is generally agreed upon

Projects

Status: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

3 participants