Don't create errors for ignored failed commands #19718
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
Reduce overhead from error handling for ECS commands that intentionally ignore errors, such as
try_despawn
. These commands currently allocate error objects and pass them to a no-op handler (ignore
), which can impact performance when many operations fail.Fix a hang when removing
ChildOf
components during entity despawning. Excessive logging of these failures can cause significant hangs (I'm noticing around 100ms).Solution
handle_error_with
optional to avoid creating error objects when the error is just going to be swallowed.remove::<ChildOf>
withtry_remove::<ChildOf>
to suppress expected (?) errors and reduce log noise.Future Work
Testing
Option
approach onhandle_error_with
is not elegant or super clear, but didn't have any better ideas at the time.