Conversation
b896165 to
c848450
Compare
| pub(crate) fn update(main_world: &mut World, render_world: &mut World) -> bool { | ||
| match render_world.resource::<RenderState>() { | ||
| RenderState::Initializing => { | ||
| render_world.insert_resource(RenderState::Ready); |
There was a problem hiding this comment.
Can we really just instantly transition from Initializing into Ready?
There was a problem hiding this comment.
Maybe the transition into Ready should be done by RenderStartup itself (in case it has its own fallibility).
There was a problem hiding this comment.
I think its better to keep all the state-machine-y things in the function together
There was a problem hiding this comment.
I'm fine with keeping this together for now, but I suspect we may need to refactor this later.
Co-authored-by: Kristoffer Søholm <k.soeholm@gmail.com>
|
This should also solve #21407 |
|
It's not quite solving it yet, but it gets us close. |
crates/bevy_render/src/lib.rs
Outdated
| render_app.set_extract(move |main_world, render_world| { | ||
| if should_run_startup { | ||
| render_app.set_extract(|main_world, render_world| { | ||
| if error_handler::update_state(main_world, render_world) { |
There was a problem hiding this comment.
The naming of update_state makes it quite hard to understand what this method call is doing. I would prefer a rename, but would accept a comment.
There was a problem hiding this comment.
it used to be called update and i asked for a bikeshed and thats what we came up with, but im open to better name suggestions. it updates the state machine that handles the renderer and device lifecycle. i'll add a comment for now saying as much
There was a problem hiding this comment.
Maybe something like check_render_device_lifecycle? IMO we should try and capture a) renderer / device b) lifecycle and c) some form of check or "should run" or something to indicate that it returns a bool that should be used.
|
No blocking feedback, and wgpu maintainers were reasonably happy with this. I'm not equipped to give a full approval here though; I don't know the domain well enough. |
IceSentry
left a comment
There was a problem hiding this comment.
So, the logic of everything is great and it does what it's supposed to.
I don't like how it feels like it does 4 different things at once but I haven't managed to untangle it.
I think it might feel mildly better to name the new module render_state and error handling just happens to be part of handling the state instead of the state being managed by something called error_handler. I would also just move the RenderStartup to be inside the state machine itself because that state machine is already aware of it so it feels a bit unnecessary to keep them separate. The update_state function already does a bunch of things and mutates the world so it seems appropriate for it to just run the schedule when it needs to. Especially if we start running it on recovery.
With that said, I think the current state of things works and we can rename it later. I don't want to block work on naming things.
|
I've done the renames requested, although im not sure i agree with them. The point of calling it error_handler was more for the user facing api: bevy::render::error_handler::{RenderErrorHandler, RenderErrorPolicy}vs bevy::render::render_state::{RenderErrorHandler, RenderErrorPolicy} |
|
Im just gonna make the mod private and re-export from the top level instead |
|
nah... it was just better before im gonna keep error_handler for now my bad |
Objective
Solution
wgpu::Device::set_device_lost_callbackandwgpu::Device::on_uncaptured_errorto listen for errors.RenderErrorHandlerto let users specify behavior on error by returning a specificRenderErrorPolicyTesting
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.