State system OutOfMemoryException

Arficord

New member
I change prefab and open scene, sometimes I take OutOfMemoryException and broken UI window. Only one fix is revert all changes. From my resources I have found that happens when prefab is overridden at the scene, but I'm not sure that only one case.

I have found how to reproduce the problem at demo scene Unity 2021. 1. 18f1. UCC 2.3.6
It's important to not save scene unless it be said. In my project I work with saved scenes and prefabs
1. Create prefab from Nolan
2. Save scene
3. Add State with new preset to Jump ability at Nolan (on scene).
4. Add State with previously created preset to Jump ability at Nolan prefab (at assets).
4.1. Set different name to this state
5. Enter at playmode

 
I am unable to reproduce that. What is the full stack trace of the exception?
 
It looks like something got corrupted. To verify that the exception still exists can you create a new project with the latest version of the controller and see if you can reproduce it?
 
I am unable to reproduce that. What is the full stack trace of the exception?
Here with full stack trace (previously Script Only)1639042112617.png
OutOfMemoryException: Out of memory
System.Array.CreateInstance (System.Type elementType, System.Int32[] lengths) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.Array.CreateInstance (System.Type elementType, System.Int32 length) (at <695d1cc93cca45069c528c15c9fdd749>:0)
Opsive.Shared.Utility.Serializer.BytesToValue (System.Type type, System.String name, System.Collections.Generic.Dictionary`2[TKey,TValue] valuePositionMap, System.Int32 hashPrefix, System.Byte[] values, System.Int32[] valuePositions, UnityEngine.Object[] unityObjects, System.Boolean useFields, Opsive.Shared.Utility.MemberVisibility visibility, System.Boolean bitwiseHash, System.Func`3[T1,T2,TResult] onValidateCallback) (at <1b344c5d94b043229e545d418d0ddcb6>:0)
Opsive.Shared.Utility.Serialization.DeserializeFields (System.Object obj, System.Int32 hashPrefix, System.Collections.Generic.Dictionary`2[TKey,TValue] valuePositionMap, System.Int32[] valuePositions, System.Byte[] values, UnityEngine.Object[] unityObjects, Opsive.Shared.Utility.MemberVisibility visibility, System.Boolean bitwiseHash, System.Func`3[T1,T2,TResult] onValidateCallback) (at <1b344c5d94b043229e545d418d0ddcb6>:0)
Opsive.Shared.Utility.Serializer.BytesToValue (System.Type type, System.String name, System.Collections.Generic.Dictionary`2[TKey,TValue] valuePositionMap, System.Int32 hashPrefix, System.Byte[] values, System.Int32[] valuePositions, UnityEngine.Object[] unityObjects, System.Boolean useFields, Opsive.Shared.Utility.MemberVisibility visibility, System.Boolean bitwiseHash, System.Func`3[T1,T2,TResult] onValidateCallback) (at <1b344c5d94b043229e545d418d0ddcb6>:0)
Opsive.Shared.Utility.Serializer.BytesToValue (System.Type type, System.String name, System.Collections.Generic.Dictionary`2[TKey,TValue] valuePositionMap, System.Int32 hashPrefix, System.Byte[] values, System.Int32[] valuePositions, UnityEngine.Object[] unityObjects, System.Boolean useFields, Opsive.Shared.Utility.MemberVisibility visibility, System.Boolean bitwiseHash, System.Func`3[T1,T2,TResult] onValidateCallback) (at <1b344c5d94b043229e545d418d0ddcb6>:0)
Opsive.Shared.Utility.Serialization.DeserializeFields (System.Object obj, System.Int32 hashPrefix, System.Collections.Generic.Dictionary`2[TKey,TValue] valuePositionMap, System.Int32[] valuePositions, System.Byte[] values, UnityEngine.Object[] unityObjects, Opsive.Shared.Utility.MemberVisibility visibility, System.Boolean bitwiseHash, System.Func`3[T1,T2,TResult] onValidateCallback) (at <1b344c5d94b043229e545d418d0ddcb6>:0)
Opsive.Shared.Utility.Serialization.DeserializeFields (Opsive.Shared.Utility.MemberVisibility visibility, System.Func`3[T1,T2,TResult] onValidateCallback) (at <1b344c5d94b043229e545d418d0ddcb6>:0)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.DeserializeAbilities (System.Boolean forceDeserialization) (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:405)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.Awake () (at Assets/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:287)
It looks like something got corrupted. To verify that the exception still exists can you create a new project with the latest version of the controller and see if you can reproduce it?
I'll see
 
It looks like something got corrupted. To verify that the exception still exists can you create a new project with the latest version of the controller and see if you can reproduce it?
I have reproduced it with Unity 2021.2.5f1 and UCC 2.4.4. Algoritm is same
 
Thanks, trying again I was able to reproduce it. I'll have it fixed in the next update.
 
Thanks, trying again I was able to reproduce it. I'll have it fixed in the next update.
Thanks, I have the same error in my project, but this happens without entering to play mode. I hope the update will fix my problem too
 
After debugging this it looks like a bug in Unity. Unity's prefab system works by flagging the fields with a dirty parameter. The ability states are saved in a long byte array and elements within this array are being flagged as dirty. As a result this corrupts the data because the binary values are merged. I will try to simplify this and submit the bug report to Unity.
 
Has there been any movement on this? I have added abilities to my UCC prefab but they are unavailable in existing scenes. The exception is not quite the same:

UCC 2.4.5
Unity 2021.2.7f1 Personal

Code:
ArgumentOutOfRangeException: MonoArgumentException:NULL
System.Array.CreateInstance (System.Type elementType, System.Int32[] lengths) (at <31c0f51ac5a24a22ba784db24f4ba023>:0)
System.Array.CreateInstance (System.Type elementType, System.Int32 length) (at <31c0f51ac5a24a22ba784db24f4ba023>:0)
Opsive.Shared.Utility.Serializer.BytesToValue (System.Type type, System.String name, System.Collections.Generic.Dictionary`2[TKey,TValue] valuePositionMap, System.Int32 hashPrefix, System.Byte[] values, System.Int32[] valuePositions, UnityEngine.Object[] unityObjects, System.Boolean useFields, Opsive.Shared.Utility.MemberVisibility visibility, System.Boolean bitwiseHash, System.Func`3[T1,T2,TResult] onValidateCallback) (at <c0cdd1983c7e4e9089170644d1b380ec>:0)
Opsive.Shared.Utility.Serialization.DeserializeFields (System.Object obj, System.Int32 hashPrefix, System.Collections.Generic.Dictionary`2[TKey,TValue] valuePositionMap, System.Int32[] valuePositions, System.Byte[] values, UnityEngine.Object[] unityObjects, Opsive.Shared.Utility.MemberVisibility visibility, System.Boolean bitwiseHash, System.Func`3[T1,T2,TResult] onValidateCallback) (at <c0cdd1983c7e4e9089170644d1b380ec>:0)
Opsive.Shared.Utility.Serialization.DeserializeFields (Opsive.Shared.Utility.MemberVisibility visibility, System.Func`3[T1,T2,TResult] onValidateCallback) (at <c0cdd1983c7e4e9089170644d1b380ec>:0)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.DeserializeAbilities (System.Boolean forceDeserialization) (at Assets/Packages/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:412)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.DeserializeAbilities () (at Assets/Packages/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:393)
Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.OnDrawGizmos () (at Assets/Packages/Opsive/UltimateCharacterController/Scripts/Character/UltimateCharacterLocomotion.cs:2403)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
 
Unity's prefab system is corrupting the data and I'm not able to prevent it from doing that. With that said, the next major release uses [SerializeField] instead of the built-in serialization for cases like this so it should help this situation.
 
Thanks Justin

Is there a planned release date for the major release? Will there be an upgrade path to the new serialization method?
 
Top