RemoteConfig always returns non-existing cached data from Server

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



As of today I’m not getting any changes I make in my settings. I get yesterdays values no matter what I do.

Please share the code that you are using.

private void Start()
 {
        Logger.Log("remote", "Start");
        ConfigManager.FetchCompleted += ApplyRemoteSettings;
        ConfigManager.FetchConfigs(userAttributes, new AppAttributes());
}

private void ApplyRemoteSettings(ConfigResponse configResponse)
    {
        if(configResponse.status != ConfigRequestStatus.Success)
        {
            Logger.Log("remote", "the remote config request was not successful but " + configResponse.status);
            return;
        }

        switch (configResponse.requestOrigin)
        {
            case ConfigOrigin.Default:
                Logger.Log("remote", "no settings loaded this session; using default values");
                break;

            case ConfigOrigin.Cached:
                Logger.Log("remote", "no settings loaded this session; using cached values from a previous session");
                break;

            case ConfigOrigin.Remote:
                Logger.Log("remote", "new settings loaded this session; update values accordingly");
                Logger.Log("remote", "origin: " + ConfigManager.appConfig.origin);

                // here we use the value 
                ConfigManager.appConfig.GetString(experiments[i].experimentName);

                break;
        }
    }

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.

Remember to set your environment-id Code integration | Remote Config | 2.0.2-exp.1

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)

private void SetEnvironmentID()
    {
#if COLTO_PRODUCTION
        const string RELEASE_REMOTE_CONFIG_ID = "xyz";
        ConfigManager.SetEnvironmentID(RELEASE_REMOTE_CONFIG_ID);
#else
        const string DEVELOPMENT_REMOTE_CONFIG_ID = "abc";
        ConfigManager.SetEnvironmentID(DEVELOPMENT_REMOTE_CONFIG_ID);
#endif
    }

Please share the actual code that you are using so we can attempt to reproduce here.

using UnityEngine;
using Unity.RemoteConfig;
using System;
using System.Collections.Generic;

public struct EXPERIMENT
{
    public const string VARIANT_OFF = "off";
    public const string VARIANT_CONTROL = "control";
    public const string VARIANT_PREFIX = "variantExperiment";

    public string experimentName;
    public string experimentVariant;
}

public class RemoteConfigManager : Singleton<RemoteConfigManager>
{
    public struct UserAttributes
    {
        public bool isStarterPackOwned;
        public bool isSpaceCarOwned;
    }
    public struct AppAttributes { }
    public int ProgressiveAppLaunchNumber
    {
        get
        {
            return PlayerPrefs.GetInt(PROGRESSIVE_APP_LAUNCH_NUMBER_TAG, 0);
        }
        set
        {
            PlayerPrefs.SetInt(PROGRESSIVE_APP_LAUNCH_NUMBER_TAG, value);
        }
    }

    private const int NUMBER_OF_EXPERIMENTS = 8;
    private readonly EXPERIMENT[] experiments = new EXPERIMENT[NUMBER_OF_EXPERIMENTS];
    private const string CUSTOM_USER_ID_TAG = "CUSTOM_USER_ID_TAG";
    private const string PROGRESSIVE_APP_LAUNCH_NUMBER_TAG = "PROGRESSIVE_APP_LAUNCH_NUMBER_TAG";

    private void Start()
    {
        Logger.Log("remote", "Start");

        for (int i = 0; i < experiments.Length; i++)
        {
            experiments[i].experimentName = EXPERIMENT.VARIANT_PREFIX + (i + 1).ToString("000");
            experiments[i].experimentVariant = EXPERIMENT.VARIANT_OFF;
        }

        UserAttributes userAttributes = new UserAttributes
        {
            isStarterPackOwned = InterstitialSceneController.IsStarterPackBought(),
            isSpaceCarOwned = InterstitialSpaceCarSceneController.IsSpaceCarOwned(),
        };

        SetNewCustomUserID();
        SetEnvironmentID();
        IncrementAppLaunchNumber();
        ConfigManager.FetchCompleted += ApplyRemoteSettings;
        ConfigManager.FetchConfigs(userAttributes, new AppAttributes());
    }

