Search Unity

Question how to update bundles without restart the app

Discussion in 'Addressables' started by elfasito, Oct 21, 2020.

  1. elfasito

    elfasito

    Joined:
    Jul 4, 2017
    Posts:
    51
    Hello people.
    im pretty new in unity and addressables system.

    I have everything working almost perfectly, except with a problem managing my bundles updates (addressables).
    Im work with persist cache to use my app in offline mode.
    Basic scenario:
    1- download scenes from remote adressables (downloaded individually).
    2- if is offline>load addressables from cache. (previously downloaded)
    3-if is online>check if a catalog update exist and update it. (this check are made when I try to open a new scene.

    my problem is: I cant load/get my bundles updates without restart the app.

    I tried this:

    Code (CSharp):
    1. public void CheckRemoteCatalog()
    2.     {    
    3.             Addressables.CheckForCatalogUpdates().Completed += checkforupdates =>
    4.             {
    5.                 if (checkforupdates.Result.Count > 0)
    6.                 {              
    7.                     Addressables.Release(AddressableSceneToLoad);
    8.                     Addressables.ClearDependencyCacheAsync(AddressableSceneToLoad);
    9.  
    10.                     Addressables.UpdateCatalogs().Completed += updates =>
    11.                     Debug.Log("new bundles exist in server");                
    12.                 }
    13.  
    14.                 else
    15.                 {
    16.                     PressButtonLoadScene(); //this function download/load remote scenes
    17.                     Debug.Log("Nothing to update");
    18.                 }                            
    19.             };
    20.     }
    works partially,.
    I used:
    Code (CSharp):
    1. Addressables.ClearDependencyCacheAsync(AddressableSceneToLoad);
    to clear addressable cache, works but need to restart the app to take effect.

    I think if I can delete the old bundle cache before to try to load the new one, I can access to it without restart the app, is right?.

    PD: Currently I can download the new bundle update without restart the app, but I cant load it.

    I dont get any errors after update the catalog. (adb logcat)
    as you can see, im lost as how I can solve this problem. if someone can give me some guidance, I appreciat
     
    Last edited: Oct 23, 2020
    arufolo-wellovate, joeBPS and BPSRyan like this.
  2. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,820
    I'll ping the team and see if they have some guidance to share. Which version of Addressables are you using?
     
  3. elfasito

    elfasito

    Joined:
    Jul 4, 2017
    Posts:
    51
    Hello Trey.
    Im using the version 1.16.6.
    I made a change settings in unity addressables: before i used just the filename of the bundle in the addressable setting "bundle naming", so when I made a bundle update, it keeps the same name.
    now I changed the option to: "append hash to filename", with this when I do a build update it always get a new filename.
    with this change, now I can load the remote scenes without restart the app after getting a catalog update.

    the problem of this (I think), is what the old bundle cache keeps in the memory(disk).
    not sure about this, I'm going to do some more corroborations.

    UPDATE 1: ok, I changed the "Player Version Override" to 1, in addressable asset settings.
    with this, catalog always keeps the same name and now is downloading the new remote scenes without build and update the app.
    but another problem showed up, I cant access to new remote bundles in offline mode (previously cached), it load the old cached version of the bundle.

    UPDATE 2: in offline mode, snooping with logcat, I see that the app tries to load the old filename scene hash (the one generated when I updated the app). so if it yet exist in cache, is loaded.
    if the app is online, it just load the new content normally.
    Is like if the catalog in remote server not replace/update the catalog builded with the app.
     
    Last edited: Oct 26, 2020
  4. elfasito

    elfasito

    Joined:
    Jul 4, 2017
    Posts:
    51
    bump.
    Im still stuck with this issue with the cache when I run in offline mode.
    I think my problem with offline mode is:
    1-fails to get the catalog from server (obviously).
    2-so proceed to use the local catalog generated with my app build.

    Is there a way to overwrite the catalog generated in build?, without need of update the app.

    EDIT: ok solved thanks to @jiahongzeng reply in old thread:
    https://forum.unity.com/threads/can-not-update-bundle-on-mobile.771455/

    just edit settings.json like says in that thread, and now in offline mode load the catalog from the correct path.
     
    Last edited: Oct 26, 2020
    FlightOfOne likes this.
  5. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,820
    Happy to hear you were able to get it sorted!
     
    elfasito likes this.
  6. elfasito

    elfasito

    Joined:
    Jul 4, 2017
    Posts:
    51
    a question related to the editing settings.json
    exist in unity inspector some configuration/var to edit the corresponding path in settings.json?
    Code (CSharp):
    1. "m_Keys":["AddressablesMainContentCatalog"],"m_InternalId":"{[B]UnityEngine.AddressableAssets.Addressables.RuntimePath}/catalog.json[/B]"
    just for practicality.