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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Question Package addressables with app

Discussion in 'Addressables' started by Mordevil, Mar 17, 2021.

  1. Mordevil

    Mordevil

    Joined:
    Mar 9, 2018
    Posts:
    4
    Hi,
    I'm using addressables in my game and really like the benefits of easily updating all players with new content when available. But in my current setup as most things are organized in different groups the game itself is really small and the users have to download a lot of content the first time they enter the game. My goal is to build all addressables bundles and package them with the app but I want to still be able to check if the server has an updated version and download it. As I saw I cant mix local and remote build and load paths I tried creating two profiles that both use remote build and load.
    upload_2021-3-17_15-2-0.png

    But when I try to build them I get an error.
    upload_2021-3-17_15-3-4.png

    Is there a more elegant solution to have the bundles "predownloaded" but still remote and updateable?

    Thanks for your help!
     
  2. Mordevil

    Mordevil

    Joined:
    Mar 9, 2018
    Posts:
    4
    Update.

    I decided that the closest i can get to the desired result is to make all the bundles local and static in order to have them ship with the app. I'm willing to have all updated assets duplicated. With the remote bundles I had all bundles with custom labels in order to be able to update them on startup:
    Addressables.GetDownloadSizeAsync(this.allAssetBundleLabels)
    Addressables.DownloadDependenciesAsync(this.allAssetBundleLabels, MergeMode.Union, false);

    The problem is that with the static bundles the update size returns zero;

    So i made an additional step with :
    var catalogsToUpdate = Addressables.CheckForCatalogUpdates()
    Addressables.UpdateCatalogs(catalogsToUpdate);

    But this approach still does not work.
    Can anyone point to an example of this working. (prefetching and updating all changes on startup) cause i want to show a message to the user that content will be downloaded and not have them download at anytime.
     
  3. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,796
    Let me pass this on to the team to see if they have any suggestions.
     
  4. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    736
    Interesting, I see what you're saying. So, I have a suggestion but I'm not sure if it'll work. If it does work it definitely won't work on platforms that don't support Caching (PS4 & Switch). What you might be able to do is:
    • Create your groups as remote groups
    • Before any Addressables calls create a new Cache at a folder in StreamingAssets and then set the Caching.currentCacheForWriting to that new cache in streaming assets
    • Enter playmode using Use Existing Build playmode script. The remote bundles should be downloaded to your cache in streaming assets
    • Build your player with those bundles in streaming assets
    If you leave the code in that sets the current cache for writing to something in StreamingAssets then UnityWebRequest should check that cache before downloading. Since you built your StreamingAssets cache into your player the bundles should be cached locally.

    If you're using a CacheInitializationObject with Addressables then you might be stomping on some setting one way or the other. If you're not sure what that is then you're probably good.

    The steps listed above wouldn't be something you'd want to do all the time during development but you should be able to incorporate it as part of your final release process.

    If you need it, here's a link to the Caching API documentation that shows how to do some of what I discussed. https://docs.unity3d.com/ScriptReference/Caching.html
     
  5. Mordevil

    Mordevil

    Joined:
    Mar 9, 2018
    Posts:
    4
    Hi guys.
    We tried it but went with a simpler option. We set all our groups as Local and Cannot Change Post Release. As we use the updates really to fix issues. The problem is that if we do a local build to device everything works fine but if we use the same build trough the GooglePlayStore all addressable assets load really slowly. And they are still bundled with the app. (nothing downloads additionally). They just load really slow. We tried not using compression on the groups but the problem persists. Any ideas for a fix.

    Thanks for the help.
     
  6. pillakirsten

    pillakirsten

    Unity Technologies

    Joined:
    May 22, 2019
    Posts:
    346
    Hi I know there is a "Use Unity Web Request For Local Bundles" option (added in Addressables 1.18.2) that might be able to improve the download speed. It's listed when viewing a group in the Inspector under Content Packing & Loading > Advanced.

    Otherwise I would suggest using the Profiler to see what specifically is taking so long to load.

    Also I based on the screenshot, I think you might be using an older version of Addressables. What Addressables/Unity version are you on? If possible you could try upgrading to the latest version.
     
    Last edited: Jun 4, 2021
  7. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    863
    The problem with the latest version (currently 1.18.4) is that all prefabs instantiated using InstantiateAsync will receive all Awake, Start etc calls twice and the game most likely will be broken. So in this case I recommend you to wait until 1.18.5 will be released.
     
  8. exoter

    exoter

    Joined:
    Apr 25, 2015
    Posts:
    10

    We can't profile it because it happens only after it is downloaded directly from Google Play.
    If we do a build & deploy on device everything works like a charm but if we deploy the same build to google play all addressables are loaded super slow. It looks like they are sync loaded - every addressables waits for the previous to load and show up. I guess it is something related with the .aab file we are using but so far we can't find a solution - we tried all settings we could think of
     
  9. pillakirsten

    pillakirsten

    Unity Technologies

    Joined:
    May 22, 2019
    Posts:
    346
    Hmm I see, it could be related to how your bundles are being setup/loaded. It's hard to tell without knowing the specific project setup. The best way for us to debug is to submit a bug report with the smallest repro case possible -- if you can pinpoint which bundles/assets are taking a long time to load that would help.

    I know we are working on integrating Addressables with android app bundles. Hopefully we will have some best practices/docs available within the coming months.