    public string GetExperimentVariantByNumber(int experimentNumber)
    {
        string experimentName = EXPERIMENT.VARIANT_PREFIX + experimentNumber.ToString("000");
        for (int i = 0; i < experiments.Length; i++)
        {
            if (experiments[i].experimentName == experimentName)
            {
                return experiments[i].experimentVariant;
            }
        }
        // we could not find the specified experiment, we assume it's off
        return EXPERIMENT.VARIANT_OFF;
    }

    private void ApplyRemoteSettings(ConfigResponse configResponse)
    {
        if(configResponse.status != ConfigRequestStatus.Success)
        {
            Logger.Log("remote", "the remote config request was not successful but " + configResponse.status);
            return;
        }

        switch (configResponse.requestOrigin)
        {
            case ConfigOrigin.Default:
                Logger.Log("remote", "no settings loaded this session; using default values");
                break;

            case ConfigOrigin.Cached:
                Logger.Log("remote", "no settings loaded this session; using cached values from a previous session");
                break;

            case ConfigOrigin.Remote:
                Logger.Log("remote", "new settings loaded this session; update values accordingly");
                Logger.Log("remote", "origin: " + ConfigManager.appConfig.origin);

                for (int i = 0; i < experiments.Length; i++)
                {
                    experiments[i].experimentVariant = ConfigManager.appConfig.GetString(experiments[i].experimentName);
                    TrackExperimentNamed(experiments[i].experimentName, experiments[i].experimentVariant);
                }

                break;
        }
    }

    private void SetNewCustomUserID()
    {
        if (string.IsNullOrEmpty(PlayerPrefs.GetString(CUSTOM_USER_ID_TAG, "")))
        {
            DateTime epochStart = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            long millisecondsSinceEpoch = (long)(DateTime.UtcNow - epochStart).TotalMilliseconds;
            PlayerPrefs.SetString(CUSTOM_USER_ID_TAG, millisecondsSinceEpoch.ToString());

            Logger.Log("remote", "saving this date to playerprefs: " + millisecondsSinceEpoch.ToString());
        }
        string customerUserID = PlayerPrefs.GetString(CUSTOM_USER_ID_TAG, "");
        ConfigManager.SetCustomUserID(customerUserID);

        Logger.Log("remote", "customerUserID: " + customerUserID);
    }

    private void SetEnvironmentID()
    {
#if COLTO_PRODUCTION
        const string RELEASE_REMOTE_CONFIG_ID = "89b434b0-0130-4f16-9a65-8ff7cb1bb240";
        ConfigManager.SetEnvironmentID(RELEASE_REMOTE_CONFIG_ID);
#else
        const string DEVELOPMENT_REMOTE_CONFIG_ID = "83d54126-f1e9-4e7e-87f8-163ad58c0267";
        ConfigManager.SetEnvironmentID(DEVELOPMENT_REMOTE_CONFIG_ID);
#endif
    }

    private void IncrementAppLaunchNumber()
    {
        ProgressiveAppLaunchNumber++;
    }

    private void TrackExperimentNamed(string experimentName, string experimentVariant)
    {
        Logger.Log("remote", experimentName + ": " + experimentVariant);

        AnalyticsController.SendCustomEvent(AnalyticsController.ANALYTICS_EVENT.CKN_EXPERIMENT,
        new Dictionary<string, object>
        {
            { AnalyticsController.GetReadableEventName(AnalyticsController.ANALYTICS_PROPERTY.CKN_EXPERIMENT_NAME), experimentName },
            { AnalyticsController.GetReadableEventName(AnalyticsController.ANALYTICS_PROPERTY.CKN_EXPERIMENT_VARIANT), experimentVariant },
        });
    }
}

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

Got it thanks, just wanted to make sure.

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.

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.

Yes, we just identified the issue and rolling out an update.

The issue has been resolved, please try again? Also mentioned here Unity remote not updating new values through script - Unity Services - Unity Discussions

It works fine now. Thank you!

3 Likes

It looks like it’s working now! Thanks for the super quick fix @JeffDUnity3D !

1 Like

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.

I’ve tested this morning and it seems to work on my machine. @Havokki do you still have the issue?

Yeah, it was working again today.

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

If you don’t mind, may I ask you how you modified the configs to limit this in the future?