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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Addressables.LoadSceneAsync Percent Complete not updating on WebGL?

Discussion in 'Addressables' started by forzabo, Jan 11, 2020.

  1. forzabo

    forzabo

    Joined:
    Aug 28, 2015
    Posts:
    60
    Context:

    I'm working on a WebGL build that consists of a very minimal bootstrap scene that then loads a fairly large initial core game payload that's contained in a single scene. I'd very much like to be able to monitor the progress of the load so I can present some simple but diverting content in the interim. Very basic stuff, right?

    However, when I test this, PercentComplete jumps immediately from 0 to .5 and then continues to hang at .5 until the scene is completely loaded. I'm testing this with a remote server on a veeeeery slow connection and the payload is relatively large, caches are cleared etc, so I would expect to see the progress slowly increment like it would with SceneManager.LoadSceneAsync (etc).

    I'm using Unity 2018.3.12.f1 / Addressables package version 1.5.0

    Here's my very simple bootstrap code:


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.AddressableAssets;
    5. using UnityEngine.ResourceManagement.AsyncOperations;
    6. using UnityEngine.UI;
    7.  
    8. public class BootstrapController : MonoBehaviour
    9. {
    10.  
    11.     public string NextSceneAddress;
    12.     public float percentDone = 0;
    13.     [SerializeField] private Text LoadingText;
    14.     AsyncOperationHandle handle;
    15.  
    16.  
    17.     // Use this for initialization
    18.     void Start()
    19.     {
    20.         StartCoroutine(Bootstrap());
    21.     }
    22.  
    23.     IEnumerator Bootstrap()
    24.     {
    25.         yield return null;
    26.  
    27.  
    28.         handle = Addressables.LoadSceneAsync(NextSceneAddress);
    29.  
    30.         int i = 0; //increment; otherwise useless sanity check that the while loop is looping...
    31.         yield return null;
    32.  
    33.         while (!handle.IsDone)
    34.         {
    35.             percentDone = Mathf.Floor(handle.PercentComplete * 100.0f);
    36.             LoadingText.text = i++ + " Loading " + percentDone.ToString() + "% Done";
    37.  
    38.  
    39.             yield return null;
    40.         }
    41.         // else scene should load automatically, right?
    42.     }
    43.  
    44.     private void Update()
    45.     {
    46.      
    47.     }
    48. }
     
    Last edited: Jan 11, 2020
    skwsk8 likes this.
  2. forzabo

    forzabo

    Joined:
    Aug 28, 2015
    Posts:
    60
    I guess it's not surprising that the same issue occurs with LoadAssetAsync<T>().

    :(
     
    skwsk8 likes this.
  3. wirelessdreamer

    wirelessdreamer

    Joined:
    Apr 13, 2016
    Posts:
    134
    @unity_bill I'm seeing this issue as well in WebGL builds.
     
    skwsk8 likes this.
  4. ProtoTerminator

    ProtoTerminator

    Joined:
    Nov 19, 2013
    Posts:
    566
  5. JohnstableUnity

    JohnstableUnity

    Unity Technologies

    Joined:
    Nov 14, 2017
    Posts:
    4
    As a workaround, instead of using handle.PerfectComplete < 0.0f, I was able to use
    handle.Task.Status != TaskStatus.RanToCompletion. I believe some fixes are coming soon.