Search Unity

Addressable asset don't find shader when loading scene,Unity default shader missing in scene loaded

Discussion in 'Addressables' started by EmilieCollard191, Oct 23, 2019.

  1. EmilieCollard191

    EmilieCollard191

    Joined:
    May 8, 2019
    Posts:
    77
    Recently my studio decided to switch from assetbundle to addressable asset.
    All is fine until I load a scene that is addressable in packed mode or in build.

    The scene load correctly but not all shader(Prety mutch everything is pink).
    The shader not native to unity seen to be loaded correctly but not the one native to unity.
    One common missing shader is Sprites/Default

    The addressable asset are build for Window and my target is Window.
    I'm on Unity 2018.4.2f1.

    Can someone point out to me what could be wrong? ,Recently my studio decided to switch from assetbundle to addressable asset. All is fine until I load a scene that is addressable in packed mode or in build.

    The scene load correctly but not all shader. The shader not native to unity seen to be loaded correctly but not the one native to unity. One common missing shader is Sprites/Default

    The addressable asset are build for Window and my target is Window.
    I also tested on Android and it doesn't work.

    Can someone point out to me what could be wrong?
     
  2. Patrick_PS

    Patrick_PS

    Joined:
    Sep 9, 2019
    Posts:
    154
    Hi, I am having the same issue at the moment. Did you manage to fix this issue?
     
  3. EmilieCollard191

    EmilieCollard191

    Joined:
    May 8, 2019
    Posts:
    77
    Sadly not. If we found a solution I will post it here.
     
  4. EmilieCollard191

    EmilieCollard191

    Joined:
    May 8, 2019
    Posts:
    77
    Hi we have found the problem on our side it was a Assetbundle.UnloadAll() call in an onDrestroy :)

    I don't know if your problem could be similar but that fixed our problem.
     
  5. Patrick_PS

    Patrick_PS

    Joined:
    Sep 9, 2019
    Posts:
    154
    Hi, thanks for the follow-up. My issue was that I was building for Android on a Windows PC, which caused the editor to not be able to correctly load the bundles. The build works fine on Android devices.
     
    Deleted User likes this.
  6. PigletPants

    PigletPants

    Joined:
    Sep 19, 2019
    Posts:
    23
    Thank you Patrick! This bug just got me too and my situation was the same as yours. :)

    Another problem I am seeing with Addressables/Android is with the memory profiler when running a build on Android the textures are howing up but the memory sizes for individual textures is showing 0 for some cases. Sometimes it is all textures, sometimes just a few or none. Just seems to randomly change between different builds, and between different scenes.

    Might need to do some bug reporting. :eek:

    Did you report the bug with the shaders?
     
  7. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,461
    Hi @PigletPants,

    If I understood the thread so far, the bug with the shaders was a bug in their own code.

    Are you using the Memory Profiler package and are those the native sizes that are 0? Is it sprites which show as 0 sized and are they in an atlas?
     
  8. PigletPants

    PigletPants

    Joined:
    Sep 19, 2019
    Posts:
    23
    Hi Martin :)

    I think you slightly misunderstood. The OP's problem was their own code but Patrick_PS's problem was that he was building the addressables content with Android as target platform. He was running the game in editor playmode with playmode script = Use Existing Build. When the game starts all the shaders that addressable content depends on is missing. However the same built game still works fine on the android device. This was exactly the same problem I was having (Unity v2019.3 and Addressables v1.8.3 [also tried v1.7.5 and same bug]).



    No, I am using just the built in memory profiler. I attached a few screenshots to show you. These are all just regular textures. Some of the textures are just randomly showing 0 size. Simply re-starting the game gives different results with this problem. Mesh data for the corresponding objects all looks normal. If I run in editor or build for windows and run everything is also normal.

    Mem Details 1.JPG Mem Details 2.JPG Mem Details 3.JPG
     
  9. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,461
    Ah ok, thanks for clarifying. I guess that's a separate bug/ usability issue with Addressables that should be reported.

    Weird. Could you maybe check if the Memory Profiler package also reports 0 B sizes for these? It splits the memory usage into Native/Managed and owned. Could be that the native memory here is owned by something else (Addressables) and these are just around via their Managed Shell objects? Or maybe you have references to them but haven't loaded them into memory via Addressables? Anyways, it'd be nice if you could report that as a bug so we can explore what's going on there. Could be by design with how Addressables works but then we should probably mention that somewhere in documtation at least.
     
  10. PigletPants

    PigletPants

    Joined:
    Sep 19, 2019
    Posts:
    23
    I just tried but it took over an hour and had not completed and I need to go now. I will try this another time.

    No, these textures are all on base scene objects. Just one simple call to load the scene. Then unload that scene and load another scene etc. I am not instantiating anything but the scene itself. It's giving different amounts of these 0 size results for the same scene objects textures when I change between scenes, rebuild the game etc. All the mesh data sizes for the objects these textures are on are normal.

    Thanks Martin. I will try to report these bugs soon.
     
  11. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,461
    Whoops, sorry forgot that you might be on a version >=2019.3.12f1 with this bug still present... If you are, you'll have to wait for the fix to land or downgrade to 2019.3.11f1 to capture but downgrading is obviously tricky so...

    Also, that capture bug was caused by a fix to properly get all memory connections, e.g. between sprites to their atlases, so maybe it's best to wait a bit for the fix. It's in the pipes and hopefully will land and be released soon.
     
  12. PigletPants

    PigletPants

    Joined:
    Sep 19, 2019
    Posts:
    23
    Ahh that would be the problem then I assume. I heard the memory snapshot can take a long time on mobile so I wasn't sure about it. I will wait for the fix and follow up on this. Cheers.
     
  13. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,461
    We've sped that up significantly for 2019.3 if it takes longer than 5-10 mins on a phone, something has very likely gone wrong.
     
  14. PigletPants

    PigletPants

    Joined:
    Sep 19, 2019
    Posts:
    23
    That's good to know thanks Martin.

    I just noticed that when pressing play in the editor the following warning pops up:

    Asset bundles built with build target Android may not be compatible with running in the Editor.
    UnityEngine.GUIUtilityProcessEvent(Int32, IntPtr)


    Does this mean the issue of addressables built for android missing shaders in playmode is a known issue? I won't report a bug if that's the case.
     
  15. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,461
    sounds like it is known...
     
  16. DungDajHjep

    DungDajHjep

    Joined:
    Mar 25, 2015
    Posts:
    202
    try set alway include shader or dont strip unused shader in graphic setting
     
    Last edited: Feb 28, 2021
  17. AbelSierra

    AbelSierra

    Joined:
    Jul 19, 2018
    Posts:
    19
    Hello! Did you find a solution for this? I had my project working properly and then I just changes the locations of some of the assets inside the project, rebuilt the addressables and now the materials in editor are pink (using existing build) and on device (oculus quest 2) does not appear, but if reassign the shader in editor is just work... weird because the same shader was already assigned
     
  18. FlightOfOne

    FlightOfOne

    Joined:
    Aug 1, 2014
    Posts:
    668
    Hi, were you able to figure this out?