bevyengine / bevyengine/bevy

bug(ui): `Node` position/occupied area computed incorrectly in some scenarios

Open
#23,964 0 comments 0 reactions 0 assignees View on GitHub
A-UI C-Bug S-Needs-Investigation
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## Bevy version and features

- `bevy@0.18.1`
- `"2d", "webp"`

## Relevant system information

**Platform:** `x86_64-unknown-linux-gnu`

**Monitor Resolution:** `3840x2160`

**AdapterInfo:**

```
AdapterInfo { name: "AMD Radeon Graphics (RADV RENOIR)", vendor: 4098, device: 5708, device_type: IntegratedGpu, driver: "radv", driver_info: "Mesa 26.0.5-arch1.1", backend: Vulkan }
```

## What you did

This is a minimal code snippet where the behavior can be observed:

```rust
use bevy::prelude::*;
use bevy_inspector_egui::{bevy_egui::EguiPlugin, quick::WorldInspectorPlugin};

fn main() -> AppExit {
App::new()
.add_plugins((
DefaultPlugins,
EguiPlugin::default(),
WorldInspectorPlugin::default(),
))
.add_systems(Startup, setup)
.run()
}

/// Setup scene
fn setup(mut commands: Commands) {
commands.spawn(Camera2d);

commands.spawn((
Node {
// NOTE: Without this, the bug cannot be observed.
padding: UiRect::all(vmin(10)),
..default()
},
children![(
Node {
width: px(288),
height: px(82),
border_radius: BorderRadius::MAX,
align_items: AlignItems::Center,
padding: UiRect::all(px(12)),
..default()
},
BackgroundColor(Color::WHITE),
children![(
Node {
width: percent(100),
height: percent(100),
border_radius: BorderRadius::MAX,
..default()
},
BackgroundColor::from(LinearRgba::RED),
children![(
Node {
position_type: PositionType::Absolute,
right: Val::ZERO,
width: px(3.6),
height: percent(100),
..default()
},
BackgroundColor(Color::WHITE),
)]
)],
)],
));
}
```

The code snippet also includes `bevy_inspector_egui` to be able to modify the third child `Node`s width that is currently at `width: px(3.6)`, but `bevy_inspector_egui` is not necessary for this.

The snippet should reproduce the error right away. If it does not, changing the window size sometimes fixes the bug, therefore modifying that might help with reproducing it.

## What went wrong

In the code snippet above I expect the second child `Node` to be fully masked by the third on the right side at all times.

This is not the case, on certain widths, a pixel of the second child `Node` is visible.

## Screenshot

Image

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.