bevyengine / bevyengine/bevy

UI Node's dimensions are incorrectly calculated if camera at first node's update had zero size

Open
#13,600 4 comments 0 reactions 0 assignees View on GitHub
A-UI C-Bug S-Ready-For-Implementation
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

> why that would stick rather than get updated here

The reason is that [compute_camera_layout()](https://github.com/bevyengine/bevy/blob/main/crates/bevy_ui/src/layout/mod.rs#L223) updates resolution in [root_nodes.implicit_viewport_node](https://github.com/bevyengine/bevy/blob/main/crates/bevy_ui/src/layout/ui_surface.rs#L211) which containes node for viewport (this is correct, because available_space relates to viewport), but then [update_uinode_geometry_recursive()](https://github.com/bevyengine/bevy/blob/main/crates/bevy_ui/src/layout/mod.rs#L225) updates geometry starting from user ui root node [which is just a child of viewport node](https://github.com/bevyengine/bevy/blob/main/crates/bevy_ui/src/layout/ui_surface.rs#L185). So user ui root node doesn't update according to updated camera.size.

_Originally posted by @bugsweeper in https://github.com/bevyengine/bevy/issues/13517#issuecomment-2139359533_

Contributor guide

Open the contributing guide

Research direction

Start in crates/bevy_ui/src/layout/mod.rs at compute_camera_layout() and update_uinode_geometry_recursive(), then inspect the related root_nodes definitions in crates/bevy_ui/src/layout/ui_surface.rs. Reproduce the zero-size camera case and trace whether the user UI root receives the updated viewport dimensions; done means UI node dimensions are recalculated correctly after the camera size changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
frontend, game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.