Hey guys, I keep getting CPU spikes which I’ve tracked in the profiler to Animation.RebuildInternalState. What can be done about this?
I was just checking this out over lunch - if I don’t disable the animation component and I do disable the skinned mesh renderer, then it looks like my spikes have gone away with two caveats: I’ve not tested this on the 3G S I was using yesterday; on the 4S I did see a massive ~300MS spike in RebuildInternalState() very early on in the level (i.e. within the first few seconds) but that seemed to be the only one, probably just as a whole bunch of animations hit the camera frustum for the first time.
So my suggested solution - the one we are now using - is to set the skinned mesh renderer enabled to false and not both disabling the animation or moving either object off screen. Of course a solution that moved the object offscreen and disabled the Renderer may prove even more efficient…
I don’t have a solution tested yet for the huge spike I received, but perhaps I can align the animations in front the camera for a second with all lights off/texture occluding them and then move them back to their proper positions. Feels like a bit of a hack though…
I too was getting this problem. After a LOT of experimentation, I have understood it to have something to do with “attaching unnecessary animations”. What I mean by that is that I used to attach all animations used by different AI types in the same prefab and changed their material at runtime and defining their type by code.
Just for the sake of trying I segregated the different AI types into their own prefabs and minimized loading of unnecessary animations. I was relieved to see that this helped; substantially.
I don’t know if this is the right solution, but I am no longer getting that CPU spike on Animation.RebuildInternalState.
I am having the same problem with Animation.RebuildInternalState too. I have it take up 13% of the time and 5ms of time. I don’t know what keeps calling it? Any ideas.