Search Unity

Can Timeline preload?

Discussion in 'Timeline' started by SardineFish, Jul 14, 2019.

  1. SardineFish

    SardineFish

    Joined:
    Oct 30, 2017
    Posts:
    8
    I found it takes a long time to load a timeline before first play. Even freeze the game for seconds on some android devices.
    Is there any way to preload a timeline playable asset?
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Yes, you can use playableDirector.RebuildGraph(). It will do all the work of preparing the timeline for play (i.e. the CreatePlayable call in the profiler) without actually starting it.
     
  3. SardineFish

    SardineFish

    Joined:
    Oct 30, 2017
    Posts:
    8
    I found this. But it still takes a long time to call a Evaluate() before first play (about 80ms on my Android).
    So I tried to call the Evaluate() to preload it, but it will present the first frame in timeline. I finally place a empty frame a the bigining of the timeline to prevent this. It is not elegant but works.
     
  4. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    That's a bit unexpected. Could you share the profile of your Evaluate() call?
     
  5. SardineFish

    SardineFish

    Joined:
    Oct 30, 2017
    Posts:
    8
    Here is the profile on my Android with only RebuildPlayable() for preloading. This happened when the timeline first play. It only contains a few infomations.

    And here is a profile in Editor on my PC, shows more call stacks.
     
  6. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    That's interesting. If this is the first timeline that is being played, then it could be a Just-In-Time compile cost that is occurring. Looking at the profiles you sent, that seems to be the case.

    We've seen this before and it's compiling all the required timeline & playable C# code. The workaround is to play (or just evaluate()) a very simple timeline during startup. IL2CPP is better since the code is compiled, but, somewhat surprisingly, still has a significant hit.