Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

problems with Addressables while offline

Discussion in 'Addressables' started by JiMMaR, Oct 25, 2018.

  1. JiMMaR

    JiMMaR

    Joined:
    Aug 4, 2012
    Posts:
    12
    I'm facing 2 problems with Addressables when used without an internet connection.

    1 - I have a mobile game with multiple characters to chose from, I have all of the characters as addressables, 3 of those characters are in the local group and the rest are in the remote group.
    Now this problem only happens when the game was installed on a device and was taken offline before starting the game for the first time.
    Loading assets with label fails saying that it fails to fetch the remote group note that I have 3 characters with the same label in the local group but it'd still want to download the remote bundle and throws an exception.
    My understanding would be that the addressables system should ignore any bundle that it doesn't have access to and retrieve everything that it could

    2 - Same game, I've noticed that if the LoadAssets ever failed, it wouldn't work again even if you got internet connection back, i.e:
    Code (CSharp):
    1.  
    2. public void LoadCharacters(){
    3.     Debug.Log("Loading Characters");
    4.     Addressables.LoadAssets<Character>(CHARACTER_LABEL, null).Completed += op =>
    5.     {
    6.         Debug.Log("Assets loaded");
    7.         if (op.Status == AsyncOperationStatus.Failed)
    8.         {
    9.             Debug.Log("Assets loading failed");
    10.         }
    11.         else if (op.Status == AsyncOperationStatus.Succeeded)
    12.         {
    13.             Debug.Log("Assets loading success");
    14.         }
    15.     };
    16. }
    17.  
    I have this stripped down method called LoadCharacter and I call it on a fresh install of the game while the device is offline, the logs shows this:

    Loading Characters
    Assets loaded
    Assets loading failed


    which is what's expected, now in the same session, I go online and call the method again, the logs would show this:

    Loading Characters


    and that's all I'm getting .. it wouldn't call the completed callback

    Am I missing anything ?
     
    AustynPember likes this.
  2. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    HI, thanks for reporting this. It does not seem like you're missing anything, as both of the scenarios you described should just work. So I've logged both of these in our bug tracking system. They seem straightforward for us to reproduce.

    Thanks,
    -Bill
     
  3. netdevo

    netdevo

    Joined:
    Sep 8, 2014
    Posts:
    4
    Hi, we are also experiencing this on our end using
    Addressables.PreloadDependencies
    on version 0.3.5 all the way to 0.4.8.

    Are there any updates or an ETA on a fix for this bug?

    Thanks,
    Leo
     
  4. JanSenseVR

    JanSenseVR

    Joined:
    Aug 31, 2018
    Posts:
    5
    We are still experiencing this in Addressables 1.15.1.

    To be more specific, when the internet connection is lost during Addressables.DownloadDependenciesAsync(sceneRef) we are getting such an error:

    Code (csharp):
    1. 2020-10-14 18:47:54.908 9997-10336/com.sensevr.*** E/Unity: Exception encountered in operation Resource<IAssetBundleResource>(***.bundle) : RemoteAssetBundleProvider unable to load from url https://***.bundle, result='Cannot resolve destination host'.
    2.     UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
    3.     UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    4.     UnityEngine.Logger:Log(LogType, Object)
    5.     UnityEngine.Debug:LogError(Object)
    6.     Program:ResourceManager_ExceptionHandler(AsyncOperationHandle, Exception) (at C:\Unity Projects\***\Assets\Content\Code\Scripts\Program.cs:709)
    7.     UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:set_OperationException(Exception) (at C:\Unity Projects\***\Library\PackageCache\com.unity.addressables@1.15.1\Runtime\ResourceManager\Asyn
    8. // (cropped by logcat)
    9.  
    10.  
    11. 2020-10-14 18:47:54.914 9997-10336/com.sensevr.***E/Unity: Exception encountered in operation Dependencies [***] : RemoteAssetBundleProvider unable to load from url https://******.bundle, result='Cannot resolve destination host'.
    12.     UnityEngine.DebugLogHandler:Internal_Log(LogType, LogOption, String, Object)
    13.     UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    14.     UnityEngine.Logger:Log(LogType, Object)
    15.     UnityEngine.Debug:LogError(Object)
    16.     Program:ResourceManager_ExceptionHandler(AsyncOperationHandle, Exception) (at C:\Unity Projects\***\Assets\Content\Code\Scripts\Program.cs:709)
    17.     UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1:set_OperationException(Exception) (at C:\Unity Projects\***\Library\PackageCache\com.unity.addressables@1.15.1\Runtime\ResourceManager\AsyncOperations\AsyncOperationBase.cs:326)
    18.     UnityEngine.Resour
    19. // (cropped by logcat)
    20.  
    after that, whenever we try to repeat the operation of Addressables.DownloadDependenciesAsync(sceneRef) using the same sceneRef we get "Attempting to use an invalid operation handle" exception.

    Another not cool thing is that the returned handle is still returning true for IsValid() method.

    In effect, when Addressables.DownloadDependenciesAsync(sceneRef) fails due to network issues, the asset becomes unloadable untill the app is fully restarted.
     
    ImpossibleRobert likes this.
  5. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    In general, the problem of a failed operation getting stuck forever was fixed in version 1.1.9 last year.
    > Fixed issue where failed async operations weren't getting released from the async operation cache.

    Sounds like we may now have that issue back specifically for DownloadDependencies. We'll look into it.

    One note on the fact that you posted this 6 weeks ago. We try to stay on top of the forums, but it's really easy for things to slip through the cracks here. If it's a legit bug, please file it through the bug tracker as we can't really miss those.
     
  6. Most_Incredible

    Most_Incredible

    Joined:
    Jan 25, 2012
    Posts:
    36
    Hi ,
    how to catch the exception due to no network connection in addressables. in the console i got the error Exception encountered in operation Resource<IAssetBundleResource>(bundlepath RemoteAssetBundleProvider unable to load from url , is there a way to catch this error so that i can show the user no internet popup screen.

    Thanks
     
  7. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    We have an active to-do to find a good way to return valid info to you. Not done yet, but on the list
     
  8. NicolasBasilGerard

    NicolasBasilGerard

    Joined:
    Nov 3, 2020
    Posts:
    7
    Hello, I am facing a similar issue of needing to handle internet connection loss reliably to display a popup to our users. Any news on it ? Or baring that, would anyone know of a good workaround ?(Application.internetReachability is not reliable enough)
     
  9. JanSenseVR

    JanSenseVR

    Joined:
    Aug 31, 2018
    Posts:
    5
    @NicolasBasilGerard
    What we ended up doing is basically saying "internet issue" whenever addressables fail for whatever reason. We just check the operation handle status and if it's failed, we trigger a popup. Far from ideal, but gives out a clear message to the user.

    EDIT:
    I strongly recommend NOT to use Addressables.DownloadDependenciesAsync function as it seems to cause a bunch of issues (invalid handle, load failing with dependencies exceptions etc). We just load the assets directly without downloading dependencies first.
     
  10. NicolasBasilGerard

    NicolasBasilGerard

    Joined:
    Nov 3, 2020
    Posts:
    7
    I opted for a similar solution for now
    I do use DownloadDependenciesAsync for preloading some things and it seems to behave as expected (I usually release the handle immediately after completion and use a new one to actually load the bundle)
     
  11. andymilsom

    andymilsom

    Unity Technologies

    Joined:
    Mar 2, 2016
    Posts:
    294
    That is unexpected, when happens when you do a LoadAssetAsync will be that it first loads dependencies and then if they are successful will load the Asset. For DownloadDependencies, it will do the first step (downloading bundles). Skipping the loading step. If there are issues when using DownloadDependencies then there would occur when using LoadAssetAsync.

    What kind of issues do you see with DownloadDependencies have that you resolve by using LoadAsset?
    From what I can tell, is that if some downloads work and others don't. Then the handle for DownloadDependencies will fail and release?
    ie. You are looking for something like releaseDependenciesOnFailure for LoadAssetsAsync? https://docs.unity3d.com/Packages/c...ableAssets.html#addressablesloadassetsasync-1
    This would let you know how many were successful or not.
     
  12. AR_Tehcnoplus

    AR_Tehcnoplus

    Joined:
    Jan 17, 2022
    Posts:
    15
    Is there any update regarding catching the connection lost problem ?
     
    Cfirzi likes this.
  13. andymilsom

    andymilsom

    Unity Technologies

    Joined:
    Mar 2, 2016
    Posts:
    294
    AR_Tehcnoplus likes this.
  14. mohamedelzayatmop

    mohamedelzayatmop

    Joined:
    Aug 28, 2020
    Posts:
    2
    I'm currently having a similar problem, however I'm wondering, If my assets are already downloaded. It is logical that if it fails to check with the server the latest assets, it should grab from the existing cached/ previously downloaded assets.
    Currently even if my assets has been downloaded, in the first run, the app won't run again unless I allow internet connection to be enabled. Am I missing something here?

    Also kindly note that I'm deploying unity app/game as a plugin targeting iOS/Android
     
  15. virgilcwyile

    virgilcwyile

    Joined:
    Jan 31, 2016
    Posts:
    73
    Above is the issue I am facing too. First time of Downloading remote assets, everything works fine in the game. Even when switching scenes back and forth. All assets would get load up fine. But next time when game is restarted, It would again look for Internet connection and won't load any asset until Internet allowed. As if it was downloading the content again. Any way to make game work offline after first time of downloading Addressables?