PlayableAsset.Internal_CreatePlayable taking a long time

I’m seeing a frame spike when I first play a timeline. The timeline is active on level start with “Play on Awake” unchecked. I have a trigger in code play the timeline later on in the scene. On that frame I start the timeline, I get a frame spike. In the profiler I see over 18ms spent on a function "PlayableAsset.Internal_CreatePlayable()

What is the cause of this? Is there something inefficient about my timeline? How can I find further information?

Hi, that is the PlayableDirector creating an instance of the Timeline (a.k.a. a playableGraph) ready for playback. It can vary based on the size of the timeline, as well as how many custom tracks and clips you are using. 18ms seems quite high.

In 2017.3, there is a method added to the PlayableDirector called RebuildGraph that can be used to ‘prewarm’ the timeline. It can be called at a more appropriate time , for example during loading, so when ‘Play’ is called to play the timeline, there is no spike.

After test deleting everything in my timeline, I’ve come up with some more information that has caused this issue. It appears it takes this time as long as I have at least one ControlTrack with ControlPlayableAsset in the timeline. Having more than one does not increase this time. The ControlPlayableAsset has “Source Game Object” set to a particle that came from Unity’s EffectExamples pack from the asset store. Curiously, if I remove that reference just have it set to none, the PlayableAsset.Internal_CreatePlayable() time drops from 18ms to about 7ms. I also tried putting in a different particle “SparksEffect” and the time jumped back up to 18ms.

It appears for the time being using ControlPlayableAsset is not advised.