UI Element Delayed positioning when just parented
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 7.8k
- Forks
- 1.2k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 49
Description
Release Type: Official Release/GitHub (please choose appropriate option)
Official Release
Version: Version number and/or git branch
4.2.0.2293
Platform(s): Does the problem occur on Windows, Android...?
Windows
Describe the bug
When UI is added in the Update loop to a existing Panel, through .Children.Add. It takes 2 update frames before position values are set.
To Reproduce
Steps to reproduce the behavior:
- New project
- Setup UIComponent with a empty Page
- Use the code in the image below
- Run project and stop project, then review immediate window.
Expected behavior
The first update frame has the margin updated added to the WorldMatrix.
Additional context
- The SharpDX exception may or may not be related.
- It will take three frames to setup positioning, even if the UIElement was added in later update frames.
- Its also sometimes possible that this position update delay can cause a crash. When a Matrix with the following values on the second frame happens, but I don't know the steps to reproduce.
[M11:1 M12:0 M13:0 M14:0] [M21:0 M22:1 M23:0 M24:0] [M31:0 M32:0 M33:1 M34:0] [M41:NaN M42:NaN M43:NaN M44:NaN]
Moving the mouse while theWorldMatrixis in the above state become a problem since it can trigger anArithmeticExceptionon theSignfunction trying to process a NaN value. This exception happens within the MouseOverChangedState functionality of the Stride UI.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the UIComponent/Page case by adding an element to an existing Panel through Children.Add during Update, then inspect when margin and WorldMatrix values are updated. Investigate the MouseOverChangedState path as well, since NaN WorldMatrix values may trigger the reported ArithmeticException. Done means positioning is valid on the first update frame and no related crash occurs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- frontend, game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100