-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Simple improvements to ambiguity reporting clarity #1484
Comments
If this isn't sufficient, we should seriously consider implementing a simple form of #1481 to supplement it. The other natural extension is system graph visualization tools. |
It would be nice if the ambiguity checker could output to a file rather than stdout. That way it's output isn't mixed with other logging and it's in a place that's easy to work with. Either a environment variable or a command line argument specifying the output path would be awesome. This seems closely related to this issue that I'm commenting here rather than making a separate issue. |
It should be possible to selectively write logs to different files. I don't know if Bevy's built-in logging frontend can do that, though. |
Should probably not spit out ambiguities that are between internal bevy systems by default |
If anyone is interested in tackling this, the work itself should be quite simple once you know where to look :) Feel free to ask me for directions on here or Discord. |
It could also be useful to be able to specify in some way that the ambiguity checker should not check inaccessible systems from other crates, perhaps by specifying plugins to ignore, or by specifying which plugins to check (ideas for this would be appreciated; I'm still sort of new to Bevy). This will help remove unactionable warnings. I think I would be interested in taking this on, if no one else has taken it by the time I'm available, in a few days. |
Given the following simple test: use bevy::{ecs::schedule::ReportExecutionOrderAmbiguities, log::LogPlugin, prelude::*};
fn main() {
env_logger::init();
App::new()
.add_plugin(LogPlugin::default())
.insert_resource(ReportExecutionOrderAmbiguities)
.insert_resource(MyStartupResource(0))
.add_startup_system(startup_system_a)
.add_startup_system(startup_system_b)
.insert_resource(MyParallelResource(0))
.add_system(parallel_system_a)
.add_system(parallel_system_b)
.run();
}
struct MyStartupResource(i32);
fn startup_system_a(mut res: ResMut<MyStartupResource>) {
res.0 += 1;
}
fn startup_system_b(mut res: ResMut<MyStartupResource>) {
res.0 += 1;
}
struct MyParallelResource(i32);
fn parallel_system_a(mut res: ResMut<MyParallelResource>) {
res.0 += 1;
}
fn parallel_system_b(mut res: ResMut<MyParallelResource>) {
res.0 += 1;
} Currently prints the following output:
So if I understood correct, those are the following desired changes: 1. Number the reported ambiguities, to make them easier to discuss in a team.
2. Display function signatures of conflicting systems.
3. Explain which component(s) / resource(s) the systems are conflicting on.
4. Report ambiguities where all pairwise combinations of systems conflict on the same data as a group.
5. Create a simple .ambiguous() method that causes a system to be ignored completely in the ambiguity checker. This would only be useful for inconsequential systems like particle effect creation. [...]
.insert_resource(MyParallelResource(0))
.add_system(parallel_system_a.ambiguous()) //ignored by ambiguity checker
.add_system(parallel_system_b) //since ambiguity checker will only check this one, not output is shown
[...] 6. Create a simple .ambiguous_with(system_label) method to create two-element ambiguity sets without being forced to invent an ambiguity set label. [...]
.insert_resource(MyParallelResource(0))
.add_system(parallel_system_a.label("my_label"))
.add_system(parallel_system_b.ambiguous_with("my_label") // this system will not be reported since it's marked
// given this third system has the same requirements as the other two, it'll be reported on ambiguity checker
.add_system(parallel_system_c)
[...] 7. Provide an "X unresolved ambiguities detected" message that runs by default. Rather than toggling ambiguity detection on/off, have three states: off / minimal / verbose. This would provide discoverability that system ambiguities are a thing and let developers see when the change that they just made added / removed some ambiguities at a glance.
8. Provide an way to ignore/filter crates when using ambiguity checker. .insert_resource(ReportExecutionOrderAmbiguities {
report_level: AmbiguityReportLevel::Minimal,
ignored_crates: vec!["bevy", "bevy_rapier"],
}) 9. By default, ambiguity checker should ignore internal bevy crates. impl Default for ReportExecutionOrderAmbiguities {
fn default() -> Self {
Self {
report_level: AmbiguityReportLevel::Minimal,
ignored_crates: vec!["bevy"],
}
}
} Is that right? This doesn't seems complicated, but I want to know if I understood correct and maybe check if some of those requirements changed over the time. |
@afonsolage that looks fantastic! I agree with the concrete suggestions for all 9 of those bullet items. Are you planning to tackle this? |
Yes, I'm not very used to public repo team working, but I read the CONTRIBUTING.md so I'll start a Draft PR and give it a try. Maybe I'll need some helping in finding the function signature, but I'll take a closer look again on bevy ecs. |
This is effectively complete now, closing it out 🎉 |
What problem does this solve or what need does it fill?
Ambiguity reports are hard to decipher.
What solution would you like?
.ambiguous()
method that causes a system to be ignored completely in the ambiguity checker. This would only be useful for inconsequential systems like particle effect creation..ambiguous_with(system_label)
method to create two-element ambiguity sets without being forced to invent an ambiguity set label.What alternative(s) have you considered?
Allow for a verbose mode?
Additional context
Many more complex improvements could be added, but these are deliberately simple to allow them to be patched and merged quickly. This arose from helping @jamadazi with resolving ambiguities in his non-trivial codebase.
Suggestion 6 results in asymmetric declarations of a symmetric property, but having to invent trivial names all over the place is awful, and large ambiguity sets are often overkill / have unintended behavior for simple conflict resolutions.
The text was updated successfully, but these errors were encountered: