- Edited
Problem statement
Hi there,
We have been hitting a very hard to repro issue since we upgraded to Spine 4.1 from 3.8.
It seems related to different things:
- The animation has to be an UI object
- Starting an animation on the object on the same frame it is enabled / disabled?
- And doing of all this inside an async / LateUpdate context?
Sorry I cannot be more precise on how to get the exception to trigger again.
I did manage to have a breakpoint into the spine code once, and here's how much info as I could get out of it:
In the Spine.Unity.MeshGenerator.BuildMeshWithArrays
method
totalVertexCount
is set to be equal toinstruction.rawVertexCount
- We then enter the slot loop line 827
for (int slotIndex = startSlot; slotIndex < endSlot; slotIndex++) {
- At some point, it seems like more bones are active than initially expected, because we hit a
vbi[]
array overflow (sometimes around lines 841-844, sometimes line 922) as vertexIndex gets incremented along the way.
Have been giving this a try for a few weeks to repro in a sandbox, but never managed to trigger this in a simple project. Looks like some very edge case - is this something that you have encountered in the past? Any idea what could be happening?
Our initial idea is that instruction.rawVertexCount
has a value of how many vertices the previous animation had (on the previous frame), while the slot loop goes over the slots enabled on the next animation, and it might have more vertices than initially computed.
Any help is appreciated
Runtime information
Spine 4.1
Unity 2021.3.20f1
IndexOutOfRangeException: Index was outside the bounds of the array.
Spine.Unity.MeshGenerator.BuildMeshWithArrays (Spine.Unity.SkeletonRendererInstruction instruction, System.Boolean updateTriangles) (at Assets/Spine/Runtime/spine-unity/Mesh Generation/MeshGenerator.cs:922)
Spine.Unity.SkeletonGraphic.UpdateMeshSingleCanvasRenderer (Spine.Unity.SkeletonRendererInstruction currentInstructions) (at Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs:731)
Spine.Unity.SkeletonGraphic.UpdateMeshToInstructions () (at Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs:688)
Spine.Unity.SkeletonGraphic.Rebuild (UnityEngine.UI.CanvasUpdate update) (at Assets/Spine/Runtime/spine-unity/Components/SkeletonGraphic.cs:286)
UnityEngine.UI.CanvasUpdateRegistry.PerformUpdate () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/CanvasUpdateRegistry.cs:215)
UnityEngine.Canvas:SendWillRenderCanvases() (at /Users/bokken/build/output/unity/unity/Modules/UI/ScriptBindings/UICanvas.bindings.cs:96)