Search Unity

Handling network disconnect during asset download

Discussion in 'Addressables' started by AniketShark, Sep 17, 2019.

  1. AniketShark

    AniketShark

    Joined:
    Sep 22, 2012
    Posts:
    2
    Hey @unity_bill,
    I am using addressable system in my game.
    I download the content in splash scene before my game scene is loaded.
    The problem is if you lose connection during the content download phase
    The addressable system is not able to download the remaining content once connection is back to normal IN THE SAME SESSION.
    If I close my app and relaunch it. Then it works like a charm.

    I tried to force initialize Addressable to make it work in same game session
    Here is the modified initializeAsync in AddresableImpl.cs

    Code (CSharp):
    1. public AsyncOperationHandle<IResourceLocator> InitializeAsync(bool force = false)
    2. {
    3.             if(force)
    4.             {
    5.                 LogError("***FORCE ReInitializing Addressable System***:" + force);
    6.                 return InitializeAsync(ResolveInternalId(PlayerPrefs.GetString(Addressables.kAddressablesRuntimeDataPath, RuntimePath + "/settings.json")));
    7.             }
    8.             if (!m_InitializationOperation.IsValid())
    9.             {
    10.                 return InitializeAsync(ResolveInternalId(PlayerPrefs.GetString(Addressables.kAddressablesRuntimeDataPath, RuntimePath + "/settings.json")));
    11.             }
    12.             return m_InitializationOperation;
    13. }
    but no luck.

    Here is how I am trying to downloading assets.

    Code (CSharp):
    1. public static void InitializeAddresable(bool force = false)
    2. {
    3.         Debug.LogError("InitializeAddresable : " + force);
    4.         InitializationOperation = Addressables.InitializeAsync(force);
    5. }
    6.  
    7. public static void DownloadFolders(List<string> keys, Action onComplete)
    8. {
    9.     List<object> folders = new List<object>(keys);
    10.  
    11.     CurrentDownloadOperation = Addressables.DownloadDependenciesAsync(folders, Addressables.MergeMode.Union);
    12.     CurrentDownloadOperation.Completed += (AsyncOperationHandle asyncOperation) => {
    13.  
    14.         Debug.LogError(" Download Folders Complete ");
    15.         if (onComplete != null)
    16.         {
    17.             onComplete();
    18.         }
    19.     };
    20. }
    I am using Addressables package Version 1.2.3

    Is there anything that I am missing?
     
  2. Favo-Yang

    Favo-Yang

    Joined:
    Apr 4, 2011
    Posts:
    464
    Sounds a known issue, but my memory is fuzzy. Would you mind search the sub forum for clues?
     
  3. an_drewr_ayist

    an_drewr_ayist

    Joined:
    May 19, 2020
    Posts:
    1
    hey? any news? still experiencing the same problem.
    Tryin to load/instantiate async but have no idea how no handle disconnect because "completed" never happens. IsDone nor Status.Failed both don't work in this case. Version 1.16.1