Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

A lot of OverflowException from IAP plugin

Discussion in 'Unity IAP' started by YuriBazila, Jan 28, 2019.

  1. YuriBazila

    YuriBazila

    Joined:
    Feb 1, 2013
    Posts:
    43
    Hi,

    From Jan 8 there are a lot of exceptions from IAP plugin in my project.
    I've used Unity 2018.3.2 and now I'm using 2018.3.3. IAP plugin is up to date

    Code (JavaScript):
    1. OverflowException: Value was either too large or too small for a character.: java.lang.Throwable:
    2. System.Convert.ToChar (System.Int32 value) (at <00000000000000000000000000000000>:0)
    3. UnityEngine.Purchasing.MiniJSON.Json+Parser.EatWhitespace () (at <00000000000000000000000000000000>:0)
    4. UnityEngine.Purchasing.MiniJSON.Json+Parser.get_NextToken () (at <00000000000000000000000000000000>:0)
    5. UnityEngine.Purchasing.MiniJSON.Json+Parser.Parse (System.String jsonString) (at <00000000000000000000000000000000>:0)
    6. UnityEngine.Purchasing.JSONSerializer.DeserializeProductDescriptions (System.String json) (at <00000000000000000000000000000000>:0)
    7. UnityEngine.Purchasing.JSONStore.OnProductsRetrieved (System.String json) (at <00000000000000000000000000000000>:0)
    8. UnityEngine.Purchasing.Extension.UnityUtil.Update () (at <00000000000000000000000000000000>:0)
    9.  
    10.     at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
    11.     at com.unity3d.player.UnityPlayer.c(Unknown Source)
    12.     at com.unity3d.player.UnityPlayer$e$2.queueIdle(Unknown Source)
    13.     at android.os.MessageQueue.next(MessageQueue.java:207)
    14.     at android.os.Looper.loop(Looper.java:123)
    15.     at com.unity3d.player.UnityPlayer$e.run(Unknown Source)
    Code (JavaScript):
    1. OverflowException: Value is greater than Char.MaxValue or less than Char.MinValue: java.lang.Throwable:
    2. System.Convert.ToChar (Int32 value)
    3. UnityEngine.Purchasing.MiniJSON.Json+Parser.EatWhitespace ()
    4. UnityEngine.Purchasing.MiniJSON.Json+Parser.get_NextToken ()
    5. UnityEngine.Purchasing.MiniJSON.Json+Parser.Parse (System.String jsonString)
    6. UnityEngine.Purchasing.JSONSerializer.DeserializeProductDescriptions (System.String json)
    7. UnityEngine.Purchasing.JSONStore.OnProductsRetrieved (System.String json)
    8. UnityEngine.Purchasing.Extension.UnityUtil.Update ()
    9.  
    10.     at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
    11.     at com.unity3d.player.UnityPlayer.c(Unknown Source)
    12.     at com.unity3d.player.UnityPlayer$e$2.queueIdle(Unknown Source)
    13.     at android.os.MessageQueue.next(MessageQueue.java:207)
    14.     at android.os.Looper.loop(Looper.java:123)
    15.     at com.unity3d.player.UnityPlayer$e.run(Unknown Source)
     
  2. YuriBazila

    YuriBazila

    Joined:
    Feb 1, 2013
    Posts:
    43
    Devices stat:
     
  3. YuriBazila

    YuriBazila

    Joined:
    Feb 1, 2013
    Posts:
    43
    android versions stat:
     
  4. YuriBazila

    YuriBazila

    Joined:
    Feb 1, 2013
    Posts:
    43
    It's still happening and I can't find the reason why. Looks like the issue in the IAP plugin on some old devices.
     
  5. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,866
    What happened on Jan 8, did you have a new release go out by chance? Some of those look like Chinese devices, and they would not necessarily be expected to have Google Play installed, but I would expect different error in that case ("class not found"). A Google search did bring up this https://github.com/googlesamples/unity-jar-resolver/issues/135 but it looks like it would not apply in your case.
     
  6. YuriBazila

    YuriBazila

    Joined:
    Feb 1, 2013
    Posts:
    43
    Thank you for the respose!
    I'm sorry for Jan 8, it was earlier too. It's happening from the release date.
    Countries where it is happening are very different. We had a lot of installs from China two weeks ago, but the number of exceptions not increased a lot. So I don't think google play is a problem.
    We can't even reproduce that exception, so that is also a problem.
     
  7. YuriBazila

    YuriBazila

    Joined:
    Feb 1, 2013
    Posts:
    43
    Is Unity IAP open source? Can we look inside UnityEngine.Purchasing.JSONSerializer.DeserializeProductDescriptions for example?
     
  8. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,866
    Sorry it is not open source. Can you list what your product descriptions look like?
     
  9. YuriBazila

    YuriBazila

    Joined:
    Feb 1, 2013
    Posts:
    43
    We have 7 inapp purchases.

    Titles and descriptions are just a strings without any special chars, emodjes etc.

    Special WINTER PACK
    Coins Storage
    Handful of Coins
    Pile of Coins
    Pinch of Coins
    Stack of Coins
    Starter Pack

    We have only English-US localization of products
     
  10. YuriBazila

    YuriBazila

    Joined:
    Feb 1, 2013
    Posts:
    43
    We don't use IAP catalog from Unity IAP. We initialize products in code

    Code (CSharp):
    1. public void Init()
    2.         {
    3.             // If we have already connected to Purchasing ...
    4.             if (IsInitialized())
    5.             {
    6.                 // ... we are done here.
    7.                 return;
    8.             }
    9.  
    10.             // Create a builder, first passing in a suite of Unity provided stores.
    11.             var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
    12.  
    13.             foreach (var p in Core.GameData.AppStoreData.products)
    14.             {
    15.                 builder.AddProduct(p.PlatformStoreId, p.productType);
    16.             }
    17.  
    18.             // Kick off the remainder of the set-up with an asynchrounous call, passing the configuration
    19.             // and this class' instance. Expect a response either in OnInitialized or OnInitializeFailed.
    20.             UnityPurchasing.Initialize(this, builder);
    21.         }
     
  11. Vasiliy-V-V

    Vasiliy-V-V

    Joined:
    Dec 9, 2013
    Posts:
    4
    I have many exceptions with "OverflowException" too. Did you find a solution? I'm on Unity 2018.3.6f1 and InAppPurchasing 2.0.6.

    Screen with stats from Unity Dashboard: https://monosnap.com/file/CsP1PMjN15JqZobeIBEPZoR6pLJY0x

    It's started after updating the app.

    Example of stacktrace with error:

    OverflowException: Value was either too large or too small for a character.
    System.Convert.ToChar (System.Int32 value) (at <44c33aa1c27b467bb7db82cd2e404e81>:0)
    UnityEngine.Purchasing.MiniJSON.Json+Parser.get_PeekChar () (at <df6ad794a9e84e21b2a1e28d0e640cbf>:0)
    UnityEngine.Purchasing.MiniJSON.Json+Parser.EatWhitespace () (at <df6ad794a9e84e21b2a1e28d0e640cbf>:0)
    UnityEngine.Purchasing.MiniJSON.Json+Parser.get_NextToken () (at <df6ad794a9e84e21b2a1e28d0e640cbf>:0)
    UnityEngine.Purchasing.MiniJSON.Json+Parser.ParseValue () (at <df6ad794a9e84e21b2a1e28d0e640cbf>:0)
    UnityEngine.Purchasing.MiniJSON.Json+Parser.Parse (System.String jsonString) (at <df6ad794a9e84e21b2a1e28d0e640cbf>:0)
    UnityEngine.Purchasing.MiniJSON.Json.Deserialize (System.String json) (at <df6ad794a9e84e21b2a1e28d0e640cbf>:0)
    UnityEngine.Purchasing.MiniJson.JsonDecode (System.String json) (at <df6ad794a9e84e21b2a1e28d0e640cbf>:0)
    UnityEngine.Purchasing.JSONSerializer.DeserializeProductDescriptions (System.String json) (at <608cd934032f415995a47e21f14f1980>:0)
    UnityEngine.Purchasing.JSONStore.OnProductsRetrieved (System.String json) (at <608cd934032f415995a47e21f14f1980>:0)
    UnityEngine.Purchasing.ScriptingUnityCallback+<>c__DisplayClass4_0.<OnProductsRetrieved>b__0 () (at <608cd934032f415995a47e21f14f1980>:0)
    UnityEngine.Purchasing.Extension.UnityUtil.Update () (at <608cd934032f415995a47e21f14f1980>:0)

    @JeffDUnity3D please help.
     
  12. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,866
    Make sure you are using Unity IAP 1.20.1. Go to the Services window in Unity (menu Window/Services or Window/General/Services) and click on the In App Purchasing tab to confirm. And as a test, compare to the Sample Project here: https://forum.unity.com/threads/sample-iap-project.529555/
     
  13. Vasiliy-V-V

    Vasiliy-V-V

    Joined:
    Dec 9, 2013
    Posts:
    4
    Thanks for the answer. I have made some investigations on my changes. And I have changed in Unity Scripting Runtime Version from "NET 3.5(Deprecated)" to "NET 4.x". After that innaps stopped working. I have tried to update Unity IAP to 1.20.1 and last Unity 2018.3.8f1, but error the same.
    Today I have changed Scripting Runtime Version back to "NET 3.5(Deprecated)" and error is gone and innaps start working correctly.
    Does Unity IAP must working with "NET 4.x"? (Scripting Backed is Mono, Api Compatibility Level is .NET 2.0)
    EDIT: Forgot to say that this problem only on Android 5.1 and earlier.
     
    Last edited: Mar 13, 2019
  14. mkg2w

    mkg2w

    Joined:
    Aug 19, 2013
    Posts:
    35
    We also came across the same issue and discovered we had to downgrade to .net 3.5 to support devices such as Galaxy J2.
    is there a fix planned for Unity IAP ?
     
  15. Zamaroht

    Zamaroht

    Joined:
    Nov 4, 2013
    Posts:
    7
    We have been receiving a lot of exception reports with this same stacktrace after releasing to production. We are building with Unity 2018.3 and .Net 4.x
     
  16. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,866
    Are you using IAP 1.22?
     
  17. Tomi-Tukiainen

    Tomi-Tukiainen

    Joined:
    Jun 8, 2013
    Posts:
    9
    Hi, I've noticed that MiniJSON produces JSON that it has problems parsing in the .NET 4.x Equivalent Scripting Runtime version. In some cultures it can use "," as the decimal separator and that breaks JSON parsing. An example JSON output would be {"t":2,"v":8,0505771636962891}.

    Test code to deserialize this...

    object test = MiniJSON.Json.Deserialize("{\"t\":2,\"v\":8,0505771636962891}");

    ...will produce an Exception:

    OverflowException: Value was either too large or too small for a character.
    System.Convert.ToChar (System.Int32 value) (at <44c33aa1c27b467bb7db82cd2e404e81>:0)
    UnityEngine.Purchasing.MiniJSON.Json+Parser.get_PeekChar () (at <df6ad794a9e84e21b2a1e28d0e640cbf>:0)
    UnityEngine.Purchasing.MiniJSON.Json+Parser.EatWhitespace () (at <df6ad794a9e84e21b2a1e28d0e640cbf>:0)
    UnityEngine.Purchasing.MiniJSON.Json+Parser.get_NextToken () (at <df6ad794a9e84e21b2a1e28d0e640cbf>:0)
    ...


    Fixing this:

    - In earlier Unity versions Thread's CurrentCulture was always InvariantCulture, that's why MiniJSON (and a lot of other code) worked. Quick fix for all is the following somewhere in your initialization code:

    System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

    - For the new Unity Runtime, MiniJSON should be patched so that it formats decimal numbers using InvariantCulture, currently it uses ToString("R") which is culture specific. Replace these with ToString("R", System.Globalization.CultureInfo.InvariantCulture).
     
    Last edited: May 22, 2019
  18. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,866
    Thanks for the info, I will pass it along!
     
  19. Prophet1111

    Prophet1111

    Joined:
    Mar 16, 2016
    Posts:
    19
    Is there a fix for this issue?

    I'm using .NET 3.5 Equivalent, and getting this OverflowException as well.



    Non-fatal Exception: java.lang.Exception: OverflowException : Value is greater than Char.MaxValue or less than Char.MinValue
    at System.Convert.ToChar(System.Convert)
    at UnityEngine.Purchasing.MiniJSON.Json+Parser.EatWhitespace(UnityEngine.Purchasing.MiniJSON.Json+Parser)
    at UnityEngine.Purchasing.MiniJSON.Json+Parser.get_NextToken(UnityEngine.Purchasing.MiniJSON.Json+Parser)
    at UnityEngine.Purchasing.MiniJSON.Json+Parser.Parse(UnityEngine.Purchasing.MiniJSON.Json+Parser)
    at UnityEngine.Purchasing.JSONSerializer.DeserializeProductDescriptions(UnityEngine.Purchasing.JSONSerializer)
    at UnityEngine.Purchasing.JSONStore.OnProductsRetrieved(UnityEngine.Purchasing.JSONStore)
    at UnityEngine.Purchasing.Extension.UnityUtil.Update(UnityEngine.Purchasing.Extension.UnityUtil)


    98% Android 5.X.
     
  20. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,866
    What country locale? Can you confirm it is non-US?
     
  21. Prophet1111

    Prophet1111

    Joined:
    Mar 16, 2016
    Posts:
    19
    @JeffDUnity3D Unfortunetely I don't have data to confirm it's non-US (or US).
    Worse ratings in the store are from Russia and Germany (a lot worse!), so I assume it's connected...
     
  22. Prophet1111

    Prophet1111

    Joined:
    Mar 16, 2016
    Posts:
    19
    I managed to find a Android 5.0 device with polish language set (game is also translated to polish) and can't find the way to make it work. OverflowException is there no matter what I do.
     
  23. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,866
    Got it, we will take a look. Sounds like an issue with non-US locale.
     
  24. Prophet1111

    Prophet1111

    Joined:
    Mar 16, 2016
    Posts:
    19
    @JeffDUnity3D Is there any ETA for the fix?
    I'm really getting a lot of bad reviews as well as losing players due to unplayable game :/
     
  25. Prophet1111

    Prophet1111

    Joined:
    Mar 16, 2016
    Posts:
    19
  26. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    9
    We found that having emoji in the name of app may cause this problem. This could happen on devices with Android versions equal to or less than 5.

    Do you have any emoji in your app name? You can follow these steps to confirm or change it:

    Go to Google Developer Console -> Choose app - > Store presence -> Store listing -> Title.

    upload_2019-6-19_15-47-2.png
     
  27. Prophet1111

    Prophet1111

    Joined:
    Mar 16, 2016
    Posts:
    19
    I do have emoji in the title. I'll try to remove it and find out if it helps.

    Is there any fix coming in the future? I really like my emoji in the title :)

    EDIT:
    It seems to be working. I don't see this exception on my test device anymore. Thank you for your help.
    I still think you should fix it so we can use emoji in the app name ;)
     
    Last edited: Jun 19, 2019
  28. cometa93

    cometa93

    Joined:
    Mar 5, 2014
    Posts:
    21
    Up^^ is there update under the issue? We encountered the same problem.
     
  29. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    9
    Hello, this issue has been reported and is in the process of being fixed. So far there is no expected time, if there is any progress I will post here. To avoid this issue, please do not include emojis in the name of the application at this time.