Description
Bevy version
0.14.2
What you did
I have a project that involves spawning and despawning many entities. I am having trouble running Tracy with the project because of a Tracy error caused by despawn_recursive.
What went wrong
Tracy errors out because it runs over the limit of systems that can be tracked (32,000).
Additional information
The reason there are over 32,000 systems running is that DespawnRecursive uses the entity that was despawned to create the trace name, creating a unique system to be tracked in Tracy. This can be seen in the Statistics window in Tracy.
I was able to workaround the problem by limiting despawn_recursives, but this only delays the problem, as my project still eventually hits the 32k limit. Changing despawn_recursive to despawn, fixes the issue, but I need despawn_recursive in some places.
Tracy Error
Tracy Statistics, filled with 32,000 unique DespawnRecursive commands
Code causing the problem in bevy_hierarchy/src/hierarchy.rs
impl Command for DespawnRecursive {
fn apply(self, world: &mut World) {
#[cfg(feature = "trace")]
let _span = bevy_utils::tracing::info_span!(
"command",
name = "DespawnRecursive",
entity = bevy_utils::tracing::field::debug(self.entity)
)
.entered();
despawn_with_children_recursive(world, self.entity);
}
}
impl Command for DespawnChildrenRecursive {
fn apply(self, world: &mut World) {
#[cfg(feature = "trace")]
let _span = bevy_utils::tracing::info_span!(
"command",
name = "DespawnChildrenRecursive",
entity = bevy_utils::tracing::field::debug(self.entity)
)
.entered();
despawn_children_recursive(world, self.entity);
}
}