Skip to content

UI Node's transform is sometimes incorrectly calculated #13517

@porkbrain

Description

@porkbrain

Context

  • Bevy 0.13.2
  • Ubuntu 22.04.4
  • Resolution 3840x1600
2024-05-26T11:06:44.685619Z  INFO log: Guessed window scale factor: 1    
2024-05-26T11:06:44.720176Z  WARN log: InstanceFlags::VALIDATION requested, but unable to find layer: VK_LAYER_KHRONOS_validation    
2024-05-26T11:06:44.728709Z  INFO log: Debug utils not enabled: debug_utils_user_data not passed to Instance::from_raw    
2024-05-26T11:06:44.740176Z  INFO log: Using X11 platform    
2024-05-26T11:06:44.811299Z  WARN log: Detected skylake derivative running on mesa i915. Clears to srgb textures will use manual shader clears.    
2024-05-26T11:06:44.811326Z  INFO log: Adapter Vulkan AdapterInfo { name: "NVIDIA GeForce RTX 3080 Laptop GPU", vendor: 4318, device: 9372, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "545.29.06", backend: Vulkan }    
2024-05-26T11:06:44.811348Z  INFO bevy_render::renderer: AdapterInfo { name: "NVIDIA GeForce RTX 3080 Laptop GPU", vendor: 4318, device: 9372, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "545.29.06", backend: Vulkan }

What you did

I spawned a UI node that acts as a root for its child nodes. It's attached to the bottom of the screen and full screen width.

cmd
            .spawn((
                Name::new("Portrait dialog root"),
                DialogUiRoot,
                TargetCamera(camera),
                NodeBundle {
                    // centers the content
                    style: Style {
                        width: Val::Vw(100.0),
                        bottom: Val::Px(0.0),
                        position_type: PositionType::Absolute,
                        flex_direction: FlexDirection::RowReverse,

                        ..default()
                    },
                    ..default()
                },
            ))

What went wrong

When I spawn this node for the first time it has about one in five chance that it would have an incorrect transform x calculated (making it invisible.)

Here's what the transform value is when it loads incorrectly:
Screenshot from 2024-05-26 13-08-20

Here's what the value is when it loads correctly.
Also, I can fix an incorrect spawn by changing the position from absolute to relative and back to absolute again in the egui, after which the value is corrected:
Screenshot from 2024-05-26 13-08-48

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-UIGraphical user interfaces, styles, layouts, and widgetsC-BugAn unexpected or incorrect behaviorS-Needs-InvestigationThis issue requires detective work to figure out what's going wrong

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions