Search Unity

Bug The AssetBundle can't be loaded because another AssetBundle with the same files is already loaded.

Discussion in 'Addressables' started by ProtoTerminator, Jul 2, 2020.

  1. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    586
    So I just spent the last several weeks refactoring my project to separate some assets into a separate project from the main project. I build the external addressables and LoadContentCatalogAsync and everything works perfect in editor.
    So to test a WebGL build, I build the main project's assets and the other project's assets for WebGL and put both in StreamingAssets under separate directories. Then I build the main engine. I upload it all to S3 and load up the WebGL build, and most of it works until I get that error, then all my local materials are pink (I believe the external shaders are loaded first causing the error on local assets. I bet if I loaded them in reverse order the local shaders would work and external shaders wouldn't).

    Code (CSharp):
    1. The AssetBundle 'https://*****.s3.amazonaws.com/test/academy/StreamingAssets/AssetBundles/WebGL/miscellaneous_unitybuiltinshaders_0ee8cf1f1746592e1392e2ed48547b63.bundle' can't be loaded because another AssetBundle with the same files is already loaded.
    This is a major blocker for us. Are there any solutions?

    Unity 2019.1.14f1 and Addressables 1.11.2 (also tested with 1.9.2, same error).
     
  2. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    586
    Okay, I still think this is a bug that needs to be addressed, but I figured out a workaround. In my main project, I have the default group bundle naming set to
    Append Hash to Filename
    and in the other project I set it to
    Filename
    . This seemed to allow all the shaders to load in properly.

    Of course this workaround means I now have duplicate shader assets from each catalog, and it also means this won't scale past 4 catalogs (there's only 4 ways to name those auto-generated bundles).
     
  3. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    973
    What sort of output are you getting from the Check Dupe Dependencies analysis tool?
     
  4. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    586
    They're built with 2 separate projects, so that tool is useless for this purpose.
     
  5. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,822
    Thanks for flagging, and happy to hear you've found a work around! Could you also submit a bug report for us so that we might investigate this further?
     
  6. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    586
    @TreyK-47 Sorry it took me a while to file the bug report, but it's done now. Case 1268758
     
  7. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    586
  8. KospY

    KospY

    Joined:
    May 12, 2014
    Posts:
    153
    @TreyK-47

    This bug is announced as fixed but it's not. We are using addressable 1.16.15 (we can't use 1.16.16 as it broke loading for us), and we are still getting this error.

    We are using addressable for our main game files and modding (we load catalogs using LoadContentCatalogAsync) and any mod that generate a "xx_unitybuiltinshaders.bundle" will not be able to be loaded because of this conflict error. We tried to prevent this unitybuiltinshaders file to be generated, but it seem impossible and any time a builtin shader or texture is used addressable will generate it. We somehow managed to do a dirty workaround to prevent the conflict (disabling CRC check, editing the catalog json and change the path to an unique xx_unitybuiltinshaders), but it still break any builtin shader a modder will use.
    Currently we are stuck and we will have to say to our modding community that it's an Unity bug, and that they need to avoid using any builtin shader in their mods to mitigate this issue.

    Would be happy if the issue could be opened again, and/or if we could get a workaround to make this work correctly.

     
  9. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    586
    @KospY I'm not sure how they fixed my original reported issue, but if it's still the same as it was back then, you could try renaming the default group so that each modder should have a unique default group name. I'm not sure how you would go about enforcing that, but that could be a workaround.
     
  10. KospY

    KospY

    Joined:
    May 12, 2014
    Posts:
    153
    @ProtoTerminator

    I tried to rename, but it throw the same message. I suppose it check the content and if the files in the bundle are same that some already loaded it crash :(
     
  11. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,822
    I'll reach out to the team for some guidance.
     
  12. KospY

    KospY

    Joined:
    May 12, 2014
    Posts:
    153
    I just saw that addressable 1.17.5-preview added an option to set custom prefix on the unitybuiltinshader AssetBundle! I updated to this version and set the option to "default group GUID" and the problem is gone!!
    Whoever worked on this at Unity I just wanted to say thanks to him!
     
    davidla_unity likes this.
  13. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    763
    @KospY happy to help :)

    Updating to 1.17.5-preview and using the new Shader bundle prefix option is going to be the solution for this. It's part of the AddressableAssetSettings options for anyone curious. It's hard to recommend which one to use since they all have their place in specific situations. I'll give a little insight to help guide anyone that needs to take advantage of this:

    When not to use something:
    1) If you're using a multi-project setup and you copied the first project to create the second project don't use the default group GUID option since the default groups for your projects will have the same guid (since they're copied projecs)
    2) If you're using a multi-project setup and your projects have the same name don't use the Project Name Hash option.
    3) If you think you'll rename your project at any point don't use the Project Name Hash option.

    As for the custom option, this can be used for multi-project setups or single project setups. The custom option is more manual but it allows you total control over how the shader bundle will be named.

    The big thing to note is that Addressables builds the default built in shader bundle for content builds and uses that as a dependency. If something from somewhere gets loaded that has a dependency on a different built in shader bundle you'll want to make sure these file names never overlap (it's a limitation of the editor that two AssetBundles with the same name can't be loaded at the same time).

    I hope the new option works well for everyone and prevents these types of issues in the future.
     
  14. Pandaismyname1

    Pandaismyname1

    Joined:
    Apr 4, 2016
    Posts:
    4
    What can we do if we use HDRP in our multiple projects?

    I have a setup of 3 Unity projects, all 3 using HDRP. In project A I have the main project, which contains some basic assets and I am loading addressable content from a local http server which contains 2 catalogs, created by projects B and C. In project B I have a prefab with a model which uses the HDRP/Lit shader that I export as the content. In project C I have a prefab with another model which uses the same HDRP/Lit shader. Both these projects have been configured as David mentioned, with a custom shader bundle prefix that is unique per project.

    Now the thing is that both of them have a dependency to the HDRP/Lit shader, as I can see when analyzing AnalyzeRules->UnfixableRules->[My custom bundle]->Implicit that there is a reference to
    Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.shader
    . Because of this, I cannot load both of them at the same time.

    I am planning to create multiple projects for Addressable content creation(like projects B and C) and have project A to load the content they create.
     
  15. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    763
    @Pandaismyname1 so, since your bundle has an implicit reference to the HDRP shader it should just be built into the bundle. What is your Internal Bundle Id Mode on the groups that have the implicit reference to the HDRP shader? If your projects A, B, and C are all copies of each other that you've changed after copying your original project then those groups will share the same GUID which can cause issues like this. I'd recommend trying to change that to "Group Guid Project Id Entries Hash" and maybe even make sure that Bundle Naming Mode is "Append Hash to Filename" though the latter shouldn't matter as much.
     
  16. phobos2077

    phobos2077

    Joined:
    Feb 10, 2018
    Posts:
    350
    I'm having the same issue on single project build after upgrading to 1.18.13. If I enable MonoScript bundle, I face the same error but regarding the "monoscript" asset bundle. If I disable it, then I get the error about builtin shaders as above. I'm clearing the build cache and all bundles between every build. Any pointers will be greatly appreciated @davidla_unity
     
  17. Jonas-Neuston

    Jonas-Neuston

    Joined:
    Jun 10, 2017
    Posts:
    70
    phobos2077 likes this.
  18. phobos2077

    phobos2077

    Joined:
    Feb 10, 2018
    Posts:
    350
    I'm also being plagued by this error followed by app crash:

    Code (CSharp):
    1. 2021.07.23 18:16:37.876 15604 15670 Error Unity The file 'none' is corrupted! Remove it and launch unity again!
    2. 2021.07.23 18:16:37.876 15604 15670 Error Unity [Position out of bounds!]
    3. 2021.07.23 18:16:37.876 15604 15670 Error Unity UnityEngine.StackTraceUtility:ExtractStackTrace () (at /Users/bokken/buildslave/unity/build/Runtime/Export/Scripting/StackTrace.cs:37)
    4. 2021.07.23 18:16:37.876 15604 15670 Error Unity UnityEngine.Object:Instantiate<UnityEngine.GameObject> (UnityEngine.GameObject) (at /Users/bokken/buildslave/unity/build/Runtime/Export/Scripting/UnityEngineObject.bindings.cs:271)
    5.  
    didn't happen in older versions :(

    Tried clearing my Library folder, but it re-appeared again.
     
  19. Patrick_PS

    Patrick_PS

    Joined:
    Sep 9, 2019
    Posts:
    154
    I also have the "bundle can't be loaded because another AssetBundle with the same name is already loaded" error after updating to the latest version of the plugin. I have a single project. The error appears when I call DownloadDependenciesAsync.
     
  20. Jonas-Neuston

    Jonas-Neuston

    Joined:
    Jun 10, 2017
    Posts:
    70
    phobos2077 likes this.
  21. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,618
    I had the same issue too and desperately tried all sorts of things to fix it. For me it ultimately comes down to missing functionality in Addressables to force a release of all AsyncOperationHandle.

    In my tests the problem occurred if an AsyncOperationHandle isn't released of the file that's being updated.

    You can find my workaround for this problem here:
    https://forum.unity.com/threads/how...-loaded-by-addressables.1121998/#post-7374218
     
  22. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    763
    Hey all, sorry if this is mentioned above and I missed it, but are any of you using TransformInternalId to point to specific remote AssetBundles? I ask because there's currently an issue that I'm working on that results in this "asset bundles cannot be loaded because one with the same name is already loaded" error. If you are, what could be happening is that in our AsyncOperationCache we're caching operations based on the un-transformed location. When another request comes in and needs a bundle that you've already loaded somewhere else, it can't pick up that operation like it should because it doesn't yet know the internal id is going to be modified.

    Peter, I'm giving your thread about wanting an Addressables.ReleaseAll to our product manager so we can evaluate this.

    If you're not using TransformInternalId and are only encountering this as part of a content update, then double check your Bundle Naming Mode on the group. If it's set to Filename, try using "Append hash to filename"

    You can also check out using Unique Bundle IDs. There's a section on it here: https://docs.unity3d.com/Packages/c...19/manual/ContentUpdateWorkflow.html#overview
     
  23. Jeff-Kesselman

    Jeff-Kesselman

    Joined:
    Apr 5, 2010
    Posts:
    99
    This is also causing my grief because I have a web service that provides the bundle and the only difference between a URL for two different bundles are "?" url parmaeters. It appears that unity is lying. Its not there are files named the same IN the bundle (they aren't) but that the url path is being used as a key (without the parameters).

    This is not good design. i question using the URL as a key period, but if you are going to do that you MUST include the entire string including any parameters.

    It looks like th only way for me to fix this is to completely rewrite the webservice to make the bundle name part of the url itself ...
     
  24. Jeff-Kesselman

    Jeff-Kesselman

    Joined:
    Apr 5, 2010
    Posts:
    99
    Edit: Update:

    Tried that so its not the issue. I have a ccodebase on another machine that doesn't evidence this problem but that codebase has other issues.

    My situation is that I am building bundles separately that have prefabs for rendered modles in them,
     
  25. adani_zynga

    adani_zynga

    Joined:
    Oct 6, 2022
    Posts:
    6
    Hey @davidla_unity! Is the issue with using TransformInternalId still happening? We use the TransformInternalId function and are running into this issue with "asset bundles cannot be loaded because one with the same name is already loaded" error.
     
    corp_unity_czy likes this.
  26. Cannaan

    Cannaan

    Joined:
    Mar 15, 2013
    Posts:
    12
    we encounter the error recently. we are using addressables 1.19.19, used WebRequestOverride. when player has bad network and the web request failed, we transform the url to another host.
    is it the same issue you mentioned? is there any work around to fix it?
     
    Last edited: Apr 10, 2023