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.

How to fetch latest catalog and re-initialize Addressables in runtime?

Discussion in 'Addressables' started by Kichang-Kim, Aug 7, 2018.

  1. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    819
    Hi. Is there any API for force refreshing the catalog to retreive latest assets from remote server?

    Here is detail:

    In mobile environment, users somtimes leave their device for a long time while game app is runnig on background. So when they re-activate game app, its local catalog cache may be different to server's latest asset on CDN. In this case, game app needs to detect asset catalog change and re-download catalog and assets.

    Also if above API is available, what happened when the asset which is loaded to memory is updateted on server? should I manually release all assets and re-load it manually?
     
    amaike likes this.
  2. unity_bill

    unity_bill

    Unity Technologies

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    In theory you could look through our initialization code and cobble together something that would do this, but I wouldn't recommend it for anyone other than very advanced users. Dealing with all the ref-counting, loaded or not loaded assets, and loaded or not loaded catalogs gets fairly complicated.
    We are aware that this situation happens, but haven't spent much time on it yet. Odds are the general use case will have to involve relaunching the app, but that has more to do with how the user manages their data.

    -Bill
     
  3. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    819
    @unity_bill
    Thanks for reply. I think Addressables needs two API at least for production environment, because this situation quite happens in the mobile game.

    1. Catalog hash check : Check whether local catalog hash and remote catalog hash are same. Using this API, app can show dialog like "Game data is changed, You need to re-launch app.". or if restart API is available (see below), "Game data is updated, app will be restarted automatically." by using that API and changing current scene to first scene.

    2. Restart Addressables, including unload all loaded assetbundles and clear all reference count to zero. (also clear all internal object pools) : This needs because Unity does not provide app re-launching feature.

    With these features, I can move my in-house asset management system to Addressables :)
     
    Most_Incredible and amaike like this.
  4. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    819
    @unity_bill
    Hi, is there any information about this features? I checked latest (0.3.5) Addressables's source code then found that this features can be implemented by adding force-refreshing flag to Addressables.Initialize().

    From
    Code (CSharp):
    1. public static IAsyncOperation<IResourceLocator> Initialize()
    2. {
    3.     if (s_initializationOperation != null)
    4.         return s_initializationOperation;
    5.  
    6.     ...
    7. }
    To
    Code (CSharp):
    1. public static IAsyncOperation<IResourceLocator> Initialize(bool forceRefresh = false)
    2. {
    3.     if (s_initializationOperation != null && !forceRefresh)
    4.         return s_initializationOperation;
    5.  
    6.     ...
    7. }
    Of course, other event-registrations should be carefully handled, like

    SceneManager.sceneUnloaded += OnSceneUnloaded;


    By allowing this API, developer can handle runtime-changed assets without restarting application. Dealing with ref-count, loading assets and internal running operations is doesn't matter because the purpose of this method is re-initialization, so simply destroying all internal state (ref count, assets, catalogue and operations ...) is enough.

    Also, catalog hash check can be implemented by comparing remote-hash (catalog_XXXX.hash on server) and local hash. Although this can be implemented by developer, officailly supported API needed because that internal Addressables's implementations can be changed in future.

    Thanks.
     
    Atlantiss and amaike like this.
  5. unity_bill

    unity_bill

    Unity Technologies

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    No update on this yet. You are correct that the `forceRefresh` flag could trigger a new initialization, but just doing that will cause all sorts of issues if the game has already started loading things. This is not a straightforward feature to create, but I agree that it is useful, and is on our list.
     
  6. AceEX7

    AceEX7

    Joined:
    Feb 2, 2014
    Posts:
    11
    @unity_bill any updates about fetching the latest catalog at runtime?
     
    ohthepain likes this.
  7. yoshitaka-arishima

    yoshitaka-arishima

    Joined:
    Jul 8, 2019
    Posts:
    5
    Our mobile game project also needs these APIs. Without these APIs, we cannot use Addressables.
    We want you to implement these APIs as soon as possible.
     
    ohthepain, mikito-wp and amaike like this.
  8. unity_bill

    unity_bill

    Unity Technologies

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    Number one should be fairly straightforward for you to add yourself. You can just trigger a download of the remote hash.

    Number two is a bit tougher. Still doable in your own code, but this is the larger task we are looking at ways to solve ourselves.

    In the interim, I definitely encourage you to tweak addressables to meet your needs. This tool will often not solve all problems for a large game without some small tweaks. For large production games, addressables will often be a framework that devs can build customization on top of.
     
    AlexandreDelan and amaike like this.
  9. amaike

    amaike

    Joined:
    Mar 6, 2014
    Posts:
    8


    I am suffering from the same problem. I strongly hope that the APIs will be implemented.
     
    mikito-wp likes this.
  10. mikito-wp

    mikito-wp

    Joined:
    Nov 15, 2018
    Posts:
    1
    Without the re-initialization API, I think it is impossible that adopt Addressables in most mobile gaming projects using remote assets...

    It ’s a very important feature.

    I think if there is no problem with destructive re-initialization if the developer manages the timing tightly.
     
  11. GfoxBackflip

    GfoxBackflip

    Joined:
    Aug 28, 2017
    Posts:
    2
    @unity_bill Any news on either of these features? The ability to reinitialize addressables and potentially retrieve a new remote catalog without restarting the game is an incredibly important feature for all our mobile products.

    We managed this when we wrote our own asset management around asset bundles but we've moved over to addressables for newer products and now have no ability to push new content to someone who keeps their app running. Telling the user to restart the game is an unacceptable solution.
     
  12. unity_bill

    unity_bill

    Unity Technologies

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    Totally missed adding this to the changelog (oops!) but we did add two APIs for this scenario to 1.3.3 - CheckForCatalogUpdates() and UpdateCatalogs().

    They don't reinitialize things, but they'll allow you to update catalogs mid-run.
     
    mikito-wp and Favo-Yang like this.
  13. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    819
    Thanks for implementing this features! I have some questions about this:
    1. When the remote catalog is updated, will GetDownloadSizeAsync() and DownloadDependenciesAsync() perform to only changed assetbundles properly?
    2. What happen if already loaded/used assetbundles are changed in remote catalog at runtime?
     
  14. yinyuewei

    yinyuewei

    Joined:
    Aug 16, 2018
    Posts:
    5
    how to use it? i used this code:
    var check = Addressables.CheckForCatalogUpdates(false);
    yield return check;
    Debug.Log(check.Result);

    but the Result has always zero-count item
     
    Last edited: Dec 4, 2019
  15. LudwigVRtualX

    LudwigVRtualX

    Joined:
    Oct 15, 2018
    Posts:
    8
    I would also appreciate a code example for this.
    EDIT: It might always be an empty list because the catalog that is used in the unity editor play mode always gets updated when building a new remote catalog.
     
    Last edited: Dec 5, 2019
  16. DrunkenMastah

    DrunkenMastah

    Joined:
    Sep 26, 2017
    Posts:
    33
    @unity_bill Please provide an example of this API. "CheckForCatalogUpdates"
    In general it is a good idea to just assume that everyone using any API will need an example to work with.
    Ps: On a Side note 1.5.0 of addressables documentation still mentions "Static Content" which is nowhere to be seen in the AddressableAssetSettings since the renaming of that field to "Can be changed / Cannot be Changed". Please update as it is causing confusion.
     
    faolad and phobos2077 like this.
  17. Atlantiss

    Atlantiss

    Joined:
    Aug 5, 2018
    Posts:
    14
    Any workaround to reinitialize addressables during runtime?
     
    faolad likes this.
  18. faolad

    faolad

    Joined:
    Jan 27, 2013
    Posts:
    118
    I will also like an example of how this works
     
  19. DrunkenMastah

    DrunkenMastah

    Joined:
    Sep 26, 2017
    Posts:
    33
    Bump. @unity_bill Please respond. Still stuck on this. Would appreciate any help.
     
    TigerHix and faolad like this.
  20. duartedd

    duartedd

    Joined:
    Aug 1, 2017
    Posts:
    148
    okay just trying to understand those 2 calls - checkfor catalogupdates and updatecatalog---


    Addressables.InitializeAsync().Completed += objects =>
    {
    Addressables.CheckForCatalogUpdates().Completed += updates =>
    Load(LabelsToDownload);
    };

    here is something that i have - What i am trying to do is to check for updates and then update if there is an update after the checkforcatalogupdates is checked it loadsassetsasyncs the addressables

    the good - all of it is working but havent tested out after i update existing build - but it checks for catalog updates but does it actually update the catalog?

    like am i supposed to initializeasync - > CheckForCatalogUpdates -> loadassetasync

    or
    initializeasync -> checkforcatalogupdates> if something true??? catalogupdate() -> loadassetasync ?

    or do i initializeasync -> catalogupdate() (it will automatically check and download the catalog???) -> -> loadassetasync

    this catalog the method is referring to is that the bundles or something else - where would they be located and how is that updated?

    for instance right now i have 7 asset packs which become .bundle s ( nothing else) - i put those in the remote server and voila they download but what about the bin file - how does build get a hold of the bin to say i need to update the assets ??? does checkcatalogupdates check to see if that bin file exists in the 'remote path' path or something?

    thanks for reading while I rant in wonder.
     
    faolad likes this.
  21. duartedd

    duartedd

    Joined:
    Aug 1, 2017
    Posts:
    148
    okay its working no issues

    step 1: check build remote content update - set the build and load path - i set to them to my remote paths

    build normal like its your first

    then make a change to an asset

    update existing build -selected the addressable content bin file

    i just uploaded all the files to the web serveer and change worked
    Addressables.InitializeAsync().Completed += objects =>
    {
    Addressables.CheckForCatalogUpdates().Completed += checkforupdates =>
    {
    if ( checkforupdates.Result.Count > 0)
    Addressables.UpdateCatalogs().Completed += updates => Load(LabelsToDownload);
    else
    Load(LabelsToDownload);
    };
    };

    note i used the default timestamp method cause that works for me and trying to keep things simple
     
  22. duartedd

    duartedd

    Joined:
    Aug 1, 2017
    Posts:
    148
    one more thing i am going to do is try to actually do the custom version instead of timestamp method instead see where that goes ...reason being is i wanted a way to get the old build to check if a new build needs to be fully downloaded - i think with a good numbering scheme i can program it in such a way to do this for me - for instance if the 1.02 and 1.03 are just patches and then from 1.03 to 2.00 would direct the player to download a new build from website or w.e

    I was going to just add a text file and read the build version from the asset but this gets around me having to download the assetpack and such first...will let you know what i get back and the code if i get it working!
     
    stevenchristian20 likes this.
  23. duartedd

    duartedd

    Joined:
    Aug 1, 2017
    Posts:
    148
    k so nope i misunderstood it and how it works i guess or should work ???? the version creates the name of the file with the name instead of the timestamp and when i update content it doesn't actually change the name of the file even no matter how many updates - stays 1.01 even though i change the override in the settings to 1.02 and stuff so that only gets used upon the first build creation i guess. Not sure if thats a bug or if that is just how they made it ... or maybe unity just hasnt implemented it fully yet
     
    stevenchristian20 likes this.
  24. duartedd

    duartedd

    Joined:
    Aug 1, 2017
    Posts:
    148
    FYI updated to 1.6.2 just to see if its something they worked on since 1.5 ( which was what i was on ) ...same thing - and my build doesnt read the new content build if i change it to 2.0 just in case that was their plan for that

    New thought though
    if i just delete the catalog files from the remote path and it cant find them i can prompt /redirect the player to download the new build
     
  25. virendra_bhoriwal

    virendra_bhoriwal

    Joined:
    Oct 25, 2018
    Posts:
    14
    @duartedd
    is this really working ? as I am also going through the same situation regarding how to get updates remotely. Could you please guide me....
     
    faolad likes this.
  26. faolad

    faolad

    Joined:
    Jan 27, 2013
    Posts:
    118
    Do you have "Disable Catalog Update on Startup" enable, in AddressableAssetSettings/Catalog?
     
  27. duartedd

    duartedd

    Joined:
    Aug 1, 2017
    Posts:
    148
    that is unchecked - i would assume if that is checked then it wont check the for updates and therefore will not update my assets regardless if there are changes...the issue was and is that when buiilding it grabs that timestamp (or player version override) file and it will use that name to check for updates looking for updates - it continues to use THAT name regardless of what other name you put in player version override - it will NOT create a new timestamp it will use the existing one (of course this is for use existing build) - for new builds it will create a new one and the old will be made obselete. Anyways pretty sure this is how it works from my testing.

    hope this helps!
     
    djalpen24, Voxel-Busters and faolad like this.
  28. Most_Incredible

    Most_Incredible

    Joined:
    Jan 25, 2012
    Posts:
    36
    Any update on this feature , we are currently exploring this feature.
     
  29. mrekuc

    mrekuc

    Joined:
    Apr 17, 2009
    Posts:
    116
    I was having issues with loading one catalog and then tryng to load another catalog depending on what content they picked form a list within the same runtime. Even tho I had a variable set to my remote path as {AddressableURL.remoteLoadPathUrl}[BuildTarget] it would always give me an error because it woul dtry and reload the next catalog with the previous cached path.

    I set AddressableURL.remoteLoadPathUrl equal something easy like "replaceme" for the remote load path.
    Then before I get the download size or Donwload any dependencies i use the following method and the variables that create the path to my asset bundles.

    Code (CSharp):
    1.  
    2. private string TransformFunc(IResourceLocation location)
    3. {
    4.             if (location.ResourceType == typeof(IAssetBundleResource) && location.InternalId.StartsWith("replace"))
    5.             {
    6.                 string remove = location.InternalId.Replace("replaceme", "");
    7.                 Debug.Log(remove);
    8.                 return "https://" + storageAccount + "." + baseUrl + container + "/" + remove + sharedKey;
    9.             }
    10.             return location.InternalId;
    11. }
    Its a hack for sure but it works for me! Hope it helps someone else using multiple catalogs.
     
  30. HEROTECH70

    HEROTECH70

    Joined:
    May 24, 2017
    Posts:
    74
    I find it appalling that a Unity Dev just stops replying to this thread even though people are clearly still struggling with this. And this system is not working, I am making modifications to the catalog and the uploaded assets yet the update catalogue returns 0 changes.
     
    JGameMaker92 likes this.
  31. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    711
    Hey all, I'm still getting caught up on everything but I want to point anyone still having issues towards some documentation we have.

    The Content Update Workflow:
    https://docs.unity3d.com/Packages/c...ateWorkflow.html#planning-for-content-updates

    An "Extended API Doc" for UpdateCatalogs
    https://docs.unity3d.com/Packages/com.unity.addressables@1.18/manual/UpdateCatalogs.html

    As far as loading secondary catalogs, one thing I'd watch for is having a .hash file next to the secondary catalog. If you update the catalog and not the hash file then Addressables will continue to use the cached version. If you always want the catalog to be downloaded regardless, you should be able to remove that hash file. If it can't find a hash file the system assumes it isn't cached and downloaded the catalog anew.

    @mrekuc that's... interesting. I don't know that I have anything concrete to give you for advice. We have the TransformInternalId func exposed to help when you need to create, or otherwise alter, the url with some custom logic so if that works for you then that's probably fine. Something that came to mind is you could have basically 3 catalogs.
    Catalog 1:
    - your main catalog, this initializes only the most basic of assets.
    Catalog 2:
    - A catalog containing the assets if they choose option 1
    Catalog 3:
    - A catalog containing the assets if they choose option 2
    I feel like I'm not fully understanding your situation so this might not be remotely plausible for you. Especially given that once a catalog is loaded it cannot be unloaded.

    I hope this, or the docs, is at least somewhat helpful
     
  32. FelixFrank

    FelixFrank

    Joined:
    Feb 25, 2021
    Posts:
    3
    Hey all, I think I finally found the correct thread for my question since this topic is bothering me for days now.

    First of all: in my mobile app I only work with addressable scenes as I am using them as containers for my changing content. I did not get the addressables to work as wanted so far.

    In my project the user can choose from multiple scenes to open/download:

    First time user opens app: user can download scene A. The downloaded scene will be stored in app cache.

    Next time user opens app: app checks for remote catalog changes:

    Code (CSharp):
    1. public void CheckForUpdate()
    2.     {
    3.         Addressables.CheckForCatalogUpdates().Completed += (_updates) =>
    4.         {
    5.             if(_updates.Status == AsyncOperationStatus.Failed)
    6.             {
    7.                 Debug.LogWarning("Fetch failed!");
    8.             }
    9.  
    10.             if (_updates.Result.Count > 0)
    11.             {
    12.                 Debug.Log("Available Update:");
    13.                 foreach(var update in _updates.Result)
    14.                 {
    15.                     Debug.Log(update);
    16.                 }
    17.                 // proceed with downloading new content
    18.             }
    19.             else
    20.             {
    21.                 Debug.LogError("No Available Update");
    22.                 // proceed with loading from cache
    23.             }
    24.         };
    25.     }
    If no update is available the app loads the scene from cache. The first
    Code (CSharp):
    1. CheckForCatalogUpdates()
    results in a changing "AddressablesMainContentCatalog" (from if (_updates.Result.Count > 0). Seems okay to me since it is the first time I load the app.

    Problem 1:
    When I close/shutdown the app on the device (completely) and restart it,
    Code (CSharp):
    1. CheckForCatalogUpdates()
    STILL give me a changing "AddressablesMainContentCatalog", even if I did not change anything. That should not be the case right? Or am I missing out on something?

    Problem 2:

    As I update my scene tree (move things around in hirachy, rename nodes, enable/disable gameobjects) I update the existing content in my RemoteBuildPath via "Update A Previous Build" in the Addressables Groups windows and copy the content to my remote (Google Storage).

    The next time I (completely) restart the app I would assume _updates.Result.Count to be > 0. This is never the case. (Debug.LogError("No Available Update"))
    Shouldn't I get a new hash this way which is internally compared with the cached catalog's hash resulting in "updated content"?

    Thank you all for your information so far! This system is very interesting and I think that it will be even more interesting in the future, so I want to be prepared.

    EDIT: So I tried something else: I build two version of my scene. One has hashA and the other has hashB. I uploaded the content with hashA to the server and downloaded it to my app. Then I updated the remote content to hashB-version. Than I clear the cache (deleting all the old catalog files). After this CheckForCatalogUpdates() returns "AddressablesMainContentCatalog" to be outdated again. This makes sense. But if I fetch the remote catalog via UpdateCatalogs() it gives me the hashA-version again. Shouldn't it be the hashB-version now?
     
    Last edited: Oct 29, 2021
  33. FelixFrank

    FelixFrank

    Joined:
    Feb 25, 2021
    Posts:
    3
    Also i found out that my content is never updated on my mobile device. Am I doing something wrong?

    My Steps:
    - Building App
    - Building Addressables with content A (New Build)
    - Uploading Addressables with content A to Google Cloud Storage
    - Installing App
    - Testing App (content is downloaded correctly => content A is shown)
    - Modifying Addressables to content B (Update previous Build)
    - Deleting content A on Google Cloud Storage
    - Uploading Addressables with content B to Google Cloud Storage
    - Testing App (content is not downloaded => content A is shown)

    My code:

    AddressablesManager: used to initialize Addressables and invoking UnityEvent which enables further steps.
    Code (CSharp):
    1. private void Start()
    2.     {
    3.         Addressables.InitializeAsync().Completed += onInitializedCompleted;
    4.     }
    5.  
    6.     private void onInitializedCompleted(AsyncOperationHandle<IResourceLocator> _handle)
    7.     {
    8.         if(_handle.Status == AsyncOperationStatus.Failed)
    9.         {
    10.             Debug.LogError("could not initialize Addressables! Error: " + _handle.OperationException.ToString());
    11.             return;
    12.         }
    13.  
    14.         Debug.Log("initialized Addressables!");
    15.         m_AddressablesManagerInitialized.Invoke();
    16.     }
    SceneLoader: activates and deactivates button depending on content availability or possible updates. Downloads catalogs, updates content, activates scene.
    Code (CSharp):
    1. private void onAddressablesManagerInitialized()
    2.     {
    3.         m_AddressablesManagerCompleted = true;
    4.         m_DownloadSceneButton.SetEnabled(true);
    5.     }
    Fired by clicking on a debug button:
    Code (CSharp):
    1. public void CheckForUpdate()
    2.     {
    3.         Addressables.CheckForCatalogUpdates().Completed += (_updates) =>
    4.         {
    5.             if(_updates.Status == AsyncOperationStatus.Failed)
    6.             {
    7.                 Logger.LogWarning("Fetch failed!");
    8.             }
    9.  
    10.             if (_updates.Result.Count > 0)
    11.             {
    12.                 Logger.LogPass("Available Update:");
    13.                 foreach(var update in _updates.Result)
    14.                 {
    15.                     Logger.Log(update);
    16.                 }
    17.             }
    18.             else
    19.             {
    20.                 Logger.LogError("No Available Update");
    21.             }
    22.         };
    23.     }
    Also fired by clicking on another debug button:
    Code (CSharp):
    1. public void UpdateCatalog()
    2.     {
    3.         Addressables.UpdateCatalogs().Completed += (update) =>
    4.         {
    5.             foreach(var thing in update.Result)
    6.             {
    7.                 foreach(var key in thing.Keys)
    8.                 {
    9.  
    10.                     Logger.Log("key: " + key);
    11.                 }
    12.             }
    13.         };
    14.     }
    Fired when download button got clicked:
    Code (CSharp):
    1. private void onDownloadButtonClicked()
    2.     {
    3.         if(SceneManager.GetSceneByName(m_SceneName).IsValid())
    4.         {
    5.             Debug.LogWarning("Download started while already downloaded!");
    6.             return;
    7.         }
    8.  
    9.         if(!m_AddressablesManagerCompleted)
    10.         {
    11.             Debug.LogError("AddressablesManager not initialized yet!");
    12.             return;
    13.         }
    14.  
    15.         Debug.Log("started...");
    16.         m_AsyncOperationHandle = Addressables.LoadSceneAsync(m_SceneName, LoadSceneMode.Single, false);
    17.         m_AsyncOperationHandle.Completed += onSceneDownloaded;
    18.         m_IsDownloading = true;
    19.     }
    When scene is downloaded completly:
    Code (CSharp):
    1. private void onSceneDownloaded(AsyncOperationHandle<SceneInstance> _handle)
    2.     {
    3.         if(!_handle.IsDone)
    4.         {
    5.             Debug.LogWarning("Accidentally called onSceneDownloaded, task not done yet!");
    6.             m_IsDownloading = false;
    7.             return;
    8.         }
    9.  
    10.         if(_handle.Status == AsyncOperationStatus.Failed)
    11.         {
    12.             Debug.LogError("download failed! Error: " + _handle.OperationException.ToString());
    13.             m_IsDownloading = false;
    14.             return;
    15.         }
    16.  
    17.         Debug.Log("finished!");
    18.         m_IsDownloading = false;
    19.         m_LoadedScene = _handle.Result;
    20.  
    21.         m_SceneReadyEvent.Invoke();
    22.     }
    Fired when clicking scene button:
    Code (CSharp):
    1. private void onSceneButtonClicked()
    2.     {
    3.         if(m_LoadedScene.Scene == null)
    4.         {
    5.             Debug.LogError("no scene to load, something went wrong!");
    6.             return;
    7.         }
    8.  
    9.         m_LoadedScene.ActivateAsync();
    10.     }
    To better visualize what is actually happening I uploaded an image of my app. The "Test scene for fetch" is my scene button (deactivated when starting app), the small cloud is my download button.


    Thanks for your help in advance!
     

    Attached Files:

    hung_pv likes this.
  34. hung_pv

    hung_pv

    Joined:
    Jul 19, 2018
    Posts:
    7
    Hi @FelixFrank,
    I am facing the same problem with CheckForUpdate.
    Do you have a new solution?
    Thank you!
     
  35. hung_pv

    hung_pv

    Joined:
    Jul 19, 2018
    Posts:
    7
    No comments from anyone at Unity?
     
  36. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    711
    Hey @FelixFrank and @phamhung_99 The first question I'd ask is if you're uploading the newly created catalog and the new catalogs .hash file alongside the new AssetBundles from build B. You mention uploading the new content so I'm not sure what all that entails. If you're not uploading the new .hash file, that could likely be your issue. We don't look at the new remote catalog and calculate a hash based on the json file, we build that hash to the .hash file and then read that for the comparison (you may already know this, I'm just explaining in case you, or others, don't). I bring this up as the likely culprit because your code otherwise looks fine at first glance.
     
  37. hung_pv

    hung_pv

    Joined:
    Jul 19, 2018
    Posts:
    7
    Hi @davidla_unity, thanks for the reply.
    When I run tool Update a previous build, Addressable system generates new .bundle file and override .hash file and .json file.
    I upload all files to Google cloud, but it does not work, I call Addressables.CheckForCatalogUpdates and receive Result.Count = 0, old bundle is still loaded.
    Could you give me a video tutorial?
    Thank you!
     
  38. wesmag

    wesmag

    Joined:
    Mar 25, 2020
    Posts:
    34
    Hello, we also appeared to observe this behaviour recently. It appeared that the we would grab the updated .hash file from the remote, but skip this *.bundle file during catalog update process. This, we believed, was initially due to a server caching problem. But upon reboots of the game it would not grab the *.bundle file once the hash file had already been retrieved.

    I'd post my code, but it is relatively similar to the functionalities already posted here. And, mostly based on the sample code provided.

    Also, we rolled back from latest Addressables 1.19.18 to 1.18.19 and now everything appears to be working fine. The bundle is retrieved no problems.

    I did most of my testing in Editor as this was most expedient, and I could observer what hash and bundle file was cached to the relevant directories, so this behaviour was easy to observe. @davidla_unity

    I can also confirm we uploaded everything: new catalog, new hash and the new bundle file.

    Unity Version: 2019.4.32f1
    Addressables: 1.19.18
     
    Last edited: Mar 1, 2022
  39. unity_shane

    unity_shane

    Unity Technologies

    Joined:
    Jun 3, 2021
    Posts:
    67
    @wesmag, the fact that rolling back lead to the issue being fixed points to this being a bug we're not aware of. Would it be possible for you to create a bug report for this issue if you're still experiencing it on 1.19.18? It appears like a lot of people are running into similar issues with content update but without a project that reproduces the issue its quite difficult for us to get to the root of the issue.
     
  40. wesmag

    wesmag

    Joined:
    Mar 25, 2020
    Posts:
    34
    Hi @unity_shane I actually spent the past couple days looking into a similar/related problem. Using 1.19.19 the problem we are observing is this.
    • Create a "Can Update Post Release" package for remote deployment. (v1)
      • Test in editor, downloads package immediately.
    • Create update: v1.1. Will download eventually. We are just assuming this is due to CDN propagation time.
      • Client now has v1.1
    • Create update: v1.2
      • Eventually, this update will be fetched. But, completely subjectively, feels like it takes longer than the second update.
    • Continue testing app in Editor. Eventually, it will move back to v1 or v1.1. We do this by outputting a version number we bake into the package at build time.
    We've tried both disabling automatic updates on startup, and running our own catalog update code at startup, including downloading dependencies. It doesn't seem to matter. I'm currently suspecting a caching issue in the Unity/Addressables side.
     
  41. wesmag

    wesmag

    Joined:
    Mar 25, 2020
    Posts:
    34
    @unity_shane I've now observed this behaviour on 1.18.19, sadly. Will look into a bug report. But not sure what I can do about a test project, this is purely on a project fetching from a remote (so far...)

    EDIT:

    One thing I have noticed is that the addressables cache will often have the latest .hash file, but not the latest .json catalog file. This will often point to the last version. I assume if we already have the latest .hash file, then there's no reason for Unity to attempt to download the lates .json file again?
     
    Last edited: Mar 21, 2022
  42. wesmag

    wesmag

    Joined:
    Mar 25, 2020
    Posts:
    34
    @unity_shane @unity_bill how are cache references from hash files resolved to .json catalog files? Via timestamp? I ask as I can't see any reference to the catalog file in the hash contents. Though I do see a reference to the latest bundle in the catalog file. I ask as I often seem to have the correct .hash file (after updating the remote) but there seems to either be a large lag on updating the catalog, or, it is not updated at all. There appears to be some brittleness here, and I suspect the hash file is getting cached and it is then assumed that the catalog file is updated?
     
  43. wesmag

    wesmag

    Joined:
    Mar 25, 2020
    Posts:
    34
    I updated to 2020.3.26f1 and this seemed to solve the "version reversion" problem I was observing. However now, sometimes, it simply refuses to grab the latest catalog file.

    See screenshot of ADDRESSABLES_LOG_ALL output. It appears the Editor already has the correct hash (I checked the specified location in Library folder). And as the log says, the hashes are the same.

    However, checking the catalog file at the same location as the hash is not the latest version, as the (one) bundle file we're using is the old version that it is referencing. It appears I have the latest hash, but not the latest catalog. However, I find the reference in the logs to the catalog under the ProjectDir/Library folder confusing. Should it not retrieve the catalog from the same location as the .hash?

    Either way, the latest catalog file should be referencing the bundle: generated_assets_all_ab74de3e98bca89446f9522da6755e9b.bundle instead we have generated_assets_all_4af9dd67539fdbaf1da2b7e13534b8fd.bundle being referenced. But with the latest hash. I can see this bundle in the cache path. See images.

    For the time being, in editor anyway, seems we're stuck on this version unless we do a clean build.

    Screenshot 2022-03-22 at 17.06.00.png Screenshot 2022-03-22 at 17.23.13.png
     
  44. wesmag

    wesmag

    Joined:
    Mar 25, 2020
    Posts:
    34
    Can confirm that manually clearing both the .hash and .json file and the bundle cache will force an update to the latest uploaded version. @unity_shane
     
  45. wesmag

    wesmag

    Joined:
    Mar 25, 2020
    Posts:
    34
  46. hung_pv

    hung_pv

    Joined:
    Jul 19, 2018
    Posts:
    7
    Hi,
    Talking about UpdateCatalog, my problem have resolved.
    When I use a local server to store resource and download it, everything works normally.
    But when I use Google Cloud to store resources, I update new content to Google Cloud and I must wait 5-10 minutes for Google Cloud to resolve it (I think so). After this time, I can download new content from Google Cloud normally.
    Hope it helps!
     
  47. wesmag

    wesmag

    Joined:
    Mar 25, 2020
    Posts:
    34
    Thanks @phamhung_99 what happens if you do not wait the 5-10 minutes? Do you have similar issues? We're also using Google Cloud.
     
  48. hung_pv

    hung_pv

    Joined:
    Jul 19, 2018
    Posts:
    7
    Hi @wesmag,
    In my case, if I don't wait 5-10 minutes, I don't get new content from Google Cloud, UpdateCatalog API will respond that there is no content to update.
     
    wesmag likes this.
  49. JGameMaker92

    JGameMaker92

    Joined:
    Oct 15, 2014
    Posts:
    40
    I’m having trouble loading catalog updates in Unity 2022 building for iOS. They said it was supposed to do it all automagically when I call Addressables.InitializeAsync() on Start but that’s not happening and my game is still only loading cached bundles no matter how many updates I’ve released on CDD.
     
unityunity