Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Thousands of Audio.Thread causing very long loading! (issue after 2017 to 2019)

Discussion in 'Editor & General Support' started by CoolJosh3k, Feb 28, 2022.

  1. CoolJosh3k

    CoolJosh3k

    Joined:
    Dec 3, 2016
    Posts:
    145
    Hi there,

    I've come across a crippling issue after migrating over to Unity 2019 from Unity 2017. Loading scenes used to take only a few seconds, but now takes a half a minute.

    I used the profiler to try and figure it out and I can see moments where there are as much as 10,000 instances of a Audio.Thread one after the other.

    Any help would be very much appreciated on this.

    Yours,

    CoolJosh3k
     
  2. CoolJosh3k

    CoolJosh3k

    Joined:
    Dec 3, 2016
    Posts:
    145
    Digging deeper, it looks like this issue is actually something to do with the FindWithTag method.

    While I was only using in Awake, something changed with my project after moving to 2019 and it broke. My guess is that instead of just checking an array created from all objects with the same tag, it searches every object in the scene instead.

    I solved most of my issue by "retro fitting" the use of a static reference. I wrote the code back when I first started using Unity so I fell for the trap of relying on finding objects via a tag, even though I had kept it to just a single use per object per scene.

    I did also have an issue where a tag I had created and used just fine, ended up going missing from my project multiple times. It no longer goes missing on its own, but perhaps there is some bug there that is causing this other symptom?

    Would be good to know more about what was going on here, but at least for those who read this with the same issue my solution may help.