Skip to content

Add example for triggering and recovering from rendering errors#22757

Merged
alice-i-cecile merged 5 commits intobevyengine:mainfrom
atlv24:ad/render-recovery-example
Feb 2, 2026
Merged

Add example for triggering and recovering from rendering errors#22757
alice-i-cecile merged 5 commits intobevyengine:mainfrom
atlv24:ad/render-recovery-example

Conversation

@atlv24
Copy link
Copy Markdown
Contributor

@atlv24 atlv24 commented Jan 31, 2026

Objective

  • Test suite/demonstration for render recovery

Solution

  • Add an example that has ways to trigger various rendering errors

Testing

  • run it

Note: im opening this separately so that behavior on bevy main can be compared to upcoming render recovery pr. It doesn't have to merge first though.

@IQuick143 IQuick143 added A-Rendering Drawing game state to the screen C-Examples An addition or correction to our examples D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jan 31, 2026
@atlv24 atlv24 force-pushed the ad/render-recovery-example branch from 2057137 to 2bc00a2 Compare January 31, 2026 21:41
@IQuick143 IQuick143 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 Jan 31, 2026
@atlv24 atlv24 mentioned this pull request Feb 1, 2026
@atlv24 atlv24 force-pushed the ad/render-recovery-example branch from 3fdd774 to 72d321c Compare February 1, 2026 02:56
@mockersf
Copy link
Copy Markdown
Member

mockersf commented Feb 2, 2026

on macOS:

  • the shader loop doesn't crash, it freezes and gets hard to kill. Even after killing the example, the GPU is still running at 100%
  • the out of memory doesn't crash and doesn't seem to have any impact, all good

@alice-i-cecile
Copy link
Copy Markdown
Member

I think that those MacOS specific quirks are helpful to test and note down, but I'm going to merge this regardless so we can track and refine behavior over time more easily.

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Feb 2, 2026
Merged via the queue into bevyengine:main with commit 7b0d0a4 Feb 2, 2026
41 of 42 checks passed
viridia pushed a commit to viridia/bevy that referenced this pull request Feb 3, 2026
…engine#22757)

# Objective

- Test suite/demonstration for render recovery

## Solution

- Add an example that has ways to trigger various rendering errors

## Testing

- run it

Note: im opening this separately so that behavior on bevy main can be
compared to upcoming render recovery pr. It doesn't have to merge first
though.
github-merge-queue bot pushed a commit that referenced this pull request Feb 5, 2026
# Objective

- Recover from rendering errors.
- Another step towards render recovery after #22714 #22759 and #16481 

## Solution

- Use `wgpu::Device::set_device_lost_callback` and
`wgpu::Device::on_uncaptured_error` to listen for errors.
- Add a state machine for the renderer
- Update it on error
- Add a `RenderErrorHandler` to let users specify behavior on error by
returning a specific `RenderErrorPolicy`
- This lets us for example ignore validation errors, delete responsible
entities, or reload the renderer if the device was lost.

## Testing

- #22757 with any of
```rs
    .insert_resource(bevy_render::error_handler::RenderErrorHandler(|_, _, _| {
        bevy_render::error_handler::RenderErrorPolicy::StopRendering
    }))
```
```rs
    .insert_resource(bevy_render::error_handler::RenderErrorHandler(|_, _, _| {
        bevy_render::error_handler::RenderErrorPolicy::Recover(default())
    }))
```

Note: no release note yet, as recovery does not exactly work well: this
PR gets us to the point of being able to care about it, but we currently
instantly crash on recover due to gpu resources not existing anymore. We
need to build more resilience before publicizing imo.

---------

Co-authored-by: Kristoffer Søholm <k.soeholm@gmail.com>
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-Examples An addition or correction to our examples D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants