-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Open
Labels
A-UIGraphical user interfaces, styles, layouts, and widgetsGraphical user interfaces, styles, layouts, and widgetsC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behaviorP-CrashA sudden unexpected crashA sudden unexpected crashS-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplished
Description
Bevy version 0.15.0
(0.14.2 also had this issue)
What you did
I created a UI node hierarchy, that looks like this:
<div width=184 height=288 align_self=center justify_self=center>
<div>
<div position=absolute width=100% height=100% flex_direction=column>
<div margin_left=10 margin_right=10>
<text text="hello world"/>
</div>
</div>
</div>
</div>
I know, it kinda does not make sense as there is a node with 100% size and parent size is not defined, but that should not crash anyway...
The code:
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins((DefaultPlugins.set::<AssetPlugin>(AssetPlugin {
watch_for_changes_override: Some(true),
..Default::default()
}),))
.add_systems(Startup, setup)
.run();
}
fn setup(mut commands: Commands) {
commands.spawn((Camera2d::default(), IsDefaultUiCamera));
// <div width=184 height=288 align_self=center justify_self=center>
// <div>
// <div position=absolute size=100% flex_direction=column>
// <div margin_x=10>
// <text text="hello world"/>
// </div>
// </div>
// </div>
// </div>
commands
.spawn(Node {
width: Val::Px(184.0),
height: Val::Px(288.0),
align_self: AlignSelf::Center,
justify_self: JustifySelf::Center,
..Default::default()
})
.with_children(|parent| {
parent
.spawn(Node {
..Default::default()
})
.with_children(|parent| {
parent
.spawn(Node {
position_type: PositionType::Absolute,
width: Val::Percent(100.0),
height: Val::Percent(100.0),
flex_direction: FlexDirection::Column,
..Default::default()
})
.with_children(|parent| {
parent
.spawn(Node {
margin: UiRect {
left: Val::Px(10.0),
right: Val::Px(10.0),
..Default::default()
},
..Default::default()
})
.with_children(|parent| {
parent.spawn(Text("hello world".to_string()));
});
});
});
});
}
What went wrong
It crashes.
rustlib/src/rust/library/core/src/num/f32.rs:1406:9:
min > max, or either was NaN. min = 0.0, max = -10.0
stack backtrace:
0: rust_begin_unwind
at /rustc/55a22d2a63334e0faff0202b72a31ce832b56125/library/std/src/panicking.rs:665:5
1: core::panicking::panic_fmt
at /rustc/55a22d2a63334e0faff0202b72a31ce832b56125/library/core/src/panicking.rs:74:14
2: core::f32::<impl f32>::clamp
at /Users/romamik/.rustup/toolchains/nightly-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/num/f32.rs:1406:9
3: bevy_ui::ui_node::BorderRadius::resolve_single_corner
at /Users/romamik/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ui-0.15.0/src/ui_node.rs:2354:9
4: bevy_ui::ui_node::BorderRadius::resolve
at /Users/romamik/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ui-0.15.0/src/ui_node.rs:2373:23
5: bevy_ui::layout::ui_layout_system::update_uinode_geometry_recursive
at /Users/romamik/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ui-0.15.0/src/layout/mod.rs:382:64
6: bevy_ui::layout::ui_layout_system::update_uinode_geometry_recursive
at /Users/romamik/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ui-0.15.0/src/layout/mod.rs:445:17
7: bevy_ui::layout::ui_layout_system::update_uinode_geometry_recursive
at /Users/romamik/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ui-0.15.0/src/layout/mod.rs:445:17
8: bevy_ui::layout::ui_layout_system::update_uinode_geometry_recursive
at /Users/romamik/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ui-0.15.0/src/layout/mod.rs:445:17
9: bevy_ui::layout::ui_layout_system
at /Users/romamik/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_ui-0.15.0/src/layout/mod.rs:301:13
10: <bevy_ecs::system::function_system::FunctionSystem<Marker,F> as bevy_ecs::system::system::System>::run_unsafe
Metadata
Metadata
Assignees
Labels
A-UIGraphical user interfaces, styles, layouts, and widgetsGraphical user interfaces, styles, layouts, and widgetsC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behaviorP-CrashA sudden unexpected crashA sudden unexpected crashS-Needs-DesignThis issue requires design work to think about how it would best be accomplishedThis issue requires design work to think about how it would best be accomplished