Search Unity

Offline but ConfigOrigin set to Remote

Discussion in 'Unity Remote Config' started by petera1980, Sep 20, 2020.

  1. petera1980

    petera1980

    Joined:
    Jan 29, 2016
    Posts:
    51
    Hello,

    I use Unity 2019.4.9f1

    I always get ConfigOrigin.Remote when I run in offline. I tried on mobile - the same.
    I tried [1.2.3] and [1.2.4-preview.4].

    Switch statements worked correctly with v1.09 for me.

    Code (CSharp):
    1. private void ApplyRemoteSettings(ConfigResponse cr)
    2.     {
    3.         switch (cr.requestOrigin)
    4.         {
    5.             case ConfigOrigin.Default:
    6.                 Debug.Log("No settings loaded this session; using default values.");
    7.                 break;
    8.             case ConfigOrigin.Cached:
    9.                 Debug.Log("No settings loaded this session; using cached values from a previous session.");
    10.                 break;
    11.            [B] case ConfigOrigin.Remote: [/B]
    12.                 Debug.Log("New settings loaded this session; update values accordingly.");
    13.                
    14.                 break;
    15.         }
    16.     }
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    11,690
  3. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    11,690
    Can you actually try to load specific values? Your case statements are empty, can you retrieve values at that point and confirm that remote values or cached values are used? Provide the output of your Debug.Log statements and the server-side values and the last cached expected value.
     
  4. petera1980

    petera1980

    Joined:
    Jan 29, 2016
    Posts:
    51
    Yes, in online mode all values are retried and cached. Also all values that I change in web site are also changed in the next reload of game.
    But, if I delete the cache file (json) manually, simulating the android clean app cache option and close internet connection on mobile, then value that I get is 0 as default static variable assignment in cs. (if I had set it to 0.5f then I will got 0.5f)

    The problem is that even in offline mode and with existing cached json file the requestOrigin return ConfigOrigin.Remote instead of ConfigOrigin.Default BUT whatever read from json cached file and return json's cached values.
     
  5. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    11,690
    Please provide specific steps to reproduce, sorry I'm not quite following. Please provide your Debug.Log output and the corresponding code so I can try to reproduce here, as requested. It sounds like what you are saying that it's properly reading the local cache after a previous successful connection, but it's triggering/returning the wrong requestOrigin (Remote vs Cached). You are also deleting files. Can you elaborate on the "android clean app cache option"?
     
  6. petera1980

    petera1980

    Joined:
    Jan 29, 2016
    Posts:
    51
    Hello,
    Remote Config 1.2.3 or 1.4.0 preview 1 (get the same result)
    Unity 2019.4.9f1

    This is code in awake :

    Code (CSharp):
    1.  void Awake()
    2.     {
    3.        ConfigManager.FetchCompleted += ApplyRemoteSettings;
    4.         ConfigManager.FetchConfigs<userAttributes,        appAttributes>(new userAttributes(), new appAttributes());
    5. }
    Then

    Code (CSharp):
    1.  private void ApplyRemoteSettings(ConfigResponse cr)
    2.     {
    3.        [B] print(cr.requestOrigin);[/B]
    4.         switch (cr.requestOrigin)
    5.         {
    6.        
    7.             case ConfigOrigin.Default:
    8.                 Debug.Log("No settings loaded this session; using default values.");
    9.                 break;
    10.             case ConfigOrigin.Cached:
    11.                 Debug.Log("No settings loaded this session; using cached values from a previous session.");
    12.                 break;
    13.             case ConfigOrigin.Remote:
    14.                 Debug.Log("New settings loaded this session; update values accordingly.");
    15.                 RemoteConfigValues.VirtualCamera.DeadZoneWidth = ConfigManager.appConfig.GetFloat("DeadZoneWidth");
    16.                 RemoteConfigValues.VirtualCamera.DeadZoneHeight = ConfigManager.appConfig.GetFloat("DeadZoneHeight");
    17.                 break;
    18.         }
    19.     }
    Then I disable Ethernet in PC imitating offline. I get the following code :

     
    Last edited: Sep 27, 2020
  7. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    11,690
  8. petera1980

    petera1980

    Joined:
    Jan 29, 2016
    Posts:
    51
    I added SetEnvironmentID but the the problem still exists.

    In offline it still shown cr.requestOrigin == ConfigOrigin.Remote

    It is weird that the R.C does not understand whether it is online or offline because it is not set SetEnvironmentID.

    Code (CSharp):
    1.  
    2.  void Awake()
    3.     {
    4. ConfigManager.SetEnvironmentID("fa1398cc-4780-4913-a982-e06b05245b7d");
    5. ConfigManager.FetchCompleted += ApplyRemoteSettings;
    6. ConfigManager.FetchConfigs<userAttributes, appAttributes>(new userAttributes(), new appAttributes());
    7. }
    8.  
     
  9. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    11,690
    I suspect if you are deleting the cache between sessions or similar, it would show as Remote. What would your expectation be? It's not Default because it expects Cached, it's not Cached because you deleted it.
     
  10. petera1980

    petera1980

    Joined:
    Jan 29, 2016
    Posts:
    51
    1) With deleted cache file it shows Remote in offline mode.
    2)Why it is expects cache if cache file do not exists ? Maybe some checks in code will fix this bug.
    3)With cache file and offline mode it still shown Remote instead of Cached, but bring values from cached file.
    If I manually change values in RemoteConfig.json I will see new values in Console but in ConfigOrigin.Remote case statement not in ConfigOrigin.Cached.

    I tried to move initialization code from Awake to Start but the same.

    It is not big problem, this case it is rare to occur.
     
  11. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    11,690
    It would not be a bug if you've deleted a resource, but a feature request. It should not say Cached if Cached is not available. Again, what is your expectation if the user does this? What switch statement would you like to add, since your use-case doesn't seem to fit into the current ones. If it is expecting Cached but someone deleted the cache, would you expect it to go back to Default, or a new value.
     
  12. petera1980

    petera1980

    Joined:
    Jan 29, 2016
    Posts:
    51
    I expect to go to Default in this case.
    If cache file do not exists and no internet connection exists this meas that I have to provide default values to user.
    But I get 0 in all variables in this case because no cache exists and it is offline and system still return Remote...

    Why Default then exists in switch if never used ?

    As I mentioned before only version 1.0.9 falls into Default. All other versions return Remote.
     
  13. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    11,690
    Sorry I don't follow. Default is used if there is no Internet connection and there hasn't been a previous session. That's not the case here. You've deleted files. Returning Default in this case would be difficult to support for you. Users would call into you complaining they lost progress or similar. You wouldn't know if they are first time users or just deleted their cache somehow, you haven't specified the process.
     
  14. petera1980

    petera1980

    Joined:
    Jan 29, 2016
    Posts:
    51
    Ok I got it. I did not understand algorithm of RC well.

    Thank you for explanation.
     
    JeffDUnity3D likes this.
  15. monu98

    monu98

    Joined:
    Sep 7, 2020
    Posts:
    5
    @JeffDUnity3D Do we have to write some code in ConfigOrigin.Cached or it will automatically fetch from a cached file?

    Thank you
     
  16. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    11,690
    Automatically, give it a test!
     
unityunity