Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI Node's dimensions are incorrectly calculated if camera at first node's update had zero size #13600

Open
bugsweeper opened this issue May 31, 2024 · 4 comments
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Bug An unexpected or incorrect behavior S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it!

Comments

@bugsweeper
Copy link
Contributor

bugsweeper commented May 31, 2024

why that would stick rather than get updated here

The reason is that compute_camera_layout() updates resolution in root_nodes.implicit_viewport_node which containes node for viewport (this is correct, because available_space relates to viewport), but then update_uinode_geometry_recursive() updates geometry starting from user ui root node which is just a child of viewport node. So user ui root node doesn't update according to updated camera.size.

Originally posted by @bugsweeper in #13517 (comment)

@bugsweeper
Copy link
Contributor Author

Behaviour is rare (app launched ~30 times to reproduce)
image

@mnmaita mnmaita added C-Bug An unexpected or incorrect behavior A-UI Graphical user interfaces, styles, layouts, and widgets labels May 31, 2024
@alice-i-cecile alice-i-cecile added the S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it! label May 31, 2024
@bugsweeper
Copy link
Contributor Author

bugsweeper commented Jun 5, 2024

I was wrong about source of problem earlier. compute_camera_layout() generates layout for viewport and all of it's child into cache (for current resolution). Then update_uinode_geometry_recursive() places nodes according to layout from cache.
The reason of #13517 is that layout is generated from styles (taffy's version of it) of node, but taffy's version of style of root node allready contains width equals to Some(0.0)!
Why? Because first time camera resolution was (0.0, 0.0), this is why when UiSurface::upsert_node it converts from bevy's style to taffy's style once, and never changes. It sets width to 0.0 because of Val::Vw(100.0) for zero resolution gives just 0.0.
I don't see nice solution yet.
@nicoburns Can you, as the author of layout calculation, advise what is best? Clear fields in taffy's Style which corresponds to Val fields in bevy's Style or just convert styles again before layout calculation?

@bugsweeper
Copy link
Contributor Author

bugsweeper commented Jun 5, 2024

Before you ask, UiSurface doesn't upsert again, because no condition is met, because when camera changes resolution from zero to nonzero it doesn't understand that something changes, it assumes that camera changes resolution when window changes resolution, attaching is not the case

@bugsweeper
Copy link
Contributor Author

bugsweeper commented Jun 5, 2024

@porkbrain Looks like you can workaround by emmiting resize event for window containing your ui after respawn of ui and camera

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Bug An unexpected or incorrect behavior S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it!
Projects
None yet
Development

No branches or pull requests

3 participants