-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Initialize DiagnosticStore
on register_diagnostic
if it does not exist
#8819
Initialize DiagnosticStore
on register_diagnostic
if it does not exist
#8819
Conversation
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.
This is a tricky behavior. Now, the user could forget to add the DiagnosticsPlugin
without a panic.
So we have the choice between:
code | adds register_diagnostic before DiagnosticsPlugin |
forgets to add DiagnosticsPlugin but yet uses register_diagnostic |
---|---|---|
main | panics | panics |
#8819 | runs | runs |
bevy | Bug in user code? | Conscequences |
---|---|---|
panics | yes | user is annoyed, learn from panic message what the issue is and fixes it |
runs | yes | user encounters a mysterious bug they have no idea how to fix, spend 2 hours fixing it |
panics | no | user is annoyed, spend 2 hours trying to fix it, submits a bug to bevy when they figure out it originates from bevy |
runs | no | user is happy 🎉 |
Honestly I think it's better to panic too much than not enough, so I think this should be solved differently.
Here is a suggestion: use get_reflect_mut
over reflect_mut
in line 307. Do
let Some(…) = …get_resource_mut…() else {
panic!("Add DiagnosticsPlugin _before_ calling register_diagnostic, or something");
};
@mockersf what do you think? You suggested this change. |
Well... to be honest, I would suggest nuking the That said, let's keep the plugin for now because it may make sense for diagnostics created during runtime. I'm not sure how to read your tables, but registering a diagnostic before adding the |
Co-authored-by: François <[email protected]>
My concern was that the user would forget to add I didn't realize |
Objective
many_sprites
andmany_animated_sprites
crashing on initialization #8782Solution
init_resource
onregister_diagnostic
so that aDiagnosticStore
gets initialized if it does not exist.