Search Unity

Timeline not playing at start of scene (2018.3.14f1)

Discussion in 'Timeline' started by samjm, Apr 7, 2020.

  1. samjm

    samjm

    Joined:
    Apr 20, 2018
    Posts:
    8
    Hi everyone!

    I'm wondering if anyone have experienced something similar to this case.
    We have a main scene on which we have a set of timelines that are played depending from where it was called, i.e. at first, timeline1 is played, after going to a 2nd scene and come back to main scene timeline2 is played and so on. Everything was working correctly, however after adding more functionality on the main scene (textures, video, mainly) the scene stops and no timeline is played. The game is not frozen as the navigation panel we have works correctly (it only has buttons to exit, go to website and restart scene), however the timeline does not play.

    Our first clue was cpu/memory issues, we check the profiler and started to reduce textures, shaders and disabling components added afterwards, reducing significantly but with the same problem.

    We exported the game to a newer version but the issue persists.
    The problem occurs in editor and exported game for windows and macos tested in different machines.

    Does anyone have experienced something similar or could give us an insight on what the problem could be?

    Thanks a lot in advance for your invaluable help!
     
  2. jin-archipin

    jin-archipin

    Joined:
    Dec 17, 2019
    Posts:
    35
    Did you check the play on awake option in playable director?
     
  3. samjm

    samjm

    Joined:
    Apr 20, 2018
    Posts:
    8
    Thanks for your response jin-archipin, yes, I checked with a single timeline and play on awake enabled, however, as we are deciding which timeline to play depending on the scene, we play them manually, as:

    Code (CSharp):
    1.  
    2. void Start()
    3.     {
    4.         PlayableDirector current = timelines[currentTimeline];
    5.         current.Play();
    6.     }
    so, we need to have the play on awake option disabled to avoid playing them all
     
  4. jin-archipin

    jin-archipin

    Joined:
    Dec 17, 2019
    Posts:
    35
    I have no idea then.. If I were you, I will make a debug playable track and put the track on every timelines to check if the timeline is working fine.
     
  5. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    A couple shots in the dark here... but are the timelines all in the same scene? Is it possible they are losing their bindings? If you are in playmode, can you load up the one that should be playing in the timeline editor?
     
  6. samjm

    samjm

    Joined:
    Apr 20, 2018
    Posts:
    8
    Thanks for your answers! I forgot an important thing to mention. In the editor, if we play the main scene directly, the timeline works perfectly. The problem only occurs when we call the main scene from another (i.e an introductory scene). This flow worked correctly in the past, were we specify through a script which timeline to play before loading the main scene (we have verified that the timeline is being called correclty, it just don't play).
    Just to mention, the profiler looks like this at the beginning of the main scene with a spike when loading everything. It have reduced significantly the amount of things loaded.
     

    Attached Files:

    Last edited: Apr 8, 2020
  7. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Are the playable directors in the same scene that is being loaded?
     
  8. samjm

    samjm

    Joined:
    Apr 20, 2018
    Posts:
    8
    Yes, all the playable directors are in the same scene, but only one is played at a time. We have found that if we call the main scene at first (not calling from the introductory scene) it has load correctly; just to remark, the introductory scene has one button which loads the main scene after playing a timeline-cinemachine animation, could it be problem of memory or garbage collection after moving scenes?
     
  9. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    That is strange. I would expect the timelines to be loaded with the scene if they are not already loaded, the same as any other asset.

    As to what the problem could be, I can't think of anything obvious. I guess it is possible it is a problem with resource loading/garbage collection, or with the order of loading/unloading. One suggestion I'd give is try to find the smallest repro case. e.g. Load Scene A, Load Scene B, Load Scene A (where A has the timelines). Hopefully that will quickly expose the issue.
     
  10. cosic196

    cosic196

    Joined:
    Mar 15, 2018
    Posts:
    6
    I'm having a similar issue. I have a timeline set up in a scene. When I play that scene directly, the timeline starts (it starts via a script). If I play another scene, and load the scene with the timeline using SceneManager.LoadScene the timeline never plays. I tried all sorts of things. Setting it to play on awake and then enabling the playable director; tried using PlayableDirector.Evaluate(); tried using PlayableDirector.Pause() and then PlayableDirector.Play()... Nothing works. I can see the timeline in the editor is played when I open it while the scene is still running (the play button in the timeline window is highlighted) but it's stuck on frame 0. If I press play (which actually stops it) and then press play again, it starts playing.
    I'm using 2018.2.6f1.
    Please help, this is driving me crazy.
     
  11. cosic196

    cosic196

    Joined:
    Mar 15, 2018
    Posts:
    6
    I just tried setting the update method to "GameTime" instead of "DSPClock" and it plays. I can use it as a workaround for now, but I would prefer to use "DSPClock" if possible.
     
  12. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Ah - that makes some sense!, We made a fix for 2019.3 related to the DSP Clock getting out of sync when large delta times occur, so I'm suspecting it is related, since the use cases usually involved level loads. I also wonder if @samjm has the same issue.

    A potential workaround is to call the internal static method PlayableDirector.ResetFrameTiming() through reflection when the level loads. It's gross, but that will get rid of the error between the game and DSP clock. Just don't call it every frame.
     
  13. samjm

    samjm

    Joined:
    Apr 20, 2018
    Posts:
    8
    Ohhh, thanks for the input!! and sorry for the late response, we haven't realized anything about DSP Clock and GameTime update methods, I guess we use the default one. We are not sure about that.

    On the other hand, we have tried the suggestion of Loading Scene A, Load Scene B, Load Scene A (where A has the timelines) and have found that actually, when switching from Scene B to Scene A, the freeze occurs, so we start improving the Scene B objects in order to generate less resource consumption, however we still have the issue.

    An approach we have been researching is the scene/assets preload to not load everything in the main scene at once, but we still can't figure out how to do it (we are kind of new in this matter). Do you think this could be a valid option to solve the issue? and what path could we follow if most of the objects we load are in the timelines?

    Thanks again for your appreciated help!
    Regards!
     
  14. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    Definitely a valid option, but it all depends on how your scenes are laid out. Loading multiple scenes (asynchronously) is one way to split the load, but separating the timeline out from the scene can be tricky due to the bindings - but of course possible.

    To reduce the amount loaded from having multiple timelines (but only needing one), you can also make a prefab out part of your scene, then have variants that contain the different timelines, and only load the one you need. Or make different scenes per timeline. Unfortunately, there's no one right way, there is what works best for your use case.