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

RemoteConfig always returns non-existing cached data from Server

Discussion in 'Unity Remote Config' started by mylastggColto, Nov 19, 2020.

Thread Status:
Not open for further replies.
  1. mylastggColto

    mylastggColto

    Joined:
    Feb 28, 2017
    Posts:
    28
    Hello!
    I am running a project on 2019.4.14f1 LTS on MacBook Pro, Catalina, latest version.

    I've been using RemoteConfig successfully for months now but this morning I experienced something weird:
    • I had a development environment with 6 different string variables and one 'rule' for each variable
    • I added a new string variable with a default value 'off'
    • I ran the code in the Editor but I could never get the value of the new string variable, only the old pre-existing 6 variables with DEFAULT values (kind of cached ones)
    • I then deleted ALL the variables from the development environment but when I run in the editor I still get all the old 6 string variables as if they were on the backend
    Things I've checked:
    • I've checked the backend dashboard and I only have one variable now, but I still get the old 6 if I run the code
    • I've removed the RemoteConfig.json file from the game folders multiple times but it doesn't affect the results
    • I've updated RemoteConfig from 1.2.x to 2.0.0 to no avail
    • If I create a new rule for the 7th variable and activate it, I magically get one of the rule values correctly (screenshots attached). I don't think this is the only way to make this work, I always understood that settings without rules should work just fine
    Thanks for your help!

    Davide
     

    Attached Files:

  2. mvhgroup

    mvhgroup

    Joined:
    May 18, 2017
    Posts:
    4
    As of today I'm not getting any changes I make in my settings. I get yesterdays values no matter what I do.
     
  3. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please share the code that you are using.
     
  4. mylastggColto

    mylastggColto

    Joined:
    Feb 28, 2017
    Posts:
    28
    Code (CSharp):
    1.    
    2. private void Start()
    3.  {
    4.         Logger.Log("remote", "Start");
    5.         ConfigManager.FetchCompleted += ApplyRemoteSettings;
    6.         ConfigManager.FetchConfigs(userAttributes, new AppAttributes());
    7. }
    8.  
    9. private void ApplyRemoteSettings(ConfigResponse configResponse)
    10.     {
    11.         if(configResponse.status != ConfigRequestStatus.Success)
    12.         {
    13.             Logger.Log("remote", "the remote config request was not successful but " + configResponse.status);
    14.             return;
    15.         }
    16.  
    17.         switch (configResponse.requestOrigin)
    18.         {
    19.             case ConfigOrigin.Default:
    20.                 Logger.Log("remote", "no settings loaded this session; using default values");
    21.                 break;
    22.  
    23.             case ConfigOrigin.Cached:
    24.                 Logger.Log("remote", "no settings loaded this session; using cached values from a previous session");
    25.                 break;
    26.  
    27.             case ConfigOrigin.Remote:
    28.                 Logger.Log("remote", "new settings loaded this session; update values accordingly");
    29.                 Logger.Log("remote", "origin: " + ConfigManager.appConfig.origin);
    30.  
    31.                 // here we use the value
    32.                 ConfigManager.appConfig.GetString(experiments[i].experimentName);
    33.  
    34.                 break;
    35.         }
    36.     }
    37.  
     
  5. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    So you're not seeing the values when you Push/Pull your values in the Editor, as in your screenshots? Or are you referring to the values when you run your code.
     
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  7. mylastggColto

    mylastggColto

    Joined:
    Feb 28, 2017
    Posts:
    28
    Pull and Push work correctly, but when I run the code, if I print the content of appConfig I get the 6 variables that I had defined until yesterday, while I should now get only one variable set (experimentVariant007 from the screenshot)

    I am also setting the env as follows (I've omitted the call to the function in the previous snippet)

    Code (CSharp):
    1.    
    2. private void SetEnvironmentID()
    3.     {
    4. #if COLTO_PRODUCTION
    5.         const string RELEASE_REMOTE_CONFIG_ID = "xyz";
    6.         ConfigManager.SetEnvironmentID(RELEASE_REMOTE_CONFIG_ID);
    7. #else
    8.         const string DEVELOPMENT_REMOTE_CONFIG_ID = "abc";
    9.         ConfigManager.SetEnvironmentID(DEVELOPMENT_REMOTE_CONFIG_ID);
    10. #endif
    11.     }
    12.  
     
  8. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please share the actual code that you are using so we can attempt to reproduce here.
     
  9. mylastggColto

    mylastggColto

    Joined:
    Feb 28, 2017
    Posts:
    28
    Code (CSharp):
    1.  
    2.  
    3. using UnityEngine;
    4. using Unity.RemoteConfig;
    5. using System;
    6. using System.Collections.Generic;
    7.  
    8. public struct EXPERIMENT
    9. {
    10.     public const string VARIANT_OFF = "off";
    11.     public const string VARIANT_CONTROL = "control";
    12.     public const string VARIANT_PREFIX = "variantExperiment";
    13.  
    14.     public string experimentName;
    15.     public string experimentVariant;
    16. }
    17.  
    18. public class RemoteConfigManager : Singleton<RemoteConfigManager>
    19. {
    20.     public struct UserAttributes
    21.     {
    22.         public bool isStarterPackOwned;
    23.         public bool isSpaceCarOwned;
    24.     }
    25.     public struct AppAttributes { }
    26.     public int ProgressiveAppLaunchNumber
    27.     {
    28.         get
    29.         {
    30.             return PlayerPrefs.GetInt(PROGRESSIVE_APP_LAUNCH_NUMBER_TAG, 0);
    31.         }
    32.         set
    33.         {
    34.             PlayerPrefs.SetInt(PROGRESSIVE_APP_LAUNCH_NUMBER_TAG, value);
    35.         }
    36.     }
    37.  
    38.     private const int NUMBER_OF_EXPERIMENTS = 8;
    39.     private readonly EXPERIMENT[] experiments = new EXPERIMENT[NUMBER_OF_EXPERIMENTS];
    40.     private const string CUSTOM_USER_ID_TAG = "CUSTOM_USER_ID_TAG";
    41.     private const string PROGRESSIVE_APP_LAUNCH_NUMBER_TAG = "PROGRESSIVE_APP_LAUNCH_NUMBER_TAG";
    42.  
    43.     private void Start()
    44.     {
    45.         Logger.Log("remote", "Start");
    46.  
    47.         for (int i = 0; i < experiments.Length; i++)
    48.         {
    49.             experiments[i].experimentName = EXPERIMENT.VARIANT_PREFIX + (i + 1).ToString("000");
    50.             experiments[i].experimentVariant = EXPERIMENT.VARIANT_OFF;
    51.         }
    52.  
    53.         UserAttributes userAttributes = new UserAttributes
    54.         {
    55.             isStarterPackOwned = InterstitialSceneController.IsStarterPackBought(),
    56.             isSpaceCarOwned = InterstitialSpaceCarSceneController.IsSpaceCarOwned(),
    57.         };
    58.  
    59.         SetNewCustomUserID();
    60.         SetEnvironmentID();
    61.         IncrementAppLaunchNumber();
    62.         ConfigManager.FetchCompleted += ApplyRemoteSettings;
    63.         ConfigManager.FetchConfigs(userAttributes, new AppAttributes());
    64.     }
    65.  
    66.     public string GetExperimentVariantByNumber(int experimentNumber)
    67.     {
    68.         string experimentName = EXPERIMENT.VARIANT_PREFIX + experimentNumber.ToString("000");
    69.         for (int i = 0; i < experiments.Length; i++)
    70.         {
    71.             if (experiments[i].experimentName == experimentName)
    72.             {
    73.                 return experiments[i].experimentVariant;
    74.             }
    75.         }
    76.         // we could not find the specified experiment, we assume it's off
    77.         return EXPERIMENT.VARIANT_OFF;
    78.     }
    79.  
    80.     private void ApplyRemoteSettings(ConfigResponse configResponse)
    81.     {
    82.         if(configResponse.status != ConfigRequestStatus.Success)
    83.         {
    84.             Logger.Log("remote", "the remote config request was not successful but " + configResponse.status);
    85.             return;
    86.         }
    87.  
    88.         switch (configResponse.requestOrigin)
    89.         {
    90.             case ConfigOrigin.Default:
    91.                 Logger.Log("remote", "no settings loaded this session; using default values");
    92.                 break;
    93.  
    94.             case ConfigOrigin.Cached:
    95.                 Logger.Log("remote", "no settings loaded this session; using cached values from a previous session");
    96.                 break;
    97.  
    98.             case ConfigOrigin.Remote:
    99.                 Logger.Log("remote", "new settings loaded this session; update values accordingly");
    100.                 Logger.Log("remote", "origin: " + ConfigManager.appConfig.origin);
    101.  
    102.                 for (int i = 0; i < experiments.Length; i++)
    103.                 {
    104.                     experiments[i].experimentVariant = ConfigManager.appConfig.GetString(experiments[i].experimentName);
    105.                     TrackExperimentNamed(experiments[i].experimentName, experiments[i].experimentVariant);
    106.                 }
    107.  
    108.                 break;
    109.         }
    110.     }
    111.  
    112.     private void SetNewCustomUserID()
    113.     {
    114.         if (string.IsNullOrEmpty(PlayerPrefs.GetString(CUSTOM_USER_ID_TAG, "")))
    115.         {
    116.             DateTime epochStart = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
    117.             long millisecondsSinceEpoch = (long)(DateTime.UtcNow - epochStart).TotalMilliseconds;
    118.             PlayerPrefs.SetString(CUSTOM_USER_ID_TAG, millisecondsSinceEpoch.ToString());
    119.  
    120.             Logger.Log("remote", "saving this date to playerprefs: " + millisecondsSinceEpoch.ToString());
    121.         }
    122.         string customerUserID = PlayerPrefs.GetString(CUSTOM_USER_ID_TAG, "");
    123.         ConfigManager.SetCustomUserID(customerUserID);
    124.  
    125.         Logger.Log("remote", "customerUserID: " + customerUserID);
    126.     }
    127.  
    128.     private void SetEnvironmentID()
    129.     {
    130. #if COLTO_PRODUCTION
    131.         const string RELEASE_REMOTE_CONFIG_ID = "89b434b0-0130-4f16-9a65-8ff7cb1bb240";
    132.         ConfigManager.SetEnvironmentID(RELEASE_REMOTE_CONFIG_ID);
    133. #else
    134.         const string DEVELOPMENT_REMOTE_CONFIG_ID = "83d54126-f1e9-4e7e-87f8-163ad58c0267";
    135.         ConfigManager.SetEnvironmentID(DEVELOPMENT_REMOTE_CONFIG_ID);
    136. #endif
    137.     }
    138.  
    139.     private void IncrementAppLaunchNumber()
    140.     {
    141.         ProgressiveAppLaunchNumber++;
    142.     }
    143.  
    144.     private void TrackExperimentNamed(string experimentName, string experimentVariant)
    145.     {
    146.         Logger.Log("remote", experimentName + ": " + experimentVariant);
    147.  
    148.         AnalyticsController.SendCustomEvent(AnalyticsController.ANALYTICS_EVENT.CKN_EXPERIMENT,
    149.         new Dictionary<string, object>
    150.         {
    151.             { AnalyticsController.GetReadableEventName(AnalyticsController.ANALYTICS_PROPERTY.CKN_EXPERIMENT_NAME), experimentName },
    152.             { AnalyticsController.GetReadableEventName(AnalyticsController.ANALYTICS_PROPERTY.CKN_EXPERIMENT_VARIANT), experimentVariant },
    153.         });
    154.     }
    155. }
    156.  
    This is the entire Singleton manager that handles the remote configuration calls.
    When it gets the data it populates an array of structs with the experiment name (key) and its value
     
  10. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Got it thanks, just wanted to make sure.
     
  11. mvhgroup

    mvhgroup

    Joined:
    May 18, 2017
    Posts:
    4
    The code I'm using was working fine for the last year or so. For me Pull & Push also work fine in the Remote Config window, but the values received during runtime are yesterdays values. Tested on both Development and Release environments.
     
  12. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    539
    Same problem here, it was working well, last week, I tried today to add a new field but I dont see any changes.
    Also modifying previous fields I still get the old values.
     
  13. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Yes, we just identified the issue and rolling out an update.
     
  14. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  15. mvhgroup

    mvhgroup

    Joined:
    May 18, 2017
    Posts:
    4
    It works fine now. Thank you!
     
    pistoleta, harpj and vd_unity like this.
  16. mylastggColto

    mylastggColto

    Joined:
    Feb 28, 2017
    Posts:
    28
    It looks like it's working now! Thanks for the super quick fix @JeffDUnity3D !
     
    JeffDUnity3D likes this.
  17. Havokki

    Havokki

    Joined:
    Jun 28, 2015
    Posts:
    118
    Seems to be broken again. It has worked fine every day for over a month, but now I'm no longer able to download the latest data.

    I tried removing all of my code and only using Unity's Remote Config window, so it's not just an issue in my code.

    I can push new changes, I can see from the dashboard that the changes went through, but pulling the configs always returns the old data.
     
  18. mylastggColto

    mylastggColto

    Joined:
    Feb 28, 2017
    Posts:
    28
    I've tested this morning and it seems to work on my machine. @Havokki do you still have the issue?
     
  19. Havokki

    Havokki

    Joined:
    Jun 28, 2015
    Posts:
    118
    Yeah, it was working again today.

    Unfortunately it was down right when I most needed it. :) I have now modified the way we use the configs, so this should not be as big of an issue in the future.
     
  20. mylastggColto

    mylastggColto

    Joined:
    Feb 28, 2017
    Posts:
    28
    If you don't mind, may I ask you how you modified the configs to limit this in the future?
     
  21. Havokki

    Havokki

    Joined:
    Jun 28, 2015
    Posts:
    118
    1. Our configs are stored in Google Drive just for convenience, since not everyone uses Unity editor.
    2. When I want to update our remote configs, I execute an editor script that first downloads the Google Drive sheets as CSV files and stores them into the project.
    3. The script then pushes those to the remote config. File names are used as keys and file contents are used as values. I also add a time of this action into the config.
    4. When we do builds, our build scripts also adds a time of the build creation into the build (just a TextAsset in resources).
    5. When the game downloads the remote config, it will compare the timestamps. If the remote data is older than the build, it will ignore it and use the built-in data instead (the CSV files previously stored into the project).
    There are also other things, such as having different remote config environments for different types of builds and a "minimum supported build" config, but this is the basic idea.

    If Unity's remote config now stops working, our builds still have compatible built-in data they can use, but they will still be able to pick up the new data once Unity's remote config starts working again. If the remote data has become incompatible during this time, I can set the "minimum supported build" config. Builds with a build number lower than that will not use the remote data.
     
  22. milesLogan

    milesLogan

    Joined:
    Mar 11, 2017
    Posts:
    10
    I seem to be having the same issue at the moment. I can see the values changing on the dashboard but the configs are returning the old data.
     
  23. mylastggColto

    mylastggColto

    Joined:
    Feb 28, 2017
    Posts:
    28
    Really appreciate you taking the time to write all of this, it's a really cool implementation : ) We have a 'minimum' build version mechanism but I never thought of extending it to work with the remote configs.
     
  24. mylastggColto

    mylastggColto

    Joined:
    Feb 28, 2017
    Posts:
    28
    I've tested it again now and it looks like it's working, can you elaborate your situation?
     
  25. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    If you are seeing an issue, please open a new thread. Show the code you are using and the version of RC that you are using. Ensure you can Push/Pull the values in the Editor. I just tested here and not seeing an issue.
     
Thread Status:
Not open for further replies.