Error is on line 82 of Animation.cs.
It's not at all clear to me what "step" means for a binary search. Though in fact, where it's being called (from the Apply method on line 562), the step argument is a constant 1. Seems like we may as well call the other version of BinarySearch that doesn't have a step parameter, and looks like a more ordinary binary search.
But that wouldn't fix the bug, since when step==1 this code appears to be equivalent to the standard one. Made that change anyway, but sure enough, it still blows up. Here's the call stack:
Spine.Animation:BinarySearch(Single[], Single) (at Assets/spine-csharp/Animation.cs:99)
Spine.AttachmentTimeline:Apply(Skeleton, Single, Single, ExposedList`1, Single, Boolean, Boolean) (at Assets/spine-csharp/Animation.cs:564)
Spine.AnimationState:Apply(Skeleton) (at Assets/spine-csharp/AnimationState.cs:180)
Spine.Unity.SkeletonAnimation:Update(Single) (at Assets/spine-unity/SkeletonAnimation.cs:181)
Spine.Unity.SkeletonAnimation:Update() (at Assets/spine-unity/SkeletonAnimation.cs:171)
A bit of hacking around finds that our values array is of length 1, and when the problem occurs, current=2147483647. I agree with C# that this is out of range. 😉
It looks to me like BinarySearch, as written, simply doesn't work for arrays of less than 2 items (because we initialize high to length-2, and then typecast this to a uint to find current). That should be an early bail-out case right at the top.
Argh. The problem appears to be much deeper. When I patch up the BinarySearch methods to return 0 for arrays of length 1, I have to patch other bits of the code that seem to be clearly assuming we're going to have at least 2 entries.
Yet when I try to trap for AttachmentTimlines with a single frame higher in the chain... these occur all over the place. My debug output for such a case appears 36 times per frame in my particular game. Yet none of these cause an issue, until I try this one particular animation. I haven't yet been able to pin down what's special about that one, but that one seems to trip over all the code assuming at least 2 frames, while none of these other animations do.
OK, last followup (for now). This is a weird problem caused, somehow, by a bug elsewhere in our code. We were reading some data to determine how long this animation should last; that data came through as zero, so we set the animation timeScale to duration / 0. This division by zero error (i.e. infinite timeScale) is what triggers all the other problems with single-frame attachment timelines, etc.
It'd be great for the runtime to detect that error more quickly, instead of falling apart in mysterious ways later... but ultimately, yeah, this was my fault. Don't I feel sheepish! Hopefully this post will help somebody else who runs into a similar issue.