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. Dismiss Notice

Bug GetDownloadSize does not complete when server not available

Discussion in 'Addressables' started by NamelessPerson, May 19, 2020.

  1. NamelessPerson

    NamelessPerson

    Joined:
    Apr 17, 2017
    Posts:
    26
    I have the following code in a coroutine used to regularly check if any Addressable updates are available.

    Code (CSharp):
    1.  
    2. var catalogOperation = UnityEngine.AddressableAssets.Addressables.CheckForCatalogUpdates( false );
    3. while ( !catalogOperation.IsDone )
    4.     yield return null;
    5. if ( catalogOperation.Status == AsyncOperationStatus.Succeeded && catalogOperation.Result.Count > 0 ) {
    6.     UpdateLog( "Catalog Update Available" );
    7.     catalogUpdateAvailable = true;
    8. }
    9. else if ( catalogOperation.Status == AsyncOperationStatus.Succeeded ) {
    10.     UpdateLog( "No Catalog Update Available" );
    11. }
    12. else if ( catalogOperation.Status == AsyncOperationStatus.Failed )
    13.     UpdateLog( "Could not check for catalog updates" );
    14. UnityEngine.AddressableAssets.Addressables.Release( catalogOperation );
    15.  
    16. AsyncOperationHandle<long> contentOperation = UnityEngine.AddressableAssets.Addressables.GetDownloadSizeAsync( "global" );
    17. contentOperation.Completed += ( ao ) => { Debug.Log( "Completed" ); };
    18. while ( !contentOperation.IsDone ) {
    19.     Debug.Log( $"Content check {contentOperation.PercentComplete * 100}% complete with status {contentOperation.Status}" );
    20.     yield return null;
    21. }
    22.  
    I am first checking for catalog updates and then using GetDownloadSize to check for missing content that needs to be downloaded (especially useful for a first time install). When the server is available this code works without any problems. However, if I disable the hosting service, the contentOperation never finishes. The Completed event never fires and IsDone never returns true. However percent complete will correctly be 1.

    I believe this is a bug as in theory GetDownloadSize should complete and return 0 if it can't reach the server and find anything to download.

    Edit: Sorry this code will not work if there is nothing new to download whether or not the server is available. It works on the first run, downloads all the content, and then on the next launch it will hang.
     
    Last edited: May 19, 2020
  2. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,795
  3. NamelessPerson

    NamelessPerson

    Joined:
    Apr 17, 2017
    Posts:
    26
    @TreyK-47 will try to file a bug report when I get a chance. In the meantime I did some debugging and it appears it is connected to the Addressables m_InitializationOperation.Task status always being stuck on WaitingToRun. However I cannot figure out why that happens and why it only happens after all the content has been downloaded the first time.
     
  4. NamelessPerson

    NamelessPerson

    Joined:
    Apr 17, 2017
    Posts:
    26
  5. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,795
    Thanks! Connected with the team, and they also advised that filing a bug report is the best course to take.