track_change_detection: Also track spawns/despawns#16047
track_change_detection: Also track spawns/despawns#16047alice-i-cecile merged 26 commits intobevyengine:mainfrom
Conversation
crates/bevy_ecs/src/query/error.rs
Outdated
| Self::NoSuchEntity(entity, world) => { | ||
| #[cfg(feature = "track_change_detection")] | ||
| { | ||
| if let Some(location) = world.entities().get_entity_spawned_despawned_by(entity) |
bushrat011899
left a comment
There was a problem hiding this comment.
Really nice change, I think this philosophy should be extended to more areas of Bevy too (e.g., Components). However, there is a safety comment which I believe this change violates. Either the PR needs to be amended to satisfy the invariant, or a SAFETY comment should be added to the field to indicate why it is safe.
crates/bevy_ecs/src/query/error.rs
Outdated
| } | ||
| #[cfg(not(feature = "track_change_detection"))] | ||
| { | ||
| write!(f, "The entity {entity} does not exist") |
There was a problem hiding this comment.
Might be nice to include a hint here to enable track_change_detection for a more detailed error message?
There was a problem hiding this comment.
Great idea; implemented. Should I note in the feature description (in Cargo.toml) that this feature has a perf impact so people don't ship with it on?
There was a problem hiding this comment.
Yeah that's a good idea. And like the tracing filter level features, we should include a note saying library authors should not enable this feature on their published crates, as it removes the ability for end-users to choose themselves.
# Objective `flush_and_reserve_invalid_assuming_no_entities` was made for the old rendering world (which was reset every frame) and is usused since the 0.15 retained rendering world, but wasn't removed yet. It is pub, but is undocumented apart from the safety comment. ## Solution Remove `flush_and_reserve_invalid_assuming_no_entities` and the safety invariants this method required for `EntityMeta`, `EntityLocation`, `TableId` and `TableRow`. This reduces the amount of unsafe code & safety invariants and makes #16047 easier. ## Alternatives - Document `flush_and_reserve_invalid_assuming_no_entities` and keep it unchanged - Document `flush_and_reserve_invalid_assuming_no_entities` and change it to be based on `EntityMeta::INVALID` ## Migration Guide - exchange `Entities::flush_and_reserve_invalid_assuming_no_entities` for `reserve` and `flush_as_invalid` and notify us if that's insufficient --------- Co-authored-by: Benjamin Brienen <[email protected]>
451ffc3 to
85dc8ca
Compare
NthTensor
left a comment
There was a problem hiding this comment.
Fantastic. I've marked this as ready for review.
|
Really lovely. We definitely need to rename the feature, but that's for follow-up. @SpecificProtagonist once merge conflicts are resolved I'll press the button. |
…16846) # Objective - Modify a comment in the shader file to describe what the shader actually does - Fixes bevyengine#16830 ## Solution - Changed the comment. ## Testing - Testing is not relevant to fixing comments (as long as the comment is accurate) --------- Co-authored-by: Freya Pines <[email protected]> Co-authored-by: Freya Pines <[email protected]>
This is the correct rotation type :)
ebb872b to
7278e94
Compare
|
CI is happy; I'm happy. Let's go: this looks so sweet. |
# Objective `flush_and_reserve_invalid_assuming_no_entities` was made for the old rendering world (which was reset every frame) and is usused since the 0.15 retained rendering world, but wasn't removed yet. It is pub, but is undocumented apart from the safety comment. ## Solution Remove `flush_and_reserve_invalid_assuming_no_entities` and the safety invariants this method required for `EntityMeta`, `EntityLocation`, `TableId` and `TableRow`. This reduces the amount of unsafe code & safety invariants and makes bevyengine#16047 easier. ## Alternatives - Document `flush_and_reserve_invalid_assuming_no_entities` and keep it unchanged - Document `flush_and_reserve_invalid_assuming_no_entities` and change it to be based on `EntityMeta::INVALID` ## Migration Guide - exchange `Entities::flush_and_reserve_invalid_assuming_no_entities` for `reserve` and `flush_as_invalid` and notify us if that's insufficient --------- Co-authored-by: Benjamin Brienen <[email protected]>
# Objective
Expand `track_change_detection` feature to also track entity spawns and
despawns. Use this to create better error messages.
# Solution
Adds `Entities::entity_get_spawned_or_despawned_by` as well as `{all
entity reference types}::spawned_by`.
This also removes the deprecated `get_many_entities_mut` & co (and
therefore can't land in 0.15) because we don't yet have no Polonius.
## Testing
Added a test that checks that the locations get updated and these
updates are ordered correctly vs hooks & observers.
---
## Showcase
Access location:
```rust
let mut world = World::new();
let entity = world.spawn_empty().id();
println!("spawned by: {}", world.entity(entity).spawned_by());
```
```
spawned by: src/main.rs:5:24
```
Error message (with `track_change_detection`):
```rust
world.despawn(entity);
world.entity(entity);
```
```
thread 'main' panicked at src/main.rs:11:11:
Entity 0v1#4294967296 was despawned by src/main.rs:10:11
```
and without:
```
thread 'main' panicked at src/main.rs:11:11:
Entity 0v1#4294967296 does not exist (enable `track_change_detection` feature for more details)
```
Similar error messages now also exists for `Query::get`,
`World::entity_mut`, `EntityCommands` creation and everything that
causes `B0003`, e.g.
```
error[B0003]: Could not insert a bundle (of type `MaterialMeshBundle<StandardMaterial>`) for entity Entity { index: 7, generation: 1 }, which was despawned by src/main.rs:10:11. See: https://bevyengine.org/learn/errors/#b0003
```
---------
Co-authored-by: kurk070ff <[email protected]>
Co-authored-by: Freya Pines <[email protected]>
Co-authored-by: Freya Pines <[email protected]>
Co-authored-by: Matty Weatherley <[email protected]>
# Objective
Expand `track_change_detection` feature to also track entity spawns and
despawns. Use this to create better error messages.
# Solution
Adds `Entities::entity_get_spawned_or_despawned_by` as well as `{all
entity reference types}::spawned_by`.
This also removes the deprecated `get_many_entities_mut` & co (and
therefore can't land in 0.15) because we don't yet have no Polonius.
## Testing
Added a test that checks that the locations get updated and these
updates are ordered correctly vs hooks & observers.
---
## Showcase
Access location:
```rust
let mut world = World::new();
let entity = world.spawn_empty().id();
println!("spawned by: {}", world.entity(entity).spawned_by());
```
```
spawned by: src/main.rs:5:24
```
Error message (with `track_change_detection`):
```rust
world.despawn(entity);
world.entity(entity);
```
```
thread 'main' panicked at src/main.rs:11:11:
Entity 0v1#4294967296 was despawned by src/main.rs:10:11
```
and without:
```
thread 'main' panicked at src/main.rs:11:11:
Entity 0v1#4294967296 does not exist (enable `track_change_detection` feature for more details)
```
Similar error messages now also exists for `Query::get`,
`World::entity_mut`, `EntityCommands` creation and everything that
causes `B0003`, e.g.
```
error[B0003]: Could not insert a bundle (of type `MaterialMeshBundle<StandardMaterial>`) for entity Entity { index: 7, generation: 1 }, which was despawned by src/main.rs:10:11. See: https://bevyengine.org/learn/errors/#b0003
```
---------
Co-authored-by: kurk070ff <[email protected]>
Co-authored-by: Freya Pines <[email protected]>
Co-authored-by: Freya Pines <[email protected]>
Co-authored-by: Matty Weatherley <[email protected]>
|
Thank you to everyone involved with the authoring or reviewing of this PR! This work is relatively important and needs release notes! Head over to bevyengine/bevy-website#1974 if you'd like to help out. |
Objective
Expand
track_change_detectionfeature to also track entity spawns and despawns. Use this to create better error messages.Solution
Adds
Entities::entity_get_spawned_or_despawned_byas well as{all entity reference types}::spawned_by.This also removes the deprecated
get_many_entities_mut& co (and therefore can't land in 0.15) because we don't yet have no Polonius.Testing
Added a test that checks that the locations get updated and these updates are ordered correctly vs hooks & observers.
Showcase
Access location:
Error message (with
track_change_detection):and without:
Similar error messages now also exists for
Query::get,World::entity_mut,EntityCommandscreation and everything that causesB0003, e.g.