bevy/crates
robtfm 30940e5cb4
fix occasional crash moving ui root nodes (#11371)
# Objective

fix an occasional crash when moving ui root nodes between cameras.

occasionally, updating the TargetCamera of a ui element and then
removing the element causes a crash.

i believe that is because when we assign a child in taffy, the old
parent doesn't remove that child from it's children, so we have:

```
user: create root node N1, camera A
-> layout::set_camera_children(A) : 
	- create implicit node A1
	- assign 1 as child -> taffy.children[A1] = [N1], taffy.parents[1] = A1

user: move root node N1 to camera B
-> layout::set_camera_children(B) :
	- create implicit node B1
	- assign 1 as child -> taffy.children[A1] = [N1], taffy.children[B1] = [N1], taffy.parents[1] = B1
-> layout::set_camera_children(A) :
	- remove implicit node A1 (which still has N1 as a child) -> 
		-> taffy sets parent[N1] = None ***
		-> taffy.children[B1] = [N1], taffy.parents[1] = None

user: remove N1
-> layout::remove_entities(N1)
	- since parent[N1] is None, it's not removed from B1 -> taffy.children[B1] = [N1], taffy.parents[1] is removed
-> layout::set_camera_children(B)
	- remove implicit node B1
	- taffy crash accessing taffy.parents[N1]
```

## Solution

we can work around this by making sure to remove the child from the old
parent if one exists (this pr).

i think a better fix may be for taffy to check in `Taffy::remove` and
only set the child's parent to None if it is currently equal to the node
being removed but i'm not sure if there's an explicit assumption we're
violating here (@nicoburns).
2024-01-17 16:53:27 +00:00
..
bevy_a11y resolve all internal ambiguities (#10411) 2024-01-09 19:08:15 +00:00
bevy_animation Skip alloc when updating animation path cache (#11330) 2024-01-13 19:33:11 +00:00
bevy_app resolve all internal ambiguities (#10411) 2024-01-09 19:08:15 +00:00
bevy_asset Fix embedded watcher to work with external crates (#11370) 2024-01-16 15:18:16 +00:00
bevy_audio Remove the ability to ignore global volume (#11092) 2024-01-15 15:31:54 +00:00
bevy_core Replace or document ignored doctests (#11040) 2024-01-01 16:50:56 +00:00
bevy_core_pipeline Exposure settings (adopted) (#11347) 2024-01-16 14:53:21 +00:00
bevy_derive Reexport winit::platform::android::activity::* in bevy_winit (#11011) 2023-12-19 20:15:03 +00:00
bevy_diagnostic Describe purpose of bevy_diagnostic (#11327) 2024-01-14 20:17:26 +00:00
bevy_dylib Add [lints] table, fix adding #![allow(clippy::type_complexity)] everywhere (#10011) 2023-11-18 20:58:48 +00:00
bevy_dynamic_plugin Add [lints] table, fix adding #![allow(clippy::type_complexity)] everywhere (#10011) 2023-11-18 20:58:48 +00:00
bevy_ecs Remove duplicate #[automatically_derived] in ECS macro (#11388) 2024-01-17 16:52:45 +00:00
bevy_ecs_compile_fail_tests Dynamic queries and builder API (#9774) 2024-01-16 19:16:49 +00:00
bevy_encase_derive Add [lints] table, fix adding #![allow(clippy::type_complexity)] everywhere (#10011) 2023-11-18 20:58:48 +00:00
bevy_gilrs Remove unnecessary path prefixes (#10749) 2023-11-28 23:43:40 +00:00
bevy_gizmos Warn when bevy_sprite and bevy_pbr are not enabled with bevy_gizmos (#11296) 2024-01-14 13:51:14 +00:00
bevy_gltf Use glam for computing gLTF node transform (#11361) 2024-01-16 14:33:19 +00:00
bevy_hierarchy Inline trivial methods in bevy_hierarchy (#11332) 2024-01-13 22:20:50 +00:00
bevy_input Extend Touches with clear and reset methods (#10930) 2024-01-04 23:13:29 +00:00
bevy_internal Revert "Implement minimal reflection probes. (#10057)" (#11307) 2024-01-12 20:41:51 +00:00
bevy_log Add support for updating the tracing subscriber in LogPlugin (#10822) 2024-01-15 15:26:13 +00:00
bevy_macro_utils Bump toml_edit in build-template-pages tool (#11342) 2024-01-16 05:23:18 +00:00
bevy_macros_compile_fail_tests Standardize toml format with taplo (#10594) 2023-11-21 01:04:14 +00:00
bevy_math Remove Default impl for CubicCurve (#11335) 2024-01-14 04:40:37 +00:00
bevy_mikktspace Update glam, encase and hexasphere (#11082) 2024-01-08 22:58:45 +00:00
bevy_pbr Exposure settings (adopted) (#11347) 2024-01-16 14:53:21 +00:00
bevy_ptr Simplify equality assertions (#10988) 2023-12-16 23:58:41 +00:00
bevy_reflect Update glam, encase and hexasphere (#11082) 2024-01-08 22:58:45 +00:00
bevy_reflect_compile_fail_tests Fix nested generics in Reflect derive (#10791) 2023-11-29 01:46:09 +00:00
bevy_render Make DynamicUniformBuffer::push accept an &T instead of T (#11373) 2024-01-16 20:51:56 +00:00
bevy_scene Change Entity::generation from u32 to NonZeroU32 for niche optimization (#9907) 2024-01-08 23:03:00 +00:00
bevy_sprite Texture Atlas rework (#5103) 2024-01-16 13:59:08 +00:00
bevy_tasks Async channel v2 (#10692) 2024-01-15 19:23:00 +00:00
bevy_text Texture Atlas rework (#5103) 2024-01-16 13:59:08 +00:00
bevy_time Add paused run condition (#11313) 2024-01-12 22:18:57 +00:00
bevy_transform Rename "AddChild" to "PushChild" (#11194) 2024-01-04 16:06:14 +00:00
bevy_ui fix occasional crash moving ui root nodes (#11371) 2024-01-17 16:53:27 +00:00
bevy_utils Add static assertions to bevy_utils for compile-time checks (#11182) 2024-01-02 22:08:30 +00:00
bevy_window Remove CanvasParentResizePlugin (#11057) 2023-12-21 20:01:22 +00:00
bevy_winit Change WinitPlugin defaults to limit game update rate when window is not visible (for real this time) (#11305) 2024-01-15 17:53:35 +00:00