Search Unity

AsyncOperationHandle.PercentComplete not updating when given as a Parameter in Function

Discussion in 'Addressables' started by David_GameDev, Apr 26, 2019.

  1. David_GameDev

    David_GameDev

    Joined:
    Dec 25, 2016
    Posts:
    25
    Since 0.7.4 I´ve got a Problem with my loading screen. What I have been doing sofar was a simple Loadingscreen, with the function

    Code (CSharp):
    1. public IEnumerator ShowProgress(AsyncOperationHandle op)
    2.     {
    3.              //this also seemingly doesn´t work anymore. What I currently do, just for testing is instead of GetDownloadSize(op) I replace the op with the actual object key, at least for now.
    4.              Addressables.GetDownloadSize(op).Completed += (AsyncOperationHandle<long> getValue) => { Downloadsize = getValue.Result; finishedGettingInfo = true; };
    5.              yield return new WaitUntil(() => finishedGettingInfo);
    6.  
    7.         while (op.PercentComplete < 1)
    8.         {
    9.              progressBar.value = op.PercentComplete;
    10.              txtProgress.text = string.Format("{0:0.00}mb / {1:0.00}mb", (op.PercentComplete / 1000000) * 100, Downloadsize / 1000000);            
    11.              yield return new WaitForSeconds(0.01f);
    12.         }
    13.   }
    14.  

    Pretty simple loading screen which worked for any Addressables Load I had. However, since 0.7.4, the op.PercentComplete doesn´t update at all. It only updates when the operation is basically done and op.PercentComplete = 1; It worked before IAsyncOperation got replaced with AsyncOperationHandle. Any advice whether I just have an error in the code now or if I need a new approach for this because maybe the AsyncOperationHandle doesn’t work exactle the same as it did before as IAsyncOperation.
    And is it possible to get the object Key from AsyncOperationHandle?

    Thanks in advance
     
    CharBodman likes this.
  2. dbarile

    dbarile

    Joined:
    Apr 14, 2015
    Posts:
    14
    Same here. Using Addressables 7.5 Please advise. :eek:

    @unity_bill , you are our only hope!

    Code (CSharp):
    1. this.asyncOperationObjectLoad = this.experienceAsset.Instantiate();
    2.  
    3. if (!this.onCompleteCreated)
    4. {
    5.      this.onCompleteCreated = true;
    6.      this.asyncOperationObjectLoad.Completed += OnObjectLoaded;
    7. }
    8.  
    9. void Update()
    10. {
    11.         if (!this.isLoading)
    12.             return;
    13.  
    14.         if (this.onCompleteCreated)
    15.         {
    16.             this.progressBar.SetValue(this.asyncOperationObjectLoad.PercentComplete);
    17.         }
    18. }
     
    Last edited: May 4, 2019
  3. David_GameDev

    David_GameDev

    Joined:
    Dec 25, 2016
    Posts:
    25
    0.8.4. Still same Problem, PercentComplete from AsyncOperationHandle - Parameter not updating.
     
    CharBodman likes this.
  4. unity_bill

    unity_bill

    Unity Technologies

    Joined:
    Apr 11, 2017
    Posts:
    981
  5. dbarile

    dbarile

    Joined:
    Apr 14, 2015
    Posts:
    14
    @unity_bill Any word on the progress complete issue? We're about ready to ship a product and were hoping there might be a solution by now. Thanks!
     
    CharBodman, faolad and David_GameDev like this.
  6. dbarile

    dbarile

    Joined:
    Apr 14, 2015
    Posts:
    14
    Using Addressables 1.1.5, is there a way to cancel a AsyncOperationHandle?

    I tried some of the following approaches, but no luck...

    Code (CSharp):
    1.  
    2. private AsyncOperationHandle asyncOperationObjectLoad;
    3.  
    4. public void LoadExperience()
    5. {
    6.           this.onCompleteCreated = true;//flag for Update()
    7.  
    8.           this.asyncOperationObjectLoad = this.experienceAsset.Instantiate();
    9.  
    10.           this.asyncOperationObjectLoad.Completed += OnObjectLoaded;
    11. }
    12.  
    13. public void DestroyLoadedAssets()
    14. {
    15.         if (this.loadedExperience != null)
    16.         {
    17.             Addressables.Release(this.loadedExperience);
    18.         }
    19.        
    20.         this.onCompleteCreated = false;
    21.  
    22.         this.asyncOperationObjectLoad.Completed -= OnObjectLoaded;//doesn't work
    23.  
    24.         StopAllCoroutines();//doesn't work
    25.  
    26.         this.asyncOperationObjectLoad = new AsyncOperationHandle();//doesn't work
    27. }
    Also, still not able to get a value for AsyncOperationHandle.PercentComplete. Is there some sort of workaround?

    For that matter, I'm doing the potential code in an Update loop, which is pretty janky to begin with. Is there a AsyncOperationHandle.onProgress or .onLoad to register to?

    Code (CSharp):
    1.  
    2. private void Update()
    3. {
    4.         if (!this.isLoading)
    5.             return;
    6.  
    7.         if (this.onCompleteCreated)
    8.         {
    9.             this.progressBar.SetValue(this.asyncOperationObjectLoad.PercentComplete);
    10.         }
    11.         else
    12.         {
    13.             this.progressBar.SetValue(0);
    14.         }
    15. }
    @unity_bill Or any other Unity staff. Any help would be much appreciated. Thank you!
     
  7. unity_bill

    unity_bill

    Unity Technologies

    Joined:
    Apr 11, 2017
    Posts:
    981
    We had fixed some case earlier, but tracked down what should be the main failing scenario recently. The fix is in our repo and will be in the next release.

    not yet. We've looked into it. The problem is that some things you can do through addressable are cancel-able. Some not. So we haven't added this yet as we can't actually guarantee a reasonable behavior.

    no. the main thing that will ever have progress is the download. for that we're wrapping https://docs.unity3d.com/ScriptReference/Networking.UnityWebRequest.html which has no "on progress" callback. The update loop is probably the best place to work with that.
     
  8. CharBodman

    CharBodman

    Joined:
    Sep 20, 2018
    Posts:
    28
    Hey Bill , Do you have a rough estimation when this next release will be? We're trying to launch a production game asap and we need this PercentComplete bug fixed :confused:.

    Thanks !
     
  9. unity_bill

    unity_bill

    Unity Technologies

    Joined:
    Apr 11, 2017
    Posts:
    981
    Either next week or the week after. Things are a little hard to nail down as a lot of the team is in and out on vacation over the summer. But I'm targeting fairly soon
     
    fabioColombini likes this.
  10. essamri

    essamri

    Joined:
    Nov 29, 2017
    Posts:
    2
    this is still an issue for me , is there any news ?
     
  11. mocerezo

    mocerezo

    Joined:
    Jan 21, 2013
    Posts:
    7
    is working now for me with Addressables v. 1.1.7
     
  12. essamri

    essamri

    Joined:
    Nov 29, 2017
    Posts:
    2
    i only get some value ex: 0.33, then 0.8, then 1
    not real progress
    is that what you got ?
     
    David_GameDev likes this.
  13. mocerezo

    mocerezo

    Joined:
    Jan 21, 2013
    Posts:
    7
    No, actually i got a smooth progress from 0 to 1 ( 0.1,..... 0.45,..... 0.6...0.8.... 1), im using a progress bar and is working fine.
     
  14. zhbd

    zhbd

    Joined:
    Jun 28, 2019
    Posts:
    2
    :::>_<::: I got the same problem
     
  15. zhbd

    zhbd

    Joined:
    Jun 28, 2019
    Posts:
    2
    When I use Addressables.GetDownloadSizeAsync
    the AsyncOperationHandle.PercentComplete is always 1
     
  16. DavidUnity3d

    DavidUnity3d

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    229
    Hey @zhbd GetDownloadSizeAsync doesn't actually download anything, it just checks the location data for the download size. If Addressables is initialized this is basically a synchronous operation. The only reason you might see anything different than 1 on this operation is if Addressables hasn't finished initialization and we chain the GetDownloadSizeAsync op with the init op.

    @essamri what API are you using that you're checking the progress of? I can take a look at how that specific operation works and make sure we haven't missed something.
     
    unity_bill likes this.
  17. vitorfgd

    vitorfgd

    Joined:
    Nov 4, 2014
    Posts:
    16
    Do you have any updates on cancelling the
    AsyncOperationHandle
    ? I'm creating a game with 3 HUGE stages and pre-loading them before the user selects a stage to play, my goal is to stop the other two and continue downloading the requested stage.
     
    Mazak likes this.
  18. Mazak

    Mazak

    Joined:
    Mar 24, 2013
    Posts:
    217
    Yes, we need a way to get a good progress of the download
     
  19. vitorfgd

    vitorfgd

    Joined:
    Nov 4, 2014
    Posts:
    16
    I am still experiencing download percentages being only 0 or 1. There are no progress, even normalized.
     
  20. trunghieu974

    trunghieu974

    Joined:
    Jun 19, 2015
    Posts:
    6
    1. Is there anyway to get download percentages? I still get just 0 or 1.
     
  21. timbokoppers

    timbokoppers

    Joined:
    Nov 14, 2016
    Posts:
    31
    Any news on this topic ?
     
    AndersLightbulb likes this.
  22. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    83
    Updated to 1.6.0 and still seeing this issue in webgl, Unity 2019.1.14.

    Interestingly, I did see a couple 0.33333 and one 0.666667, but the other several hundred were either 0 or 1.
    I thought maybe it was because my mac is downloading so fast that it doesn't have time to register any in-betweens. So I fired it up on my chromebook and even throttled the network, but it still only got 0 or 1, and it didn't get any in betweens.

    @DavidUnity3d @unity_bill
     
  23. DavidUnity3d

    DavidUnity3d

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    229
    @ProtoTerminator just curious, have you tried any other builds (like Standalone?). To the best of my knowledge we should be reporting the underlying operations percent complete (or a calculated one in the event of chain operation or group operations). I'd be curious to double check that you're getting more granularity if you used UnityWebRequest directly to download the asset bundle. I'm unsure.

    What APIs are you using that you're seeing this on?
     
  24. timbokoppers

    timbokoppers

    Joined:
    Nov 14, 2016
    Posts:
    31
    I have the same problem as @ProtoTerminator is describing. Only for an iOS build. I load the addressables from a google bucket. Keeps at 0 for a long time... and in the end you see really quickly 0.6667 and BOOM it's there..
    Not a steady progress from 0 to 1.
     
  25. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    83
    @DavidUnity3d Hm, interesting. I just ran a test with directly using UnityWebRequests to download pngs and json files, and it elicited the same behavior (only printing 0 and 1). I was just using Addressables.LoadAsset<T>(string) btw.

    After digging through the patch notes for 2019.2 and 2019.3, I saw
    WebRequest: Fixed an issue with UploadHandlerFile properties contentType and progress. ([URL='https://issuetracker.unity3d.com/issues/uploadhandlerfile-dot-contenttype-cannot-be-set-and-always-returns-text-slash-plain']1197177[/URL])
    in 2019.2.19. Is that where this issue is fixed?

    Sadly, my team's project has been unable to run WebGL after upgrading the engine, so we've been stuck on 2019.1.14 for a while.
     
  26. DavidUnity3d

    DavidUnity3d

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    229
    @ProtoTerminator I'll have to triage on the different versions to see but that sounds very likely to be the case. If there's an issue with what the underlying operation is reporting as it's percent complete there won't be anything we can do about that on the Addressables side unfortunately.

    Sorry to hear you're having trouble with WebGL on updated versions of the Editor. I don't know if you've submitted any WebGL bugs or talked to them on their forums but maybe they can help you out there?
     
  27. timbokoppers

    timbokoppers

    Joined:
    Nov 14, 2016
    Posts:
    31
    @DavidUnity3d can you confirm it should work? I have (and based on other comment, more people do) exactly the same issue. We build for iOS and are loading a prefab with dependencies. The PercentComplete is not working as expected.

    Can you 100% confirm it should work in a smooth manner giving you back the exact percentage loaded (including the dependencies loaded)
     
unityunity