Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[bug] addressables save utility object ("ResourceManagerCallbacks") in scene and it leaks after that

Discussion in 'Addressables' started by nik_d, Aug 16, 2019.

  1. nik_d

    nik_d

    Joined:
    Apr 27, 2018
    Posts:
    61
    Addressables don't even try to reuse already created ResourceManagerCallbacks and artists don't notice them, so it became there are a lot of them in scenes.

    Even worse - if this object is saved in scene, because of DontDestroyOnLoad in MonoBehaviourCallbackHooks, they leak!

    workaround: in Runtime\ResourceManager\ResourceManager.cs
    after line:

    m_CallbackHooks = new GameObject("ResourceManagerCallbacks", typeof(MonoBehaviourCallbackHooks)).GetComponent<MonoBehaviourCallbackHooks>();

    put:

    m_CallbackHooks.hideFlags = HideFlags.DontSave | HideFlags.NotEditable; //**addressables: we don't need the utility object to be saved in scene //todo: cleanup current scenes
     
  2. unity_bill

    unity_bill

    Unity Technologies

    Joined:
    Apr 11, 2017
    Posts:
    1,013
    thanks, we'll look into it.
     
  3. GrandBOOM

    GrandBOOM

    Joined:
    Oct 25, 2016
    Posts:
    18

    Thanks just what I needed. Maybe its hidden in a DLL or something (should not be because addresables are supposed to be open source) but I noticed the Dispose method in ResourceManager.cs has 0 usages.
     
  4. Egil-Sandfeld

    Egil-Sandfeld

    Joined:
    Oct 8, 2012
    Posts:
    72
    Still getting these after runtime in editor:

     
    Brightori, hololabs and Lukas-Labaj like this.
  5. paladinrose

    paladinrose

    Joined:
    Aug 1, 2010
    Posts:
    8
    Also getting these objects after asset database is updated.
     
  6. Egil-Sandfeld

    Egil-Sandfeld

    Joined:
    Oct 8, 2012
    Posts:
    72
    Below does NOT work unfortunately...

    ---

    Still getting this error with Addressables 1.7.4, but I think I've found a workaround, to prevent these gameobjects from being added:

     
    Last edited: Apr 3, 2020
  7. ruiyl

    ruiyl

    Joined:
    Aug 4, 2019
    Posts:
    11
    I just did what you suggest there @Egil-Sandfeld . The objects still popped up in 1.7.5.
     
  8. Egil-Sandfeld

    Egil-Sandfeld

    Joined:
    Oct 8, 2012
    Posts:
    72
    Yeah, sorry that didn't work unfortunately. Also got it myself just now
     
  9. ruiyl

    ruiyl

    Joined:
    Aug 4, 2019
    Posts:
    11
    Let's hope they will fix this in the next update!
     
  10. Patrick_PS

    Patrick_PS

    Joined:
    Sep 9, 2019
    Posts:
    86
    I had this when I tried to load assets with addressables in an editor script.
     
  11. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    754
    This is still an issue in Unity 2019.3.8f1. GameObjects are instantiated into the scene at edit time, although they should be part of DontDestroyOnLoad at runtime only.
     
  12. VacuumBreather

    VacuumBreather

    Joined:
    Oct 30, 2013
    Posts:
    65
    Still an issue. Basically renders this package unusable. It's trashing every scene
     
  13. peartreegames

    peartreegames

    Joined:
    Mar 15, 2016
    Posts:
    5
    I was also experiencing this issue in editor. I couldn't find any uses of Dispose as GrandBOOM mentioned (except for a couple test clean ups) but also couldn't quite find where it should be called, maybe someone smarter than me can see. So for now as a quick patch I've just added scene search in the ResourceManager RegisterForCallbacks function.

    m_CallbackHooks = GameObject.FindObjectOfType<MonoBehaviourCallbackHooks>();

    The function now just looks like this:

    Code (CSharp):
    1.        
    2.         private void RegisterForCallbacks()
    3.         {
    4.             m_CallbackHooks = GameObject.FindObjectOfType<MonoBehaviourCallbackHooks>();
    5.             if (CallbackHooksEnabled && m_CallbackHooks == null)
    6.             {
    7.                 m_CallbackHooks = new GameObject("ResourceManagerCallbacks", typeof(MonoBehaviourCallbackHooks)).GetComponent<MonoBehaviourCallbackHooks>();
    8.                 m_CallbackHooks.OnUpdateDelegate += Update;
    9.             }
    10.         }
     
    lanpartygamesstudio likes this.
  14. Brightori

    Brightori

    Joined:
    Sep 15, 2017
    Posts:
    57
    have same problem =(
     
  15. Arthur-LVGameDev

    Arthur-LVGameDev

    Joined:
    Mar 14, 2016
    Posts:
    138
    We're seeing this, too.
     
    lanpartygamesstudio likes this.
  16. lanpartygamesstudio

    lanpartygamesstudio

    Joined:
    Jul 3, 2019
    Posts:
    2
    I am observing this as well, seems like the only place where the OnUpdateDelegate (funny name for an event) event gets unsubscribed is from here:
    upload_2020-7-1_13-45-11.png

    However I believe every time a new Load operation is initiated, a subscriber is added from RegisterForCallbacks. Which leads to a huge leak of delegates:

    upload_2020-7-1_13-43-11.png

    Unless I am misusing the whole system, I think this should be fixed...

    EDIT: I'm testing a simple fix and seems to be working fine (might have side effects since I'm not aware 100% of the rest of the system but seems reasonable)

    upload_2020-7-1_14-8-24.png
     
    Last edited: Jul 1, 2020
  17. Arthur-LVGameDev

    Arthur-LVGameDev

    Joined:
    Mar 14, 2016
    Posts:
    138
    Unity -- is this on your radar to get fixed? ETA on a fix?

    It's definitely still a bug we're seeing frequently, and from @lanpartygamesstudio posted code changes it would seem that the problem/cause of the issue is spelled out pretty well.
     
    lanpartygamesstudio likes this.
  18. Prodigga

    Prodigga

    Joined:
    Apr 13, 2011
    Posts:
    908
    It has been an entire year, and ResourceManagerCallback's still leaks in to the scene.

    And whats hilarious is that sometimes this is the thing that causes our scenes to become dirty, so when we do addressable update builds the scene needs to be rebuilt and re-downloaded by the end user because of this garbage that is being leaked into the scene. So it is screwing over your own pipelining.
     
  19. Danoli3

    Danoli3

    Joined:
    Sep 12, 2017
    Posts:
    10
    How was this fix missing from 1.8.5...
     
    lanpartygamesstudio likes this.
  20. Arthur-LVGameDev

    Arthur-LVGameDev

    Joined:
    Mar 14, 2016
    Posts:
    138
unityunity