Search Unity

Timeline Signals Emitting in Editor Only

Discussion in 'Timeline' started by PeachyPixels, Nov 12, 2021.

  1. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
    Hello!

    I added a simple timeline to a scene a few weeks back that emits two signals and plays one audio source. It's been running in the editor without issue.

    After building the game for Win UWP IL2CPP, I noticed the signals were not emitting, even though the timeline is playing (as the audio is played on-cue). I tried an Android IL2CPP build and the same issue.

    I've tried everything to get these to fire at runtime (even going so far as to recreate the entire timeline) but nothing seems to work.

    From searching it seemed there was\is an issue where timelines in asset bundles didn't emit signals, but asset bundles are not in-use here. The timeline & signal receiver are all in the same scene, nothing fancy.

    I'm using timelines elsewhere in the game and they appear to work (at runtime) as expected. It's just this one timeline.

    I've attached pictures of the setup.

    Has anyone seen this behaviour before? Any help would be much appreciated.

    PS: This is using Unity 2020.3.22f1

    PPS: The timeline is invoked manually at runtime using Play();
     

    Attached Files:

  2. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
    Anyone from Unity able to comment please?

    I've triple checked the timeline as well as the emitters & receivers and just can't see any reason why the signals aren't being sent\received at runtime.

    I moved the receivers to another object (along with the relevant reaction code) and they still won't fire, so I suspect it's the timeline. But the timeline is playing because the audio is playing.

    This one really has me stumped.
     
  3. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
  4. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
    Sorry but it's been over 5 days now and not even a hint of help from Unity.

    I have poured over the setup for days and just can't see anything wrong with the timeline or signals, so suspect this is a Unity bug.

    I'm on the verge of dropping timelines and invoking delayed methods in code as a workaround, which is crazy!
     
  5. Midiphony-panda

    Midiphony-panda

    Joined:
    Feb 10, 2020
    Posts:
    243
    You have the issue on one specific Timeline ?

    Have you tried to recreate it from scratch ? To reproduce the issue in an empty project ?
     
  6. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
    Thanks for the reply.

    Yes, it's one specific timeline. Others in the game work in the same way and they work fine. I've re-built this specific timeline from the ground up and the same issue persists, which makes me think it's a Unity bug being triggered by a very specific set of circumstances.

    I've not yet reproduced the issue in a standalone project. I was hoping someone from Unity may be able to point me in the right direction first, with regards to a resolution. But it's next on the list.

    It's not possible (as far as I can tell) to determine if the issue is the signal not being emitted or received. Which makes it even more frustrating.
     
  7. Midiphony-panda

    Midiphony-panda

    Joined:
    Feb 10, 2020
    Posts:
    243
    You can maybe try to break on the OnNotify method of the SignalReceiver script

    com.unity.timeline@1.6.2\Runtime\Events\Signals\SignalReceiver.cs
     
  8. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
    The issue is only in release (IL2CPP) builds. I've reproduced it the Windows & Android builds.

    So (as far as I am aware) it's not possible to debug those with VS. And debug logging is only getting me so far.

    I'm going to devote a little more time to it tomorrow and try again.

    Fwiw, today I reverted to Timeline 1.4.8 and also tried 1.7.0 and the issue is still there.

    Thanks again for replying, I'll post back when there is more news.
     
  9. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    This kind of thing can happen when some classes are not referred to anywhere in the scenes that are part of your base executable.

    IL2CPP code stripping will aggressively strip classes and types that are not there, and doesn't take into account asset bundles.

    Make sure that somewhere in your base scenes you have a signal reference. It doesn't need to do anything.

    I'm a bit fuzzy on the exact mechanics, but you can maybe ask in the build pipeline forums for more info.
     
    PeachyPixels likes this.
  10. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
    Thanks for the reply @DavidGeoffroy

    The game doesn't use asset bundles, so not sure it's related to that.

    But to rule out code stripping I added two fields to the GameManager and referenced the relevant signals. Unfortunately it made no difference in the build.

    I then referenced the relevant reaction methods directly in code (in an OnTriggerEnter method that shouldn't be called) and that didn't work either.

    I then deleted the reactions & signals completely and re-built them from the ground up and whilst they worked in the player (as before) they still didn't work in the build.

    Finally I added the signals to the preload assets list (really clutching at straws here) and that didn't work either.

    I checked the stripping levels and they're set to Low with no option to disable them using IL2CPP.

    Long story short, I'm guessing the above pretty much rules out stripping?

    I'm going to try and parse the signals (and assets) at runtime and log their values to see if they're present and correct. Is there anything you can recommend on that front please?
     
  11. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    That's a pretty thorough investigation.
    Unfortunately code stripping is the only reason I know where something would work on one platform but not the other.
    Is your Windows/Mac player using IL2CPP too?

    I would encourage you to file a bug report at this point. We get the benefit of being able to step through the code to figure out what's wrong, so it should be easier to figure out what is wrong.
     
  12. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
    Results for the signals not being emitted\received are...

    Unity Player = Yes
    Windows UWP IL2CPP = No
    Android IL2CPP = No

    Haven't tried iOS yet.

    I did just try putting the signals & audio onto the same track bound to the GameManager (moving the AudioSource in the process) and that didn't work either.

    I'll pick this up again Monday as I've a few more things to try before giving up. But I'm not really in a position to send the entire project, so hopefully it's reproducible in a small standalone project.

    Thanks again for replying.
     
  13. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    I've got an avenue for you to try.
    • Get the Timeline Package from the package cache (you can do this by using "Show in Explorer"/"Reveal in Finder" on the folder in the project view)
    • Embed it in your project by copying the folder in your Packages folder
    • Add the [Preserve] attribute to SignalReceiver (Runtime/Events/Signals/SignalReceiver.cs)
    If you have your own INotificationReceiver, you can do the same with it. Assuming the SignalReceiver is getting stripped, this should fix it (and we can apply this in a future patch).

    If all else fails, a quick googling seems to indicate that you can inspect the generated assemblies (stripped and non-stripped) with ILSpy to try and figure out what got stripped. Hopefully, it would be something evident like INotificationReceiver, SignalReceiver, or Signal.
     
    PeachyPixels likes this.
  14. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
    Hi @DavidGeoffroy

    So with a weekend off and a fresh mind, I finally worked out what it was and resolved it in minutes this morning. Turns out the issue was developer stupidity! (on my part)

    I'm running an Obfuscator and completely forgot that it doesn't handle renaming of UnityAction event calls and of course timeline reactions use those. So just added a [SkipRename] tag onto the relevant reaction methods et voila! It works again.

    What was throwing me was that all other timelines were working, but with hindsight they all use MonoBehaviour methods to react (i.e. SetActive) which aren't obfuscated.

    At the very least, hopefully this thread will help others in the future. I just wish the Unity forum would add a face-palm emoji, it would be perfect for situations like these :D

    On a side note... would it be possible to submit a feature request that UnityAction events at-least log a warning (or error) if the underlying call is invalid? I'm sure there is a performance overhead with this, but why not just enable it in development builds? I'm sure that would actually help out with a myriad of other similar situations as well. At present they're just silent failures which make them harder to track down.

    Just an idea anyway.

    Thanks again for replying and apologies for wasting any of your time.
     
    Last edited: Nov 23, 2021
    DavidGeoffroy likes this.
  15. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
    Great tip, thanks!

    I was trying to add logging to the SignalReceiver code, but Unity's integrity checking kept restoring the original code on compilation.

    So knowing you can copy the package locally and modify it is of great help, thanks!
     
    Last edited: Nov 22, 2021
  16. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    I'm happy you figured it out.
    I also got to learn a bit about IL2Cpp stripping, so win-win I guess?

    For anyone coming here looking for help diagnosing IL2Cpp stripping issues, there is a UnityLinker_Diagnostics folder which should contain logs related to stripped types and methods.

    Looks like this is not publicly available, and/or hard to configure.

    If you get stripping issues that you cannot diagnose, please file a bug report, which would put some pressure to help debugging of stripping code.
     
    Last edited: Dec 6, 2021
    PeachyPixels and Midiphony-panda like this.
  17. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    713
    I concur :)

    That's another great tip, thanks! I'll check it out as very interested to see what's stripped out of the build, code and\or assets.
     
    DavidGeoffroy likes this.