FetchConfigsAsync does not work and gets stuck!

Hi. Please help me solve the problem!
Trying to get values from “Remote Configs” and gets stuck on WebGL.
Everything is fine in the editor, I get all the necessary values without any problems! But not WebGL!

using System.Collections;
using Unity.Services.Authentication;
using Unity.Services.Core;
using UnityEngine;
using ConfigManager = Unity.Services.RemoteConfig.ConfigManager;

public class CanvasTest : MonoBehaviour
{
  private struct userAttributes { }
  private struct appAttributes { }

  // ============================================================================
  private void Start()
  {
    StartCoroutine(nameof(StartAsync));
  }

  // ============================================================================
  private IEnumerator StartAsync()
  {
    #region UnityRemoteConfig

    DebugX.Log("Unity Remote config initialize...");
    ConfigManager.SetEnvironmentID(Global.UnityRemoteConfigEnvID);
    ConfigManager.SetPlayerID("...");

    var initTask = UnityServices.InitializeAsync();
    yield return new WaitUntil(() => initTask.IsCompleted);

    if (!AuthenticationService.Instance.IsSignedIn)
    {
      var authTask = AuthenticationService.Instance.SignInAnonymouslyAsync();
      yield return new WaitUntil(() => authTask.IsCompleted);
    }

    DebugX.Log("Wait for fetching remote config (10)");
    yield return new WaitForSeconds(10);

    DebugX.Log("Fetching remote config from Unity...");

    // STUCK on this
    var fetchTask = ConfigManager.FetchConfigsAsync<userAttributes, appAttributes>(new userAttributes(), new appAttributes());
    yield return new WaitUntil(() => fetchTask.IsCompleted);

    // !!!!!!!! This log and next code is no longer executed !!!!!!!
    DebugX.Log("Remote config from Unity acepted.");

    // Log Remote Config
    var message = ConfigManager.appConfig.GetString("Message");
    var messageTime = ConfigManager.appConfig.GetLong("MessageTime");
    var minVersion = ConfigManager.appConfig.GetInt("MinVersion");
    var showBlockMessage = ConfigManager.appConfig.GetBool("ShowBlockMessage");
    DebugX.Log($"Remote config: message({message}), messageTime({messageTime}), minVersion({minVersion}), showBlockMessage({showBlockMessage})");
   
    #endregion UnityRemoteConfig
  }
}

Get this result in browser, the response is obtained, but the function gets stuck:

Hi there,
Thanks for posting on the forums.
Could you provide the Unity Version and Remote Config version you are using? Could you also share your web browser?
Are you using any adblockers?

I would like to reproduce this locally. Look forward to your response.
Seb

For anyone encountering this in the future:

I’ve solved it by using FetchConfigs instead of FetchConfigsAsync, because FetchConfigsAsync uses Task.Delay internally which doesn’t work correctly in WebGL.

5 Likes