Replies: 2 comments 2 replies
-
Alternatively, we could just record an |
Beta Was this translation helpful? Give feedback.
1 reply
-
Would standard log levels be enough for this? Or would a bevy specific log level be appropriate for filtering purposes? Or maybe a tag/flag on a log entry to show its from bevy internals? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Following up on an idea briefly mentioned in Discord, I'd like to propose a new debugging feature : a
CommandTrace
buffer optionally (if enabled) populated in parallel ofCommands
, and recording metadata about the commands.Motivation
I had some issue with the internal parenting system running after my own, and trying to access a parent entity already deleted, causing a panic. To make things worse, as discovered later, the entity ID was being immediately reused, such that looking at it alone appeared like it was still available. In this kind of scenario, there's very little information available to developers, and I had to resort to checking out the Bevy codebase and add some
println!()
everywhere. This worked for a tiny project (<20 entities) but I can't imagine a larger one.Initial workaround
This episode led to #2943 which adds the entity ID and generation to the panic message, allowing a dev to reason about which entity the issue is about. However, this approach is fairly limited in that there's no information about when/where the entity was spawned nor destroyed, making the investigation difficult especially when an internal system is involved.
Proposal
The proposal allows recording command metadata not usually useful for the functioning of the engine, but largely helpful for the developers.
Metadata
Examples of metadata I'm thinking of, which are up for individual discussion, include:
Some debug entity nameEDIT: There's actually aName
component for thatInterface
The entire feature can be being a feature flag to generate no code in a release build. Additionally it should be explicitly enabled, due to potential overhead, with some call. Maybe
AppBuilder::with_debug_commands()
?@DJMcNab already suggested adding
SystemState
to theCommand
trait to allow retrieving the system name.Entity debug name can be supported on creation with an
EntityCommand::with_debug_name()
.Thread ID/name are accessible from
std::thread.current()
. They can be recorded with a flag set when enabling the overall feature itself.To be continued...
Beta Was this translation helpful? Give feedback.
All reactions