Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Feedback RemoteConfig lifecycle returns multiple states

Discussion in 'Unity Remote Config' started by blockimperium, Apr 26, 2020.

  1. blockimperium

    blockimperium

    Joined:
    Jan 21, 2008
    Posts:
    452
    I have created a RemoteConfigManager which loads the configurations from remote config. Was depending on the lifecycle to be able to determine what state the game is starting in, but there are some issues:

    1) When the game is run for the first time I receive a ConfigOrigin.Default.

    2) Every other time the game is run I receive a ConfigOrigin.Cached *and* a ConfigOrigin.Remote. So effectively it is always hitting my ApplyRemoteSettings closure twice.

    Code (CSharp):
    1.    
    2.     void Awake()
    3.     {
    4.         ConfigManager.FetchCompleted += ApplyRemoteSettings;
    5.         ConfigManager.FetchConfigs<userAttributes,appAttributes> ( new userAttributes(), new appAttributes());
    6.         Debug.Log("Fetched remote configuration");
    7.     }
    8.  
    9.     void ApplyRemoteSettings(ConfigResponse configResponse)
    10.     {
    11.  
    12.         switch ( configResponse.requestOrigin)
    13.         {
    14.             case ConfigOrigin.Default:
    15.                 Debug.Log("No setting loaded in this session; using defaults");
    16.                 break;
    17.  
    18.             case ConfigOrigin.Cached:
    19.                 Debug.Log("No settings loaded this session; using cached values from previous session");
    20.                 break;
    21.  
    22.             case ConfigOrigin.Remote:
    23.                 Debug.Log("New settings retrieved this session; updating from loaded settings");
    24.  
    25.                 Debug.Log("Server " + ConfigManager.appConfig.GetString(MATCHMAKING_SERVER_IP));
    26.  
    27.                 matchMakingServerIp = ConfigManager.appConfig.GetString(MATCHMAKING_SERVER_IP);
    28.                 matchMakingServerPort = ConfigManager.appConfig.GetInt(MATCHMAKING_SERVER_PORT);
    29.                 break;
    30.         }
    31.  
    32.     }
    This manager is attached to an empty GameObject in the scene so it should only be called once, during the Awake for that GameObject.

    upload_2020-4-26_4-55-56.png

    upload_2020-4-26_4-56-50.png
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Which version of RC are you using?
     
  3. rambod

    rambod

    Unity Technologies

    Joined:
    Mar 2, 2018
    Posts:
    58
    Hey @gregorypierce

    Those are all by design - I’d be curious to see what you behavior you would expect to see?

    for some background:
    1. The default state is to let you know that nothing has been fetched yet
    2. Each time you fire off FetchConfigs - under the covers, Remote Config tries to load cached values for that Config first (hence the cached callback)
    3. At the same time, it hits the remote server to try to get the latest Config from the cloud, which usually takes longer, so then the callback is triggered with the Remote source
     
  4. blockimperium

    blockimperium

    Joined:
    Jan 21, 2008
    Posts:
    452
    The behavior I was expecting was if the config was coming from something cached, I would only receive a cached event. If it was being pulled from something remote I would only get a remote event. I'm trying to get a lifecycle that tells me where the settings are coming from, not one that is the d-graph of what RC is doing to retrieve the settings.