Quaternion To Matrix conversion failed because input Quaternion is invalid {nan, nan, nan, nan} l=na

I noticed a strange behavior in the UI Elements (missing events, elements with wrong pointer state, sometimes no ui elements were rendered), and i guess these errors here can be a reason. I had one of these errors already a longer time, in some special situations, but never had such an impact.
The main problem is that i have no starting point to debug, and no idea to what part its related. So its impossible for me to create a reproducable repository.I have no idea how to debug that.

Quaternion To Matrix conversion failed because input Quaternion is invalid {nan, nan, nan, nan} l=nan
UnityEngine.UIElements.UIElementsRuntimeUtilityNative:UpdateRuntimePanels ()
Quaternion To Matrix conversion failed because input Quaternion is invalid {nan, nan, nan, nan} l=nan
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

I tried to figure out what it is, but i can’t find anything related to the Stacktrace and i can’t figure out more in the reference implementation on github.

What i tried is to check my complete VisualElement graph for NaN values in several style elements, but all look fine. (or maybe i did it wrong)

    // Iterative called for all visual elements in the hierarchy.
    // Checked for width, height, bottom,... , all padding, all margin style values
    private void Verify(VisualElement element, StyleLength length, string propertyName) {
        if (float.IsNaN(length.value.value))
            Debug.LogError($"{propertyName} was NaN of {element}");
    }

I’m on Unity 2022.3.2f1

I found a reason somewhere inside of my code i sometimes use the localBounds and worldBounds to calculate positions. They can be NaN when not initialized from the ui system yet. Ends up in setting NaNs to the style values.

=> Can be good to check in the Style Values for NaNs when they are set, to fail fast with a good point to start debugging. If not, it should prevented to completely break the whole game instead :slight_smile: