Quickstart-unity: Remote Config Unable to parse double values when device language is Russian or French

Created on 16 Dec 2020  路  4Comments  路  Source: firebase/quickstart-unity

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2020.1.17f
  • Firebase Unity SDK version: 7.0.1
  • Source you installed the SDK: Unity Package Manager
  • Problematic Firebase Component: Remote Config
  • Other Firebase Components in use: Auth, Realtime Database, Analytics, Dynamic Links, Cloud Messaging, Crashlytics
  • Additional SDKs you are using: Facebook, Applovin MAX
  • Platform you are using the Unity editor on: Mac
  • Platform you are targeting: iOS, Android
  • Scripting Runtime: Mono and il2cpp

[REQUIRED] Please describe the issue here:

FirebaseRemoteConfig.GetValue(key).DoubleValue gives an Exception when device language is set to French or Russian.
On investigating, it's found that languages like French or Russian use ',' instead of '.' in their fractional values. So, a value of '0.25' in French will be '0,25'.

So, when a remote config double value is fetched it throws the exception.

If you use FirebaseRemoteConfig.GetValue(key).StringValue, value is printed correctly.

Steps to reproduce:

  1. Create a double value on Remote Config dashboard.
  2. Fetch it in code using FirebaseRemoteConfig.GetValue(key).DoubleValue
  3. Change your iOS or Android device language to French or Russian, run the app and you will get the exception.

Workaround:

if (Single.TryParse(FirebaseRemoteConfig.GetValue(key).StringValue, NumberStyles.Float, CultureInfo.InvariantCulture, out val)) {
                return val;
            }
remoteconfig bug

All 4 comments

Thanks for this report! If you wouldn't mind confirming that you see this behaviour with the quick start app, I'll be able to pull this in as a bug.

Thanks for this report! If you wouldn't mind confirming that you see this behaviour with the quick start app, I'll be able to pull this in as a bug.

Yes, seeing the same behavior in quick start app as well.

@kashif789us thanks for testing and verifying that you can reproduce this issue in quickstart app.
We will look into this and keep you posted.

Seems to be an issue in Unity SDK when we convert string to double using System.Convert.ToDouble(StringValue), without passing IFormatProvider.

This should be System.Convert.ToDouble(StringValue, CultureInfo.InvariantCulture) instead.

I'll prepare a patch for this. At the meantime, you can use your workaround or simply double.Parse(FirebaseRemoteConfig.GetValue(key).StringValue, CultureInfo.InvariantCulture)

Sorry for the inconvenience

Shawn

Was this page helpful?
0 / 5 - 0 ratings