bevy/crates/bevy_ecs/src
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
..
entity Split EntityClonerBuilder in OptOut and OptIn variants (#19649) 2025-06-24 00:12:08 +00:00
error Don't create errors for ignored failed commands (#19718) 2025-06-29 16:34:20 +00:00
event Event Split: Event, EntityEvent, and BufferedEvent (#19647) 2025-06-15 16:46:34 +00:00
observer Split EntityClonerBuilder in OptOut and OptIn variants (#19649) 2025-06-24 00:12:08 +00:00
query Add newlines before impl blocks (#19746) 2025-06-22 23:07:02 +00:00
reflect ECS: put strings only used for debug behind a feature (#19558) 2025-06-18 20:15:25 +00:00
relationship Don't create errors for ignored failed commands (#19718) 2025-06-29 16:34:20 +00:00
schedule Upgrade to Rust 1.88 (#19825) 2025-06-26 19:38:19 +00:00
storage ECS: put strings only used for debug behind a feature (#19558) 2025-06-18 20:15:25 +00:00
system Don't create errors for ignored failed commands (#19718) 2025-06-29 16:34:20 +00:00
world Split EntityClonerBuilder in OptOut and OptIn variants (#19649) 2025-06-24 00:12:08 +00:00
archetype.rs Add newlines before impl blocks (#19746) 2025-06-22 23:07:02 +00:00
batching.rs Nonmax all rows (#19132) 2025-05-26 17:39:55 +00:00
bundle.rs Refactor bundle derive (#19749) 2025-06-20 16:36:08 +00:00
change_detection.rs Event Split: Event, EntityEvent, and BufferedEvent (#19647) 2025-06-15 16:46:34 +00:00
component.rs Let Component::map_entities defer to MapEntities (#19414) 2025-06-23 21:05:04 +00:00
entity_disabling.rs bevy_reflect: Add clone registrations project-wide (#18307) 2025-03-17 18:32:35 +00:00
hierarchy.rs Fix some typos (#19788) 2025-06-23 22:32:46 +00:00
intern.rs Rename bevy_platform_support to bevy_platform (#18813) 2025-04-11 23:13:28 +00:00
label.rs Remove upcasting methods + Cleanup interned label code (#18984) 2025-05-26 15:38:12 +00:00
lib.rs Rename num_entities to entity_count (#19781) 2025-06-23 05:08:02 +00:00
lifecycle.rs Added clone bounds to EntityEvents that were missing them. (#19708) 2025-06-17 21:22:32 +00:00
name.rs Add newlines before impl blocks (#19746) 2025-06-22 23:07:02 +00:00
never.rs Use never_say_never hack to work around Rust 2024 regression for fn traits (#18804) 2025-04-14 19:59:48 +00:00
resource.rs refactor(utils): move SyncCell and SyncUnsafeCell to bevy_platform (#19305) 2025-05-27 04:57:26 +00:00
spawn.rs Add newlines before impl blocks (#19746) 2025-06-22 23:07:02 +00:00
traversal.rs Let query items borrow from query state to avoid needing to clone (#15396) 2025-06-16 21:05:41 +00:00