Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

PlayableAsset returned a null Playable on Instantiate

Discussion in 'Timeline' started by tday_magicfuel, May 7, 2021.

  1. tday_magicfuel

    tday_magicfuel

    Joined:
    Apr 10, 2018
    Posts:
    21
    Unfortunately this problem is hard to describe. We've seen this error in our Unity Cloud Diagnostics mostly in released builds. In internal testing we've not been able to replicate it. Despite additional logging surrounding the error we haven't come up with many leads.

    We have a variety of prefabs with timelines that play on awake. These prefabs are loaded via addressables (the prefabs and timeline assets are all in the same addressable group).

    It seems like everything functions correctly yet the playable graph is invalid.

    The timelines are using several custom playable scripts as well. These errors only pop up after the prefab and underlying playable asset should already be loaded. The director component does have a play on awake however the update method is done manually in our own scripts and updates only begin after the callback for the addressable load of the prefab.

    I assume that addressables should load the required playable linked in the inspector on these prefabs in the same call that loads the prefab itself. However if this wasn't happening perhaps that could cause this issue.

    Other topics with this error suggests this might be to do with addressables, but that was specifically for iOS devices.

    Happy to provide more details. This has been a bit of a stumper and we haven't been able to replicate in editor.

    Using Unity 2019.4.15f1 and Timeline package version 1.2.18.
     
    Last edited: May 7, 2021
  2. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    This doesn't really ring a bell.

    It's the whole graph invalid, or just a specific asset?
     
  3. tday_magicfuel

    tday_magicfuel

    Joined:
    Apr 10, 2018
    Posts:
    21
    @DavidGeoffroy I think it must be a singular graph inside the timeline since we still see some of the playable take effect in the logs. However this hasn't always happened to the same timeline. Suggests it's an error in our general setup or perhaps a bug with timeline/addressable rather than the specific prefab I think.

    We have a decent way to add more logging when this case happens--with a playable graph is valid check happening when the timeline updates. Anything you suggest we could add to help diagnose?
     
  4. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    Are you seeing a specific exception in the logs?
     
  5. tday_magicfuel

    tday_magicfuel

    Joined:
    Apr 10, 2018
    Posts:
    21
    We have a marker in the logs for when the timeline starts and then essentially every time the timeline updates after that it throws out this "PlayableAsset returned a null Playable on Instantiate" message.


    Here's a screenshot of our logging. The "when updating timeline" messages is our own logging after the playable graph.isvalid check fails.

    This eventually leads to other exceptions in our own custom playable classes. Which is strange--if that wasn't loaded correctly then surely it wouldn't be executing code in the relevant script to assert on?
     
  6. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    PlayableAsset returned a null Playable on Instantiate
    is returned by the engine, and it means that the whole Timeline has failed to return a valid Playable. This means the whole Timeline hasn't been created properly.

    Here is the code that creates a Timeline:

    Code (CSharp):
    1. public static ScriptPlayable<TimelinePlayable> Create(PlayableGraph graph, IEnumerable<TrackAsset> tracks, GameObject go, bool autoRebalance, bool createOutputs)
    2. {
    3.     if (tracks == null)
    4.         throw new ArgumentNullException("Tracks list is null", "tracks");
    5.     if (go == null)
    6.         throw new ArgumentNullException("GameObject parameter is null", "go");
    7.  
    8.     var playable = ScriptPlayable<TimelinePlayable>.Create(graph);
    9.     playable.SetTraversalMode(PlayableTraversalMode.Passthrough);
    10.     var sequence = playable.GetBehaviour();
    11.     sequence.Compile(graph, playable, tracks, go, autoRebalance, createOutputs);
    12.     return playable;
    13. }
    If you are not seeing either of these exceptions, I would expect the Playable to be valid.

    Other potential reasons are:
    • Timeline code has been stripped from the build (that's usually an issue in IL2CPP builds, fixable by either marking Timeline as exempt from stripping, or using one Timeline somewhere in one scene that is part of your main build.)
    • Somehow, the PlayableDirector is loaded, the TimelineAsset isn't, but it's not null. Not sure how that could happen, but I am not very well versed in how addressables work.
     
  7. tday_magicfuel

    tday_magicfuel

    Joined:
    Apr 10, 2018
    Posts:
    21
    Hopefully we can determine the first bullet by trying those options our next build; unfortunately with no solid repro it will be hard to confirm. I can add some logging that might help us understand if we're in the second situation as well. Thanks for the help.
     
  8. tday_magicfuel

    tday_magicfuel

    Joined:
    Apr 10, 2018
    Posts:
    21
    Well follow up, we added Timeline to Link.xml to rule out it being stripped from the build but the issue persisted.

    Not sure what steps to take next--it seems possible this a weird edge case/bug? But without any sort of repro steps still it's not going to be that useful of a bug report for Unity!
     
  9. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542

    Without a repro, we're a bit limited on how we can help you.

    That said, Timeline is entirely implemented in C#, and you can embed the package (from the package cache) in your project, and add as much diagnostic information as you need to figure out where this error is coming from.
     
  10. tday_magicfuel

    tday_magicfuel

    Joined:
    Apr 10, 2018
    Posts:
    21
    Seems like that's the path we'll have to travel through next then! Appreciate the help.
     
  11. tblank555

    tblank555

    Joined:
    Nov 3, 2016
    Posts:
    2
    @tday_magicfuel Did you ever figure this out? I seem to be experiencing the same issue.

    It seems to happen when playing through a section of our main timeline that has an embedded sub-timeline. This issue also only happens in builds and not in editor, so it's pretty tough to track down...
     
  12. tday_magicfuel

    tday_magicfuel

    Joined:
    Apr 10, 2018
    Posts:
    21
    @tblank555 We ultimately combed through every custom clip creation code and changed or protected against any that might return a null playable. This seems to have squashed it. Simply put "PlayableAsset returned a null Playable on Instantiate" is accurately describing what happened, however the challenge was finding out which clip for us. We fortunately finally got an internal repro and fixed it.
     
  13. kloot

    kloot

    Joined:
    Mar 14, 2018
    Posts:
    79