Search Unity

  1. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice
  2. Dismiss Notice

Help Wanted Freeze in SendOnPlayableDirectorPlay()

Discussion in 'Timeline' started by Adrien_Danglard, Aug 18, 2020.

  1. Adrien_Danglard

    Adrien_Danglard

    Joined:
    Nov 4, 2019
    Posts:
    18
    Hello. Sometimes we get a seconds - sometimes almost or over a minute - long freeze when calling
    Code (CSharp):
    1. PlayableDirector.Play();
    - according to the profiler, the culprit is a method called
    Code (CSharp):
    1. PlayableDirector.SendOnPlayableDirectorPlay()
    . This call seems to be spamming calls to GC.Alloc (e.g. we have 24582 calls to GC.Alloc, allocating a total of 0.8 MB; SendOnPlayableDirectorPlay() taking up 24628 ms.)

    Any ideas as to what we might be doing wrong here / how we should be doing things instead?
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    A couple thoughts

    1) The Play() is actually the culprit - in particular the instantiation of the instance of the timeline. Timeline does allocation - creating script playables along with some internal housekeeping for the timeline playable are the main culprits of allocations although ControlTracks that use prefabs and other custom tracks can always increase those allocations substantially. One way to test this is to use PlayableDirector.RebuildGraph() to create the instance prior to playing it. If the cost moves to RebuildGraph, then creating the instance is where the allocations are occurring.

    2) Something is listening to PlayableDirector.played events and is causing the allocation.
     
unityunity