-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[Merged by Bors] - Clean up taffy nodes when UI node entities are removed #5886
Conversation
Sorry if I'm spamming reviewers. Looks like GitHub cancels one when I request the other. I'll leave this as-is now haha. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't need that extra .iter call now :) Once that's fixed this LGTM.
af118ae
to
101347a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, thanks :)
@@ -780,6 +780,15 @@ impl<'a, T: Component> RemovedComponents<'a, T> { | |||
} | |||
} | |||
|
|||
impl<'a, T: Component> IntoIterator for &'a RemovedComponents<'a, T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically this doesn't need both lifetimes to be 'a
does it? I think .iter()
also has an overconstrained lifetime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not compile without &'a
if that's what you're asking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean that iter
returns a std::iter::Cloned<std::slice::Iter<'_, Entity>>
whose lifetime is linked to the &self
parameter, but it could return a std::iter::Cloned<std::slice::Iter<'a, Entity>>
, and by consequence IntoIterator
could be implemented for &'a RemovedComponents<'b, T>
, returning a std::iter::Cloned<std::slice::Iter<'b, Entity>>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bors r+
# Objective Clean up taffy nodes when the associated UI node gets removed. The current UI code will keep the taffy nodes around forever. ## Solution Use `RemovedComponents<Node>` to iterate over nodes that are no longer valid UI nodes or that have been despawned, and remove them from taffy and the internal hash map. ## Implementation Notes Do note that using `despawn()` instead of `despawn_recursive()` on a UI node that has children will result in a [warnings spam](https://github.com/bevyengine/bevy/blob/main/crates/bevy_ui/src/flex/mod.rs#L120) since the children will not be part of a proper UI hierarchy anymore. --- ## Changelog - Fixed memory leak when nodes are removed in bevy_ui
Pull request successfully merged into main. Build succeeded: |
# Objective Clean up taffy nodes when the associated UI node gets removed. The current UI code will keep the taffy nodes around forever. ## Solution Use `RemovedComponents<Node>` to iterate over nodes that are no longer valid UI nodes or that have been despawned, and remove them from taffy and the internal hash map. ## Implementation Notes Do note that using `despawn()` instead of `despawn_recursive()` on a UI node that has children will result in a [warnings spam](https://github.com/bevyengine/bevy/blob/main/crates/bevy_ui/src/flex/mod.rs#L120) since the children will not be part of a proper UI hierarchy anymore. --- ## Changelog - Fixed memory leak when nodes are removed in bevy_ui
# Objective Clean up taffy nodes when the associated UI node gets removed. The current UI code will keep the taffy nodes around forever. ## Solution Use `RemovedComponents<Node>` to iterate over nodes that are no longer valid UI nodes or that have been despawned, and remove them from taffy and the internal hash map. ## Implementation Notes Do note that using `despawn()` instead of `despawn_recursive()` on a UI node that has children will result in a [warnings spam](https://github.com/bevyengine/bevy/blob/main/crates/bevy_ui/src/flex/mod.rs#L120) since the children will not be part of a proper UI hierarchy anymore. --- ## Changelog - Fixed memory leak when nodes are removed in bevy_ui
# Objective Clean up taffy nodes when the associated UI node gets removed. The current UI code will keep the taffy nodes around forever. ## Solution Use `RemovedComponents<Node>` to iterate over nodes that are no longer valid UI nodes or that have been despawned, and remove them from taffy and the internal hash map. ## Implementation Notes Do note that using `despawn()` instead of `despawn_recursive()` on a UI node that has children will result in a [warnings spam](https://github.com/bevyengine/bevy/blob/main/crates/bevy_ui/src/flex/mod.rs#L120) since the children will not be part of a proper UI hierarchy anymore. --- ## Changelog - Fixed memory leak when nodes are removed in bevy_ui
Objective
Clean up taffy nodes when the associated UI node gets removed. The current UI code will keep the taffy nodes around forever.
Solution
Use
RemovedComponents<Node>
to iterate over nodes that are no longer valid UI nodes or that have been despawned, and remove them from taffy and the internal hash map.Implementation Notes
Do note that using
despawn()
instead ofdespawn_recursive()
on a UI node that has children will result in a warnings spam since the children will not be part of a proper UI hierarchy anymore.Changelog