So we’re seeing some weird issues, mostly on device (they are hard to trigger in editor)
It seems to have to do with the Style Animation system as that is what the stack trace gives us and it might be that an animation is triggered twice as seems to run into Dictionary key duplication:
System.ArgumentException: An item with the same key has already been added. Key: UnityEngine.UIElements.StylePropertyAnimationSystem+ElementPropertyPair
at System.Collections.Generic.Dictionary2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) [0x001cc] in <06a8633d56964cb4a0c4050a8ba5ed74>:0 at System.Collections.Generic.Dictionary2[TKey,TValue].Add (TKey key, TValue value) [0x00000] in <06a8633d56964cb4a0c4050a8ba5ed74>:0
at UnityEngine.UIElements.StylePropertyAnimationSystem+AnimationDataSet2[TTimingData,TStyleData].Add (UnityEngine.UIElements.VisualElement owner, UnityEngine.UIElements.StyleSheets.StylePropertyId prop, TTimingData timingData, TStyleData styleData) [0x00066] in /home/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/StylePropertyAnimationSystem.cs:112 at UnityEngine.UIElements.StylePropertyAnimationSystem+Values1[T].UpdateProgress (System.Int64 currentTimeMs) [0x000ae] in /home/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/StylePropertyAnimationSystem.cs:811
at UnityEngine.UIElements.StylePropertyAnimationSystem+Values`1[T].Update (System.Int64 currentTimeMs) [0x00008] in /home/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/StylePropertyAnimationSystem.cs:756
at UnityEngine.UIElements.StylePropertyAnimationSystem.Update () [0x0001d] in /home/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/StylePropertyAnimationSystem.cs:1431
at UnityEngine.UIElements.VisualElementAnimationSystem.Update () [0x000b1] in /home/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/VisualTreeAnimationUpdater.cs:87
at UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTreePhase (UnityEngine.UIElements.VisualTreeUpdatePhase phase) [0x0001e] in /home/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/VisualTreeUpdater.cs:111
at UnityEngine.UIElements.Panel.UpdateAnimations () [0x0000d] in /home/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/Panel.cs:957
at UnityEngine.UIElements.BaseVisualElementPanel.Update () [0x0001b] in /home/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/Panel.cs:561
at UnityEngine.UIElements.RuntimePanel.Update () [0x0001d] in /home/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/GameObjects/RuntimePanel.cs:47
at UnityEngine.UIElements.UIElementsRuntimeUtility.UpdateRuntimePanels () [0x0001d] in /home/bokken/buildslave/unity/build/ModuleOverrides/com.unity.ui/Core/UIElementsRuntimeUtility.cs:218
at UnityEngine.UIElements.UIElementsRuntimeUtilityNative.UpdateRuntimePanels () [0x00001] in /home/bokken/buildslave/unity/build/Modules/UIElementsNative/UIElementsUtility.bindings.cs:26
How do we debug this or rather, is this a bug that should be cought by UIToolkit itself? Its really hard to reproduce reliably in Editor. This error also doesn’t go away, its stuck in this state perpetually it seems and UIToolkit is partially non-functional afterwards.
Managed a minimal repro that is consistent, it happens when you click a button that dismisses itself and the screen behind it but behind the button is another button that has a hover effect.
Its complicated. I’ll make sure to open a bug for this. Its really weird.
Where background-color is not set. This leads to a continuous stream of exceptions following a NullReferenceException on removal of an item that is not the top of its respective hierarchy.
Fun fact, this also only seems to happen if you add a VisualElement to the same hierarchy you are removing the one that contains the transition in the same frame!
I also encounter this error in 2022.2.1f1
In my case, the error randomly appears when you click on the GameObject (on which the UI Document is attached) in the scene hierarchy
but… As far as I can tell this doesn’t affect functionality… Just spamming bugs
I reported this bug. Since then 8 new versions have been released but it’s still not fixed. I’m using 2022.2.3f1 and waiting for the new 2022.2 in which it will be fixed. I can’t do more than one animation in a loop without it.
Please backport this! Still not fixed in 2022.2.11f1 which makes it so I can’t use animations in most of my UI, when it worked in 2021.3. This is a major regression!
I’ve filed a bug report too https://unity3d.atlassian.net/servicedesk/customer/portal/2/IN-35324
It’s now very tricky to move on with my current project, built with 2022 (specifically to be able to use features of UITK), I’m uncomfortable moving the project to 2023 and being in bug-limbo, I’m considering stripping out all the uss transitions and replacing with DoTween