ArgumentOutOfRange Exception Non-negative number required

JordanSebastian

New member
Hey,

This is a weird one. It seems to be coming from Behavior tree's serializer. I keep getting the exception "ArgumentOutOfRange: Non-negative number required"

See:

Code:
ArgumentOutOfRangeException: Non-negative number required.
Parameter name: count
System.Text.UTF8Encoding.GetString (System.Byte[] bytes, System.Int32 index, System.Int32 count) (at <437ba245d8404784b9fbab9b439ac908>:0)
BinaryDeserialization.BytesToString (System.Byte[] bytes, System.Int32 dataPosition, System.Int32 dataSize) (at <ddb5579d0d23478c9f73ec2f99600079>:0)
BinaryDeserialization.LoadField (BehaviorDesigner.Runtime.FieldSerializationData fieldSerializationData, System.Collections.Generic.Dictionary`2[TKey,TValue] fieldIndexMap, System.Type fieldType, System.String fieldName, System.Int32 hashPrefix, BehaviorDesigner.Runtime.IVariableSource variableSource, System.Object obj, System.Reflection.FieldInfo fieldInfo) (at <ddb5579d0d23478c9f73ec2f99600079>:0)
BinaryDeserialization.LoadNodeData (BehaviorDesigner.Runtime.FieldSerializationData fieldSerializationData, System.Collections.Generic.Dictionary`2[TKey,TValue] fieldIndexMap, BehaviorDesigner.Runtime.Tasks.Task task) (at <ddb5579d0d23478c9f73ec2f99600079>:0)
BinaryDeserialization.LoadTask (BehaviorDesigner.Runtime.TaskSerializationData taskSerializationData, BehaviorDesigner.Runtime.FieldSerializationData fieldSerializationData, System.Collections.Generic.List`1[BehaviorDesigner.Runtime.Tasks.Task]& taskList, BehaviorDesigner.Runtime.BehaviorSource& behaviorSource) (at <ddb5579d0d23478c9f73ec2f99600079>:0)
BinaryDeserialization.Load (BehaviorDesigner.Runtime.TaskSerializationData taskData, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at <ddb5579d0d23478c9f73ec2f99600079>:0)
BehaviorDesigner.Runtime.BehaviorSource.CheckForSerialization (System.Boolean force, BehaviorDesigner.Runtime.BehaviorSource behaviorSource) (at <ddb5579d0d23478c9f73ec2f99600079>:0)
BehaviorDesigner.Runtime.Behavior.CheckForSerialization () (at <ddb5579d0d23478c9f73ec2f99600079>:0)
BehaviorDesigner.Runtime.BehaviorManager.LoadBehavior (BehaviorDesigner.Runtime.Behavior behavior, UnityEngine.GameObject behaviorGameObject, System.String gameObjectName, UnityEngine.Transform behaviorTransform) (at <ddb5579d0d23478c9f73ec2f99600079>:0)
BehaviorDesigner.Runtime.BehaviorManager.EnableBehavior (BehaviorDesigner.Runtime.Behavior behavior) (at <ddb5579d0d23478c9f73ec2f99600079>:0)
BehaviorDesigner.Runtime.Behavior.EnableBehavior () (at <ddb5579d0d23478c9f73ec2f99600079>:0)
BehaviorDesigner.Runtime.Behavior.Start () (at <ddb5579d0d23478c9f73ec2f99600079>:0)

I've tried recreating various nodes. At one point in time this went away if I removed a particular node, now this sticks around no matter what. Happens when the project is first loaded and on play in the editor. Any ideas how to fix this?
 
Can you send a repro project to support@opsive.com? It would be even better if you can list the steps to get to that state.

If you switch to JSON serialization does it work?
 
Switching to JSON did the trick. Is there any downside to being in JSON serialization mode vs binary? Performance? I imagine parsing the binary version is faster.

Additionally, when I swtich to JSON and then back to binary, the issue re-emerges. It seems JSON serialization is the only method that works right now.

Not really an option to send it, the repo is several gigs in size. I can send individual things if you think it would help. Maybe I can carve out a lot of the assets that are making up the bulk of the size...let me know if there's something i can do to help diagnose this overall problem. The serialized binary must live on the hard drive somewhere, maybe I can send you that? Would it help if I exported the tree?

Edit: I am not sure what I did to get into this state, I know that's not terribly helpful. I had created a new Action and attached it to a tree. The action wasn't anything special, just an action that found the closest object based on a layer map.
 
Glad JSON worked. JSON is slightly slower compared to binary when deserialization.

Not really an option to send it, the repo is several gigs in size. I can send individual things if you think it would help. Maybe I can carve out a lot of the assets that are making up the bulk of the size...let me know if there's something i can do to help diagnose this overall problem. The serialized binary must live on the hard drive somewhere, maybe I can send you that? Would it help if I exported the tree?

Stripping it down into a smaller tree definitely helps, though I can download any sized projects if you upload it to something like Google Drive. If you aren't using any custom tasks then you can send just the scene/external tree, but most people use custom tasks so in that case I'll need it to compile.

Edit: I am not sure what I did to get into this state, I know that's not terribly helpful. I had created a new Action and attached it to a tree. The action wasn't anything special, just an action that found the closest object based on a layer map.

So even if you remove that task then it continues with the error?
 
Top