Repository: bevyengine/bevy
File: crates/bevy_ui/src/layout/mod.rs (Rust)

Code before:
                    computed_target.physical_size.as_vec2(),
                );
                let measure = content_size.and_then(|mut c| c.measure.take());
                ui_surface.upsert_node(&layout_context, entity, &node, measure);
            }
        });

    // update and remove children
    for entity in removed_children.read() {
        ui_surface.try_remove_children(entity);
    }

    // clean up removed nodes after syncing children to avoid potential panic (invalid SlotMap key used)
    ui_surface.remove_entities(
        removed_nodes
            .read()
            .filter(|entity| !node_query.contains(*entity)),
    );

    for ui_root_entity in ui_root_node_query.iter() {
        fn update_children_recursively(
            ui_surface: &mut UiSurface,
            ui_children: &UiChildren,
            added_node_query: &Query<(), Added<Node>>,
            entity: Entity,
        ) {
            if ui_surface.entity_to_taffy.contains_key(&entity)
                && (added_node_query.contains(entity)
                    || ui_children.is_changed(entity)
                    || ui_children
                        .iter_ui_children(entity)
                        .any(|child| added_node_query.contains(child)))
            {
                ui_surface.update_children(entity, ui_children.iter_ui_children(entity));
            }

            for child in ui_children.iter_ui_children(entity) {
                update_children_recursively(ui_surface, ui_children, added_node_query, child);
            }
        }

        for ui_root_entity in ui_root_node_query.iter() {
            update_children_recursively(
                &mut ui_surface,
                &ui_children,
                &added_node_query,
                ui_root_entity,
            );
        }

        let (_, _, _, computed_target) = node_query.get(ui_root_entity).unwrap();

Review comment (suggestion):
Looks like we lost this warning. Though I can see how it kind of contradicts the "sync on `Node` addition" support, as warnings would be logged for entities that are still not fully initialized but on their way to be in a few frames 🤔 

Code after:
                    computed_target.physical_size.as_vec2(),
                );
                let measure = content_size.and_then(|mut c| c.measure.take());
                ui_surface.upsert_node(&layout_context, entity, &node, measure);
            }
        });

    // update and remove children
    for entity in removed_children.read() {
        ui_surface.try_remove_children(entity);
    }

    // clean up removed nodes after syncing children to avoid potential panic (invalid SlotMap key used)
    ui_surface.remove_entities(
        removed_nodes
            .read()
            .filter(|entity| !node_query.contains(*entity)),
    );

    for ui_root_entity in ui_root_node_query.iter() {
        fn update_children_recursively(
            ui_surface: &mut UiSurface,
            ui_children: &UiChildren,
            added_node_query: &Query<(), Added<Node>>,
            entity: Entity,
        ) {
            if ui_surface.entity_to_taffy.contains_key(&entity)
                && (added_node_query.contains(entity)
                    || ui_children.is_changed(entity)
                    || ui_children
                        .iter_ui_children(entity)
                        .any(|child| added_node_query.contains(child)))
            {
                ui_surface.update_children(entity, ui_children.iter_ui_children(entity));
            }

            for child in ui_children.iter_ui_children(entity) {
                update_children_recursively(ui_surface, ui_children, added_node_query, child);
            }
        }

        update_children_recursively(
            &mut ui_surface,
            &ui_children,
            &added_node_query,
            ui_root_entity,
        );

        let (_, _, _, computed_target) = node_query.get(ui_root_entity).unwrap();

        ui_surface.compute_layout(