-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Change most RenderApp accesses to panics instead of silently doing nothing/half the work. #19856
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
base: main
Are you sure you want to change the base?
Conversation
…vy_ui panic instead of doing nothing.
7e78ae1
to
2dd8467
Compare
…erApp subapp from in the RenderApp subapp.
This PR is already paying itself off! Previously I have no idea what this plugin does, but it seems reasonable to say it shouldn't be doing nothing (and if it is, we should just remove it outright). |
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.
My kingdom for real plugin dependencies :( #1255 please.
This PR might not actually be the way. It turns out if you have no rendering backends we don't insert the I'm not really sure what to do here, @alice-i-cecile. Even in a world with plugin dependencies, we'd still need to do this conditional check. That doesn't seem desirable and almost seems like we shouldn't support having no backends, but I don't know what the implications of that are. |
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.
Could we use error!
instead of panic!
? I know it shouldn't matter, but in case someone's project has weird orderings that are useless, it's very annoying to upgrade your project and find out that it crashes due to some bevy_rendering
stuff that you maybe didn't even setup yourself, but imported through a dependency. Though that seems unlikely in this case, admittedly.
But I can imagine someone's CI setup depending on a missing RenderApp
being ignored, for example.
See also point 3 of #12660:
+1 on error! instead of panic! |
Objective
if let Some(render_app)
which adds a whole extra level of nesting.Solution
Make them panic if there is no RenderApp! It is better to give a more immediate warning than your app just silently doing nothing. This also reduces nesting in some cases.
One case is special (in
crates/bevy_render/src/lib.rs
): theRenderPlugin
itself callsinitialize_render_app
, and then later checks if we have theRenderApp
. By moving thisif
to theinitialize_render_app
function, we avoid the useless branch and the problem goes away!There are 4 remaining cases that I did not handle. I am willing to fix all in this PR if that's desired.
bevy_text
adds an extraction schedule for extracting the text2d sprite to the rendering stuff. In theory though, a user could be using thebevy_text
stack with their own rendering (so reusing the layout and stuff). This one I am the least confident about. I added a comment explaining this one.bevy_gizmos
prints a warning message about having the plugins in the wrong order. Since this is also messing with feature flags, I didn't feel compelled to mess with it.bevy_render
ExtractResourcePlugin
prints a warning message about having the plugins in the wrong order. Since this plugin is intended to be added by users, and we already have a message, I decided to leave this alone.bevy_sprite::SpritePlugin
may be added even in headless situations (e.g., to register theSprite
type for spawning scenes). I added a comment explaining this one too.I don't think this needs a migration guide, since no one should be depending on this - the plugins would pretty much do nothing before anyway.