Search Unity

Bug Error while building Addressables

Discussion in 'Addressables' started by Houtamelo, Sep 12, 2021.

  1. Houtamelo

    Houtamelo

    Joined:
    Jan 3, 2020
    Posts:
    31
    I'm getting the following errors while trying to build the addressables:

    1:
    An asset is marked with HideFlags.DontSave but is included in the build:
    Asset: 'Library/unity default resources'
    Included from scene: 'Assets/Scenes/MainMenuScene.unity'
    Asset name: GUISkin
    (You are probably referencing internal Unity data in your build.)
    UnityEditor.GenericMenu:CatchMenu (object,string[],int)

    2:
    Build Task WriteSerializedFiles failed with exception:
    Could not find file "C:\Users\anton\Documents\Repository\src\Library\BuildCache\09\09ce8b0817aa172c31c2406eb8cb0d48\8d13ef0b72bb794afb62efa3c0f57ec8\CAB-a454b013b8e1832c5df47a3870b9e2ef"
    at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x0019e] in <695d1cc93cca45069c528c15c9fdd749>:0
    at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean isAsync, System.Boolean anonymous) [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0
    at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access) [0x00000] in <695d1cc93cca45069c528c15c9fdd749>:0
    at (wrapper remoting-invoke-with-check) System.IO.FileStream..ctor(string,System.IO.FileMode,System.IO.FileAccess)
    at UnityEditor.Build.Pipeline.Utilities.HashingMethods.CalculateFile (System.String filePath) [0x00000] in C:\Users\anton\Documents\Repository\src\Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.2\Editor\Utilities\HashingMethods.cs:488
    at UnityEditor.Build.Pipeline.Tasks.WriteSerializedFiles.CalculateFileMetadata (UnityEditor.Build.Content.WriteResult& result) [0x0002f] in C:\Users\anton\Documents\Repository\src\Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.2\Editor\Tasks\WriteSerializedFiles.cs:134
    at UnityEditor.Build.Pipeline.Tasks.WriteSerializedFiles.UnityEditor.Build.Pipeline.Utilities.TaskCachingUtility.IRunCachedCallbacks<UnityEditor.Build.Pipeline.Tasks.WriteSerializedFiles.Item>.ProcessUncached (UnityEditor.Build.Pipeline.Utilities.TaskCachingUtility+WorkItem`1[T] item) [0x000bb] in C:\Users\anton\Documents\Repository\src\Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.2\Editor\Tasks\WriteSerializedFiles.cs:178
    at UnityEditor.Build.Pipeline.Utilities.TaskCachingUtility.RunCachedOperation[T] (UnityEditor.Build.Pipeline.Interfaces.IBuildCache cache, UnityEditor.Build.Pipeline.Interfaces.IBuildLogger log, UnityEditor.Build.Pipeline.Interfaces.IProgressTracker tracker, System.Collections.Generic.List`1[T] workItems, UnityEditor.Build.Pipeline.Utilities.TaskCachingUtility+IRunCachedCallbacks`1[T] cbs) [0x00177] in C:\Users\anton\Documents\Repository\src\Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.2\Editor\Utilities\TaskCachingUtility.cs:100
    at UnityEditor.Build.Pipeline.Tasks.WriteSerializedFiles.Run () [0x0003b] in C:\Users\anton\Documents\Repository\src\Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.2\Editor\Tasks\WriteSerializedFiles.cs:120
    at UnityEditor.Build.Pipeline.BuildTasksRunner.Run (System.Collections.Generic.IList`1[T] pipeline, UnityEditor.Build.Pipeline.Interfaces.IBuildContext context) [0x00099] in C:\Users\anton\Documents\Repository\src\Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.2\Editor\Shared\BuildTasksRunner.cs:56
    UnityEditor.GenericMenu:CatchMenu (object,string[],int)

    3:
    SBP ErrorException
    UnityEditor.GenericMenu:CatchMenu (object,string[],int)

    4:
    Addressable content build failure (duration : 0:01:37.412)
    UnityEditor.GenericMenu:CatchMenu (object,string[],int)

    Things i have tried so far:
    1- Deleting the mentioned 'Assets/Scenes/MainMenuScene.unity' scene, doesn't fix the issue as after trying to build the game without the scene the same error happens but referencing another scene.
    2- Making sure none of my scripts has the "using UnityEditor;" directive (anywhere i use it in my script is also between "#if UNITY_EDITOR" and "#endif".
    3- Deleting the Library folder.
    4- Reimporting the Assets folder.
    5- Enabling/Disabling MonoScript Bundle Naming, as well as trying all the different options in that.
    6- Enabling/Disabling Non-Recursive Dependency Calculation.
    7- Also tried out all the options on the Shader Naming.

    Also worth noticing:
    1- Disabling MonoScript Bundle Naming makes it so no error is thrown during the addressables building process, however it makes any kind of addressable files completely broken inside game builds (works fine in editor play mode), the first scene works fine in standalone builds since it's not an addressable, however any scene after that is broken and full of errors.
    2- In the editor, changing Play Mode Scripts to advanced makes the game work fine, however using "Existing Build" (if MonoScript Bundle Naming is disabled - since while enabled it throws the above error) makes the game completely broken as well, only the starting scene works since it's not an addressable.
    3- I can't reproduce the issue since it's a very large project.
    4- I can't attach the project since it's very large.
    5- I have been using addressables for over an year and i have never experienced such problem, the problem didn't appear after updating the Addressables package.
    6- I was experiencing this issue in the 1.18.15 version, upgraded to 1.19.4 but that did not fix the problem.

    Current Addressables package version: 1.19.4
    Current Unity Version: 2020.3.18f1
     

    Attached Files:

  2. Houtamelo

    Houtamelo

    Joined:
    Jan 3, 2020
    Posts:
    31
    Can't edit the post due to some error so i'm making this reply.

    Things i have tried so far:
    8- Deleting the Graphics asset on the project folder.
    Edit:
    9- Removing all gameobjects from the "MainMenuScene" still throws the same error on that same scene, meaning the error happens on clean/empty scenes as well.

    Worth mentioning:
    7- I searched google and some people were having problems with the DoozyUI package which i do not use.
     
    Last edited: Sep 14, 2021
  3. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,822
    I'll flag with the team!
     
    Houtamelo likes this.
  4. pillakirsten

    pillakirsten

    Unity Technologies

    Joined:
    May 22, 2019
    Posts:
    346
    Houtamelo likes this.
  5. Houtamelo

    Houtamelo

    Joined:
    Jan 3, 2020
    Posts:
    31
    Tried downgrading, but the addressables are still broken inside game builds (i can build the addressables).
    The only reason i enabled MonoScript Bundle Naming was to check if it would fix my problem, because addressables was building it was just not working inside standalone builds (and on the inspector with the PlayScript "Use Existing Build" option).
     
  6. pillakirsten

    pillakirsten

    Unity Technologies

    Joined:
    May 22, 2019
    Posts:
    346
    @Houtamelo Oh I see, so you're able to build Addressables successfully (without errors) but loading data from AssetBundles still fails (running the game builds or when using the "Use Existing Build" playmode script in the Editor)?

    If so, then the ticket mentioned only applies for the case where you're seeing the GUI skin build errors. Could you elaborate more on the errors you're seeing at runtime?

    The other playmode scripts load Assets from the Project files, not from the AssetBundles created after building Addressables. So it is possible for the other playmode scripts to load Assets successfully while the "Use Existing Build" playmode script fails to load any Assets.
     
    Last edited: Sep 16, 2021
    Houtamelo likes this.
  7. Houtamelo

    Houtamelo

    Joined:
    Jan 3, 2020
    Posts:
    31
    Yes, i can successfuly build the addressables with no errors or warnings. (if monoscript is disabled)
    I can load some of the Addressables in-game, however some of the loading operations result in null values, the ones that don't give me broken assets, e.g. an addressable scene loaded comes with missing objects, the objects that are not missing have a bunch of null references (even simple ones like UI Images come with a different(usually null) sprite than it originally had). Many monobehaviours attached to gameobjects in such scenes come with null references (in both cases were they are referencing assets or objects in that scene).

    In the end it results on standalone builds that don't work past the first scene (the first scene is not an addressable).

    Worth Mentioning:
    Before making any standalone build i always make sure to build the addressable content, i even try purging the previous build cache before doing that.
     
  8. pillakirsten

    pillakirsten

    Unity Technologies

    Joined:
    May 22, 2019
    Posts:
    346
    Houtamelo likes this.
  9. Houtamelo

    Houtamelo

    Joined:
    Jan 3, 2020
    Posts:
    31
    I used "Debug.Log(Application.persistentDataPath);" to find the folder, went there and there was no "com.unity.addressables" folder or file, just "Player.log" and "Player-prev.log".

    Editor log is attached.
     

    Attached Files:

  10. pillakirsten

    pillakirsten

    Unity Technologies

    Joined:
    May 22, 2019
    Posts:
    346
    I see, since the folder doesn't exist then no catalogs have been cached.

    Sorry might not have been clear before, but could you share any log file (Player.log, or Editor.txt) that shows the errors being logged when running the player or using the "Use Existing Build" playmode script in the Editor?
     
    Houtamelo likes this.
  11. Houtamelo

    Houtamelo

    Joined:
    Jan 3, 2020
    Posts:
    31
    Here's a log file for each situation.
    It is worth mentioning that the errors shown here do not represent the actual broken state of the addressables files, quoting my first post:
     

    Attached Files:

  12. pillakirsten

    pillakirsten

    Unity Technologies

    Joined:
    May 22, 2019
    Posts:
    346
    Thank you! I see that the NullReferenceException logs are not that helpful, it's just saying that whatever the SortEntryButtons are referencing is null. Are they referencing an asset that's Addressable? If so, are you using the AssetReference class to reference the asset?
     
    Houtamelo likes this.
  13. Houtamelo

    Houtamelo

    Joined:
    Jan 3, 2020
    Posts:
    31
    I don't use the AssetReference class on my project, whenever i want to get an addressable i use it's address.
    The CodexPanel class that holds the SortEntryButtons() method is also an addressable which is loaded after all my static classes are initiliazed.
    The NullReferenceException happens on this object:

    [SerializeField] private List<CodexEntryButton> codexEntryButtons = new List<CodexEntryButton>();


    This list is serialized by Unity and has by default around 30 CodexEntryButtons (which are MonoBehaviours).
    To make sure the list is not null i also added this line at the start of the Awake method (SortEntryButtons() is called at the end of the Awake method).
    Code (CSharp):
    1.  codexEntryButtons ??= new List<CodexEntryButton>();
    That NullReferenceException is only one among many of problems while using "Existing Build"/Standalone Build.
    Here's some more screenshots of the issues, Text Mesh Pro Font Assets are not loading (i reference them inside an addressable scriptable object), the sprites are simply wrong on the scenes.

    I included a comparison of the main menu on "Use Asset Database" vs "Use Existing Build", as well as how the Pause Menu is on "Use Asset Database" (the PauseMenu on "Use Existing Build" is simply a white screen but i can still interact with the buttons (by pressing down Left Mouse on where the button should be).
     

    Attached Files:

  14. pillakirsten

    pillakirsten

    Unity Technologies

    Joined:
    May 22, 2019
    Posts:
    346
    I see, are the CodexEntryButtons and Text Mesh Pro Font Assets addressable as well? You may be referencing Project files that don't actually get included in the AssetBundles, and become null references in the "Existing Build" playmode/Standalone Build.
     
  15. Houtamelo

    Houtamelo

    Joined:
    Jan 3, 2020
    Posts:
    31
    The CodexEntryButtons are prefabs and addressables, the TMP Font assets are not, just the scriptable object that references them.

    Shouldn't they be included in the build through the recursive dependency check? It always worked without needing to turn every single asset into an addressable. Previously (2 months ago) i only needed to turn the asset i want to load into an addressable and during the Content Build it would include any assets referenced by the addressable.

    I didn't change the CodexEntryButtons or the Font Assets recently, neither did i change how i load them and it previously worked fine.
     
  16. pillakirsten

    pillakirsten

    Unity Technologies

    Joined:
    May 22, 2019
    Posts:
    346
    Hmm I tested how your TMP Font assets set up (loading an addressable ScriptableObject that references TMP Font assets), and it does load correctly.

    Are you be able to reproduce the issue on a new project? Maybe pick one of your existing scenes that when loaded, contains (1) a missing object and (2) an object with a null reference.
     
  17. Houtamelo

    Houtamelo

    Joined:
    Jan 3, 2020
    Posts:
    31
    I was not able to reproduce it on a new project, copying and the scenes to the new project (and the assets the scenes need) did not present the issue.
     
  18. Houtamelo

    Houtamelo

    Joined:
    Jan 3, 2020
    Posts:
    31
    Update, I tried the following, in this order:

    1=> Uninstalling the Addressables Package
    2=> Deleting the Addressable Assets Folder
    3=> Closing the Unity Editor
    4=> Opening the Unity Editor
    5=> Reinstalling the Addressables Package
    6=> Making every file that was previously addressable an addressable again and putting it in the same group as before
    7=> Entering the editor play mode (using the fastest option) to make sure the game is still working and it was working fine
    8=> Building the Addressables Content
    9=> Entering the editor play mode (using the "Use existing Build" option), the game still has the exact same issues.
    10=> Creating a standalone build and testing it, still has the exact same issues.
     
  19. Houtamelo

    Houtamelo

    Joined:
    Jan 3, 2020
    Posts:
    31
  20. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    332
    The monoscript bundle option will be fixed with Scriptable Build Pipeline 1.19.3 release.
    In the short term, if you want to modify your local copy of Scriptable Build Pipeline to fix this, here are the changes:

    In CreateMonoScriptBundle.cs add to the using section:
    using UnityEditor.Build.Utilities;

    Then in the
    Run()
    update the type check from this:
    if (usedTypes[i] != monoScript)

    to this:
    if (usedTypes[i] != monoScript || usedSet[i].filePath.Equals(CommonStrings.UnityDefaultResourcePath, StringComparison.OrdinalIgnoreCase))


    Attached is the updated code file.
     

    Attached Files:

    Houtamelo likes this.
  21. Houtamelo

    Houtamelo

    Joined:
    Jan 3, 2020
    Posts:
    31

    thank you for the reply but as i have discussed with @pillakirsten in the above posts the monoscript bundle naming is not my real problem, the problem is that addressables scenes and some scriptableObjects are not loading correctly.
     
  22. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    332
    Apologies I was only made aware of the initial type issue and quickly replied with the update to that issue missing the rest of the context in the thread. Reading through the thread, I do not see any mention of clearing the build cache via the Addressables build menu option, or via the Scriptable Build Pipeline's Preferences Window. Can you try clearing the build cache and rebuilding to see if that helps at all?
     
    Houtamelo likes this.
  23. Houtamelo

    Houtamelo

    Joined:
    Jan 3, 2020
    Posts:
    31
    Although i didn't mention it, almost every time i try building the Addressables i clear the cache beforehand.

    I managed to dodge the issue by not using Addressables Scenes and Prefabs, other kinds of addressable assets have not been presenting any issues.
     
  24. pillakirsten

    pillakirsten

    Unity Technologies

    Joined:
    May 22, 2019
    Posts:
    346
    Hi @Houtamelo apologies for the delay. I think the easiest way for us to debug the issue is to access your project.

    If you can send me your email address, I'll send you a secure link where you can upload your large project. Then from there I'll create a bug ticket.
     
  25. Houtamelo

    Houtamelo

    Joined:
    Jan 3, 2020
    Posts:
    31
    Hi, i changed my whole project structure to make the addressables work (including the changes on my last post) and due to company policies i am not allowed to share the project with anyone.
     
  26. pillakirsten

    pillakirsten

    Unity Technologies

    Joined:
    May 22, 2019
    Posts:
    346
    Understood, let us know if you encounter the issue in the future and can submit a separate reproduction project.
     
    Houtamelo likes this.
  27. huangdongxc

    huangdongxc

    Joined:
    Mar 22, 2020
    Posts:
    6
    @Houtamelo @pillakirsten
    We have the same issue.
    Addressable Load TextAsset and return null in production
    Do you have a solution?
     
    Nyanpass233 likes this.
  28. zackleitzel

    zackleitzel

    Joined:
    Oct 19, 2021
    Posts:
    1
    Actually having this same issue in my project, anybody have a solution?
     
  29. evgeny44mikhalev

    evgeny44mikhalev

    Joined:
    Sep 4, 2018
    Posts:
    9
    Regarding the error n 2.
    I just restarted my unity and it worked like a charm :D Now I can update already existing build