-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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 transform is sometimes incorrectly calculated #13517
Comments
Sounds like a system ordering issue if it's occurring irregularly. |
I thought perhaps the fact that I was not setting a height and relying on the content to expand that node might have been be the issue. Setting min height in the styles did not help though. Also changing pretty much any What's a good way for me to provide more information? I tried |
I'd really like a minimal reproducible example. Failing that, a reproducible example at all so we can test fixes would be super useful. Normally I'd tell you to test this upstream in |
I seperated out the relevant code to this repo. When I run this repo a few times, I encounter the problem.
|
The culprit seems to be the Now, it's unclear whether merely adding some extra systems increases the odds of this happening due to, as you pointed out, some specific ordering condition, or whether the plugin directly breaks something that |
@porkbrain Looks like as in #13155 there is a problem in bevy_ui (or rather in taffy api), when there is only one dimension ( |
I think
would be better temporary workaround, it behaves well when toggling, but not when resizing |
Agree that this is another instance of #13155
Hmm... this was also my understanding of the issue. EDIT: Ok, I've found another issue that may have caused the min-width to be ignored. #13555 is up that should hopefully fix both issues. |
Thanks everyone for their support. Given that the linked issue is very active and the suggested temporary workaround, I will close this and pay attention to #13555. Once |
@porkbrain I think you should reopen this issue, because taffy's ratio blindness is just a part of problem, the issue which we mentioned contains description of bug, that is stable and relates to images, but root node here is not image rather container! Every run we get same result there, but bug in this issue is floating. Second part (more important) of this problem is that some times node lives in zero-sized environment!
Any way looks like taffy is not the source of problem here rather victim of circumstances |
Some experimenting I did a while back is that the resolution sometimes gets set to 0, 0 when minimized and under other certain conditions depending on the platform. But I don't understand why that would stick rather than get updated here. I would probably check if the window's physical resolution matches the camera's computed target info, my guess is there is a chain here where it misses an update about this. |
Looks like camera fixes it's resolution later, but taffy still continues to store zeros in layout despite being given the correct data at step 2
My reproducing flow is restarting app from reproduce instructions until problem occurs (determine unsuccessfull launch), then I can repeat problem again just by toggling nodes without app restart. |
Update:
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. @bardt, please tell us, shouldn't camera.root_nodes contain node of viewport instead of ui root node? |
…zes (#13555) # Objective - Fixes #13155 - fixes #13517 - Supercedes #13381 - Requires DioxusLabs/taffy#661 ## Solution - Taffy has been updated to: - Apply size styles to absolutely positioned children - Pass the node's `Style` through to the measure function - Bevy's image measure function has been updated to make use of this style information ## Notes - This is currently using a git version of Taffy. If this is tested as fixing the issue then we can turn that into a Taffy 0.5 release (this would be the only change between Taffy 0.4 and Taffy 0.5 so upgrading is not expected to be an issue) - This implementation may not be completely correct. I would have preferred to extend Taffy's gentest infrastructure to handle images and used that to nail down the correct behaviour. But I don't have time for that atm so we'll have to iterate on this in future. This PR at least puts that under Bevy's control. ## Testing - I manually tested the game_menu_example (from #13155) - More testing is probably merited --- ## Changelog No changelog should be required as it fixes a regression on `main` that was not present in bevy 0.13. The changelog for "Taffy upgrade" may want to be changed from 0.4 to 0.5 if this change gets merged. --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com> Co-authored-by: François Mockers <francois.mockers@vleue.com>
@alice-i-cecile I think we should reopen this issue again, I left additional info in previous comment about reason why this issue wants another PR. |
@alice-i-cecile I did migrate example to bevy main (with #13555 fix) and example became much more stable (I ran ~30 times example to reproduce bug), but bug still persist. I will make fix PR according to syncing viewport and root ui node |
@bugsweeper Maybe open a new issue tracking the viewport updating issue |
Context
Bevy 0.13.2
Ubuntu 22.04.4
3840x1600
What you did
I spawned a UI node that acts as a root for its child nodes. It's attached to the bottom of the screen and full screen width.
What went wrong
When I spawn this node for the first time it has about one in five chance that it would have an incorrect transform
x
calculated (making it invisible.)Here's what the transform value is when it loads incorrectly:
Here's what the value is when it loads correctly.
Also, I can fix an incorrect spawn by changing the position from absolute to relative and back to absolute again in the egui, after which the value is corrected:
The text was updated successfully, but these errors were encountered: