ContiguousArray reallocates itself after every append

Here's something about reserveCapacity that might be easy to miss:

var a = ContiguousArray<Float>.init()
a.reserveCapacity(1_000_000) // <-- You want *at least* 1_000_000
print(a.capacity) // <-- It will print eg 1_000_440, ie you got some more.

That is, you cannot trust that it will reserve exactly the capacity that you ask for.
If I'm not mistaken, your code assumes that you can, and that's whats causing your issue.

The correct way to check the actual capacity is by using the array's .capacity property, not storing and using your "wished-for minimum capacity" frameCount.

This would be clearer if you had to write eg myArray.reserveCapacity(atLeast: frameCount).

Related:
https://forums.swift.org/t/array-capacity-optimization/13829