-
-
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
Inconsistency between Debug
and serialized representation of Entity
#12139
Comments
Ah: I know what we should do. The serialized representation should stay the same, optimized for information density. This is just an opaque identifier. However, we should make the debug representation more verbose, and report In the future, we will be packing more information into here (e.g. entity disabling) that we want to add to the debug output, but we should avoid adding bloat (or semantic meaning) to the serialized representation. Displaying the raw bits separately gives us the best of both worlds, as users will be able to make this correspondence themselves. |
I like that idea. My only concern there is that the current "#v#" format for I'm concerned if we make the |
That seems like a prime case for a |
Just a random idea I had on this topic: If we take this approach, we could make the Alternatively, we could make |
I like |
- Derive `Debug` impl for `Entity` - Add impl `Display` for `Entity` - Add `entity_display` display to check the output contains all required info
…ty (#12469) # Objective Fixes #12139 ## Solution - Derive `Debug` impl for `Entity` - Add impl `Display` for `Entity` - Add `entity_display` test to check the output contains all required info I decided to go with `0v0|1234` format as opposed to the `0v0[1234]` which was initially discussed in the issue. My rationale for this is that `[1234]` may be confused for index values, which may be common in logs, and so searching for entities by text would become harder. I figured `|1234` would help the entity IDs stand out more. Additionally, I'm a little concerned that this change is gonna break existing logging for projects because `Debug` is now going to be a multi-line output. But maybe this is ok. We could implement `Debug` to be a single-line output, but then I don't see why it would be different from `Display` at all. @alice-i-cecile Let me know if we'd like to make any changes based on these points.
@alice-i-cecile I want to re-open this issue. I don't think the The ProblemThe serialized output of Bevy scenes uses the raw bit representation of entities, i.e. After this change, the Additionally, this still doesn't fix the initial problem, because My ProposalTo me, This not only avoids the need to retroactively fix logs, but also solves the initial problem by including the raw bits into the debug output. Any specialized debugger that needs to show additional data for the entity most likely would need to format it explicitly. Trying to implement The only other alternative I see around this issue is that we retroactively fix existing log locations to use |
Proposed fix for bevyengine#12139
# Objective Fixes #12139 ## Solution See this comment on original issue for my proposal: #12139 (comment) This PR is an implementation of this proposal. I modified the implementation of `fmt::Debug` to instead display `0v0#12345` to ensure entity index, generation, and raw bits are all present in the output for debug purposes while still keeping log message concise. `fmt::Display` remains as is (`0v0`) to offer an even shorter output. To me, this is the most non-intrusive fix for this issue. ## Testing Add `fn entity_debug` test --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com> Co-authored-by: Gino Valente <49806985+MrGVSV@users.noreply.github.com>
Bevy version
0.13
What went wrong
There is an inconsistency between the
Debug
representation of anEntity
:And its
Serialize
representation:This makes it difficult to debug serialized outputs, since the serialized entity IDs cannot be easily mapped to runtime entities via human inspection. Ideally, these representations should be consistent for easier debugging.
Additional information
I wanted to just open a PR on this, but I think the issue warrants some discussion. Mainly on two points:
The text was updated successfully, but these errors were encountered: