bevy/crates/bevy_ecs/src/error
Brian Reavis 795e273a9a
Don't create errors for ignored failed commands (#19718)
# Objective

1. 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.

2. Fix a hang when removing `ChildOf` components during entity
despawning. Excessive logging of these failures can cause significant
hangs (I'm noticing around 100ms).
    - Fixes https://github.com/bevyengine/bevy/issues/19777
    - Fixes https://github.com/bevyengine/bevy/issues/19753

<img width="1387" alt="image"
src="https://github.com/user-attachments/assets/5c67ab77-97bb-46e5-b287-2c502bef9358"
/>


## Solution

* Added a `ignore_error` method to the `HandleError` trait to use
instead of `handle_error_with(ignore)`. It swallows errors and does not
create error objects.
* Replaced `remove::<ChildOf>` with `try_remove::<ChildOf>` to suppress
expected (?) errors and reduce log noise.

## Testing

- I ran these changes on a local project.
2025-06-29 16:34:20 +00:00
..
bevy_error.rs More uninlined_format_args fixes (#19396) 2025-05-28 02:35:18 +00:00
command_handling.rs Don't create errors for ignored failed commands (#19718) 2025-06-29 16:34:20 +00:00
handler.rs ECS: put strings only used for debug behind a feature (#19558) 2025-06-18 20:15:25 +00:00
mod.rs Per world error handler (#18810) 2025-05-19 01:35:07 +00:00