bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
35.71k stars 3.53k forks source link

Invalid node size calculation for text + flex_grow: 1.0 #9350

Closed jkb0o closed 1 year ago

jkb0o commented 1 year ago

Bevy version

v0.11.0

Relevant system information

Cargo: cargo 1.71.0 (cfd3bbd8f 2023-06-08) Adapter: AdapterInfo { name: "Apple M2", vendor: 0, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Metal } System: SystemInfo { os: "MacOS 13.0 ", kernel: "22.1.0", cpu: "Apple M2", core_count: "8", memory: "16.0 GiB" }

What you did

I create multiple nodes with two flex_grow: 1 nodes (the first one is parent of the second one) and put some text inside the second node. On the video the center red node has flex_grow: 1, the center green node has flex_grow: 1 and the text added to the center green node.

What went wrong

When I try to resize the window, the center green node doesn't reduce the size to match the size of the text.

Additional information

Providing width to the center green node will fix the issue

https://github.com/bevyengine/bevy/assets/122736/80de67d7-e1dc-4861-8a4a-74db371a3a97

There is the sample project: bevy-issue-flex-grow.zip

ickshonpe commented 1 year ago

Looks like a bug in Taffy, since the text node is the correct size. The sample project works correctly if you replace the text node with a regular NodeBundle and a fixed size measure func.

nicoburns commented 1 year ago

I have been able to reproduce this as a Taffy gentest, so I can confirm that this is (most likely) a bug in Taffy. It seems to be using the min-content size for the text when it shouldn't be, or something like that.

nicoburns commented 1 year ago

Taffy 0.3.13, which includes the fix for this issue has now been released. Please cargo update to obtain the fix :)

jkb0o commented 1 year ago

@nicoburns thank you!