-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Quit Application on any RenderErrors by default
#24131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
alice-i-cecile
merged 8 commits into
bevyengine:main
from
kfc35:23183_exit_when_render_error
May 6, 2026
+27
−9
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4a36d79
fix: quit application on any render errors by default
kfc35 68bb2fb
Update release note on render recovery
kfc35 10e69a4
Improved doc comments for Ignore and QuitApplication
kfc35 2c0706c
Suggestions from @atlv24: no need for separate policy to quit app
kfc35 98a0fab
fixup from GH being weird; docs to clarify errors are from wgpu
kfc35 bc74431
fmt
kfc35 a4f7fb1
wgpu not webgpu api
kfc35 a77565a
Doc improvements
kfc35 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| use alloc::sync::Arc; | ||
| use bevy_app::AppExit; | ||
| use bevy_ecs::{ | ||
| resource::Resource, | ||
| world::{Mut, World}, | ||
|
|
@@ -19,13 +20,22 @@ use crate::{ | |
| pub enum RenderErrorPolicy { | ||
| /// Pretends nothing happened and continues rendering. | ||
| /// This discards the error after logging it to console. | ||
|
kfc35 marked this conversation as resolved.
|
||
| /// WARNING: Using this policy can cause hazardous rapid flashing | ||
| /// if the conditions causing the error remain unaddressed, since | ||
| /// rendering will attempt to continue executing. | ||
| /// When choosing to use this policy, be sure to test that the application | ||
| /// remains safe to use. | ||
| Ignore, | ||
| /// Keeps the app alive, but stops rendering further. | ||
| /// This keeps the error state, and will continue polling the [`RenderErrorHandler`] | ||
| /// every frame until some other policy is returned. | ||
| StopRendering, | ||
| /// Attempt renderer recovery with the given [`RenderCreation`]. | ||
| Recover(RenderCreation), | ||
| /// Quits the app. | ||
|
kfc35 marked this conversation as resolved.
Outdated
|
||
| /// This stops rendering and sends an [`AppExit::error`], which will | ||
| /// immediately terminate the app. | ||
| QuitApplication, | ||
|
kfc35 marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| /// Determines what [`RenderErrorPolicy`] should be used to respond to a given [`RenderError`]. | ||
|
|
@@ -50,6 +60,9 @@ impl RenderErrorHandler { | |
| RenderErrorPolicy::StopRendering => { | ||
| // do nothing | ||
| } | ||
| RenderErrorPolicy::QuitApplication => { | ||
| main_world.write_message(AppExit::error()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ugh, we only get a u8 to embed error information. |
||
| } | ||
|
kfc35 marked this conversation as resolved.
Outdated
|
||
| RenderErrorPolicy::Recover(render_creation) => { | ||
| assert!(insert_future_resources(&render_creation, main_world)); | ||
| render_world.insert_resource(RenderState::Reinitializing); | ||
|
|
@@ -60,9 +73,14 @@ impl RenderErrorHandler { | |
|
|
||
| impl Default for RenderErrorHandler { | ||
| fn default() -> Self { | ||
| // This is what we've always done historically, | ||
| // but we could choose a new default once recovery works better. | ||
| Self(|_, _, _| RenderErrorPolicy::Ignore) | ||
| // Quit the application for any `RenderError`. | ||
| // Especially for OOM's and Validation RenderErrors, ignoring the error | ||
| // and resuming render can cause a loop that can cause hazardous strobing effects. | ||
| // We can choose a new default once recovery works better. | ||
| Self(|error, _, _| { | ||
| bevy_log::error!("Quitting the application due to {:?} RenderError", error.ty); | ||
| RenderErrorPolicy::QuitApplication | ||
|
kfc35 marked this conversation as resolved.
Outdated
|
||
| }) | ||
| } | ||
| } | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm working on revising the release notes right now, and have pre-emptively included this PR. Please just accept those changes when resolving conflicts.