stride3d / stride3d/stride

UI Element Delayed positioning when just parented

Open
#2,602 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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:

  1. New project
  2. Setup UIComponent with a empty Page
  3. Use the code in the image below
  4. Run project and stop project, then review immediate window.
    Image

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 the WorldMatrix is in the above state become a problem since it can trigger an ArithmeticException on the Sign function trying to process a NaN value. This exception happens within the MouseOverChangedState functionality of the Stride UI.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.