Skip to content

Commit e35372d

Browse files
authored
Render Recovery release note (#23466)
# Objective - Completes goal and closes #23029 - Culmination of #22761, #23350, #23349, #23433, #23458, #23444, #23459, #23461, #23463, #22714, #22759, #16481 ## Solution - Add a release note. - Re-export a wgpu type that you need to match on to handle errors. ## Testing - cargo run --example render_recovery with all the other PRs merged in. Press 5 and then V, the app will not crash. Note that D for "destroy device" will still crash: this is a WGPU problem resolved by gfx-rs/wgpu#9281. # Note I opted not to change the default recovery behavior yet. I believe we need testing in user projects and just general trodding of this code path before committing to a new default. It works in a simple example, it might not work in a complex project. We need to field test this and likely iterate to really call this ready IMO.
1 parent 35ce30e commit e35372d

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

crates/bevy_render/src/error_handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use bevy_ecs::{
55
};
66
use std::sync::Mutex;
77
use wgpu::ErrorSource;
8-
use wgpu_types::error::ErrorType;
8+
pub use wgpu_types::error::ErrorType;
99

1010
use crate::{
1111
insert_future_resources,
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
title: "Render Recovery"
3+
authors: ["@atlv24"]
4+
pull_requests: [22761, 23350, 23349, 23433, 23458, 23444, 23459, 23461, 23463, 22714, 22759, 16481]
5+
---
6+
7+
You can now recover from rendering errors such as device loss by reloading the renderer:
8+
9+
```rs
10+
use bevy::render::error_handler::{ErrorType, RenderErrorHandler, RenderErrorPolicy};
11+
12+
app.insert_resource(RenderErrorHandler(
13+
|error, main_world, render_world| match error.ty {
14+
ErrorType::Internal => panic!(),
15+
ErrorType::OutOfMemory => RenderErrorPolicy::StopRendering,
16+
ErrorType::Validation => RenderErrorPolicy::Ignore,
17+
ErrorType::DeviceLost => RenderErrorPolicy::Recover(default()),
18+
},
19+
));
20+
```
21+
22+
NOTE: this is just an example showing the different errors and policies available, and not a recommendation for how to handle errors.
23+
24+
The default error handler behaves identically to how Bevy behaved before: validation errors are ignored, and other errors crash/hang the application.

0 commit comments

Comments
 (0)