Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unloading AudioClip assets via assetReference Release causes 100 ms lock on Main thread

Discussion in 'Addressables' started by dizzy2003, May 27, 2020.

  1. dizzy2003

    dizzy2003

    Joined:
    Nov 25, 2013
    Posts:
    107
    Link to deep profile (this is ps4 but its on all platforms to some extent)

    https://imgur.com/a/0pS05QT


    I have 1000 audio clips I wish to async load, they are in 10 addressable groups
    Each group has approx 100 clips.

    when I async load, I load all items in a group 1 by 1 a few per game turn

    when I unload I release all the sounds from a group 1 by 1 over a few game turns

    the last one causes 100 ms Stall when the asset bundle is released.

    Is there any way I can async stream audio as I move through the world async pre loading without getting a massive stall?

    I cant mark the audio as streaming I wish to preload it so its ready before its needed
    Marking all audio as dont preload and then using audioClip.Preload works, but is expensive on main thread about .5ms per clip.

    So here I am with addressables that also have issues.

    Unity 2019.3.10
    addressables 1.8.3
     
    Last edited: May 27, 2020
    laurentlavigne likes this.
  2. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,816
    I'll flag this for the team to have a look!
     
  3. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,816
    Have a bit of insight and guidance from the team. So, bundle unload is done synchronous which is likely why you're seeing that. To get unloading asynchronously is going to take a long time since it will require an engine change and a package change.You might try breaking your audio clips down into different Addressable Groups or making that Group a Pack Separately group, if that's at all possible for you.
     
  4. dizzy2003

    dizzy2003

    Joined:
    Nov 25, 2013
    Posts:
    107
    yeah my clips are in groups of a couple of hundred clips per group. Last time I tried the pack seperatly option it crashed the build process, but maybe a group only containing audio clips might work.

    So as far as I can tell unity currently has no way to aync load and unload audio clips.

    Even just disabling preload per clip and calling .load and unload manually which claims to be async actually blocks the main thread.