bevy icon indicating copy to clipboard operation
bevy copied to clipboard

UI Layout Or Size Can Seem To Shift Unnecessarily Post-Creation

Open TrialDragon opened this issue 1 year ago • 7 comments

Bevy version

Bevy v0.14.2

What you did

We created a main menu for our game using straight Bevy UI.

What went wrong

On spawning the main menu UI, it shifts / changes during the frame after creation. The expectation is that it would spawn with the correct layout and size, not having to shift to accommodate or conform to what is wanted, since nothing should've changed from the values passed for initial creation.

Video showcasing what I'm talking about specifically: https://github.com/user-attachments/assets/4c440f45-f723-4c69-ab23-92378c421262

Additional information

My best guess as to what this is, is some form of layout calculations being performed in Bevy UI?

We don't think it's any of our code that is causing this; it still occurs after disabling / removing any systems which may modify UI values post-creation. Tho, if this does end up being a fault in the code we wrote, rather than Bevy UI, or even just intended behavior, then sorry for making this issue and wasting time.

TrialDragon avatar Oct 10 '24 17:10 TrialDragon

Does this happen across all platforms? Can you reproduce this on main? I suspect this is actually windowing related, where we're not getting the right window size soon enough.

alice-i-cecile avatar Oct 10 '24 17:10 alice-i-cecile

I know it occurs on macOS (every time it is spawned), and Linux [Fedora] (I've only seen it the first time it's spawned per run so far). I'll try to make an MRE, and then see if that works on main (I don't want to deal with migrating a whole game to main, especially when I probably should make sure this is reproducible first).

TrialDragon avatar Oct 10 '24 18:10 TrialDragon

I slowed a recording of this down WAY more and cut it to the moment it switches from ingame to menu to illustrate the strange 2 frames that make up this weirdness:

https://github.com/user-attachments/assets/363f9325-9b81-4e9f-bc0d-1c772421945b

extrawurst avatar Oct 10 '24 21:10 extrawurst

Is there a chance that this is scale factor related? It looks like this is on a mobile phone emulator? Is it consistent every run?

alice-i-cecile avatar Oct 10 '24 23:10 alice-i-cecile

Nope it’s happening on my macOS build consistently in every run. Of course that also has a scaling factor but I seem to be able to corner it more down to when it got introduced.

and it seems to be an instability related to cramping multiple elements in a column that define height: 100%

extrawurst avatar Oct 10 '24 23:10 extrawurst

Speaking of which: https://github.com/DioxusLabs/taffy/releases/tag/v0.6.0 :)

extrawurst avatar Oct 10 '24 23:10 extrawurst

And as a result, #15844 :D I'd love if you could test with that PR.

alice-i-cecile avatar Oct 10 '24 23:10 alice-i-cecile

I suspect it won't help but can you test this with #16097.

ickshonpe avatar Oct 25 '24 09:10 ickshonpe

I would love to test against the new taffy release or #16097, but the problem i have is that it is practically impossible to switch my project to main because of the dozens of dependencies i have :( I don't have yet a simple example reproducer

extrawurst avatar Oct 25 '24 10:10 extrawurst

You could just make a fork of bevy 14, set the taffy version to 0.6 and backport #16067 (which only changes a few lines). Don't worry yourself if that seems like too much hassle though.

ickshonpe avatar Oct 25 '24 10:10 ickshonpe