Big problem: Playables API generates tons of garbage (Unity 5.5.0f3)

I was playing around with the Playables API today, and noticed that the AnimationMixerPlayable.SetInputWeight() method generates garbage every time it is called (which is pretty much on every frame, because I use it for all animation blending).

This basically means the Playables API shouldn’t be used by anyone, because having anything that generates garbage every frame should be considered unacceptable. Is there any way around this? Or are there plans to fix this in 5.6? I’m fully aware that this feature is still experimental, but I just want to make sure this gets fixed sooner than later. I can’t keep using this until I know for sure that this problem will be gone very soon

I tested this in a build too, and the problem is still there.

Would it not be possible to replace the inputs List by an inputs array with a specific size? You’d only have to resize it when inputs are set or added. Actually I’m not even sure why there’s a List.Add() operation when setting input weights in the first place (?). Can the “CheckInputBounds()” be avoided completely?

I’ve submitted a bug report with an example project ( Unity Issue Tracker - [GC Alloc]Playables API "SetInputWeights()" method generates tons of garbage collector allocation )

Thanks

Bumping this since it hasn’t gotten a response. This is a huge issue for me as well, making Playables more or less unusable for what I wanted to do with it. Any plans to fix this Unity?

I got a reply from someone at Unity on December 23. They have acknowledged the problem and said the issue has been forwarded to devs for further review.

With Timeline (aka Director) being days away from an experimental release (supposedly), I think we might hear about it again soon enough
https://forum.unity3d.com/threads/timeline-beta-cinemachine.449596/

1 Like

Update:
I managed to test this in 5.6b4 with the new Playables API, after this doc was posted: AnimationClipPlayable - Unity Engine - Unity Discussions

and… the GC alloc for SetInputWeight is gone! Seems like the problem is fixed!

Nice that it will be fixed in 5.6, but I wonder if this fix will come to 5.5. It may be a while before 5.6 is released

I don’t know for sure, but I really don’t think this change will make it in 5.5. The Playables API it totally different in 5.6. Seems like they did a big refactor

On a side note, we’ve upgraded a pretty decently-large project from 5.5 to 5.6beta and we haven’t had any problems so far

The Playables API is indeed undergoing a major refactor in 5.6, so I would strongly advise against building anything that should last with any version before 5.6.

As it is an Experimental API, there will be no Auto-upgrader, so any changes to fit the new API would have to be done manually.

We expect the API to stabilize a lot from 5.6 on, because we are basing the Cinematic and Storytelling tools on this.

As for efficiency; we are using the same APIs as you are to build these tools, so you can expect them to be cleaned up before they move out of Experimental.