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. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    Dismiss Notice

Bug FetchConfigsAsync does not work and gets stuck!

Discussion in 'Unity Remote Config' started by Iammakep, Jan 12, 2023.

  1. Iammakep

    Iammakep

    Joined:
    Feb 25, 2015
    Posts:
    2
    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!

    Code (CSharp):
    1. using System.Collections;
    2. using Unity.Services.Authentication;
    3. using Unity.Services.Core;
    4. using UnityEngine;
    5. using ConfigManager = Unity.Services.RemoteConfig.ConfigManager;
    6.  
    7. public class CanvasTest : MonoBehaviour
    8. {
    9.   private struct userAttributes { }
    10.   private struct appAttributes { }
    11.  
    12.   // ============================================================================
    13.   private void Start()
    14.   {
    15.     StartCoroutine(nameof(StartAsync));
    16.   }
    17.  
    18.   // ============================================================================
    19.   private IEnumerator StartAsync()
    20.   {
    21.     #region UnityRemoteConfig
    22.  
    23.     DebugX.Log("Unity Remote config initialize...");
    24.     ConfigManager.SetEnvironmentID(Global.UnityRemoteConfigEnvID);
    25.     ConfigManager.SetPlayerID("...");
    26.  
    27.     var initTask = UnityServices.InitializeAsync();
    28.     yield return new WaitUntil(() => initTask.IsCompleted);
    29.  
    30.     if (!AuthenticationService.Instance.IsSignedIn)
    31.     {
    32.       var authTask = AuthenticationService.Instance.SignInAnonymouslyAsync();
    33.       yield return new WaitUntil(() => authTask.IsCompleted);
    34.     }
    35.  
    36.     DebugX.Log("Wait for fetching remote config (10)");
    37.     yield return new WaitForSeconds(10);
    38.  
    39.     DebugX.Log("Fetching remote config from Unity...");
    40.  
    41.     // STUCK on this
    42.     var fetchTask = ConfigManager.FetchConfigsAsync<userAttributes, appAttributes>(new userAttributes(), new appAttributes());
    43.     yield return new WaitUntil(() => fetchTask.IsCompleted);
    44.  
    45.     // !!!!!!!! This log and next code is no longer executed !!!!!!!
    46.     DebugX.Log("Remote config from Unity acepted.");
    47.  
    48.     // Log Remote Config
    49.     var message = ConfigManager.appConfig.GetString("Message");
    50.     var messageTime = ConfigManager.appConfig.GetLong("MessageTime");
    51.     var minVersion = ConfigManager.appConfig.GetInt("MinVersion");
    52.     var showBlockMessage = ConfigManager.appConfig.GetBool("ShowBlockMessage");
    53.     DebugX.Log($"Remote config: message({message}), messageTime({messageTime}), minVersion({minVersion}), showBlockMessage({showBlockMessage})");
    54.    
    55.     #endregion UnityRemoteConfig
    56.   }
    57. }
    58.  
    Get this result in browser, the response is obtained, but the function gets stuck:
    log.png
     
  2. SebT_Unity

    SebT_Unity

    Unity Technologies

    Joined:
    Jun 21, 2021
    Posts:
    251
    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