Bevy UI freezes application after window resize
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## Bevy version
- 0.15.0
## \[Optional\] Relevant system information
If you cannot get Bevy to build or run on your machine, please include:
```
- cargo 1.83.0 (5ffbef321 2024-10-29)
- MacOS Sonoma 14.1.1 (23B81)
- SystemInfo { os: "MacOS 14.1.1 ", kernel: "23.1.0", cpu: "Apple M1 Max", core_count: "10", memory: "64.0 GiB" }
- AdapterInfo { name: "Apple M1 Max", vendor: 0, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Metal }
If your bug is rendering-related, copy the adapter info that appears when you run Bevy.
```
## What you did
I thought I was going crazy... My app just started freezing randomly. It took hours to find why it happens.
So in short I display some messages on screen when events happen. And exactly one message had correct length for BevyUI to go crazy. Changing text size/margins/paddings fixes this bug, so it must be related to screen size.
Code is very simple:
```rust
use bevy::dev_tools::fps_overlay::FpsOverlayPlugin;
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins((
DefaultPlugins,
FpsOverlayPlugin::default(),
))
.add_systems(Startup, spawn_overlay)
.run();
}
fn spawn_overlay(mut commands: Commands) {
let camera_entity = commands.spawn(Camera2d).id();
commands.spawn((
Node {
margin: UiRect::top(Val::VMin(20.0)),
padding: UiRect::all(Val::VMin(1.0)),
..default()
},
TargetCamera(camera_entity),
)).with_child((
Text::new("this is some very weird message that hangs bevy ui when resizing"),
TextFont::default().with_font_size(12.0),
));
}
```
## What went wrong
Application just freezes.

Changing text length fixes the problem:

## Additional information
Here are camera properties before freeze (can't print anything after):
```rust
physical_viewport_size - [2560, 1440]
logical_viewport_size - [1280, 720]
```
Here is a flamegraph:

Contributor guide
Assessment
This issue has not been assessed yet.