Search Unity

getSubscriptionInfo() method crashes on Android.

Discussion in 'Unity IAP' started by MorenoBralts, Jun 5, 2018.

  1. MorenoBralts

    MorenoBralts

    Joined:
    May 23, 2017
    Posts:
    19
    Hi there, I'm experiencing a crash when trying to check if a subscription on Android is active.

    UnityIAP : 1.19
    Unity: 2017.4.1f2

    I'm using the following code ( With some extra logging ) :

    Code (CSharp):
    1.        if (!IsInitialized)
    2.             return false;
    3.  
    4.         if (storeController == null || storeController.products == null)
    5.             return false;
    6.  
    7.         Debug.Log("Retrieving all products...");
    8.         Product[] products = storeController.products.all;
    9.  
    10.         Debug.Log("Retrieved all products!");
    11.  
    12.         foreach (Product product in products)
    13.         {
    14.             if (product.definition.type != ProductType.Subscription)
    15.                 continue;
    16.  
    17.             if (product.definition.id != iapIdentifier)
    18.                 continue;
    19.  
    20.             Debug.Log("found sub " + iapIdentifier);
    21.  
    22.             if (!product.hasReceipt)
    23.                 continue;
    24.  
    25.             Debug.Log("Product has receipt! " + iapIdentifier);
    26.  
    27.             if (!checkIfProductIsAvailableForSubscriptionManager(product.receipt))
    28.                 continue;
    29.  
    30.             Debug.Log("Product is 1.19 compatible! " + iapIdentifier);
    31.  
    32.             string intro_json = null;
    33.             appleIntroductoryPriceDictionary.TryGetValue(product.definition.storeSpecificId, out intro_json);
    34.  
    35.             Debug.Log("Generating subscriptionManager! " + iapIdentifier);
    36.  
    37.             SubscriptionManager p = new SubscriptionManager(product, intro_json);
    38.  
    39.             Debug.Log("Retrieving sub info! " + iapIdentifier);
    40.  
    41.             // This call seems to cause a crash.
    42.             SubscriptionInfo info = p.getSubscriptionInfo();
    43.  
    44.             Debug.Log("Retrieving isSubscribed State! " + iapIdentifier);
    45.             return info.isSubscribed() == Result.True;
    46.  
    47.  
    48.            
    49.         }
    50.  
    51.         return false;

    Here is the error log that I'm receiving :

    06-05 16:08:27.735: E/CRASH(17866): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
    06-05 16:08:27.735: E/CRASH(17866): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    06-05 16:08:27.735: E/CRASH(17866): Build fingerprint: 'samsung/zerofltexx/zeroflte:7.0/NRD90M/G920FXXU6ERC1:user/release-keys'
    06-05 16:08:27.735: E/CRASH(17866): Revision: '11'
    06-05 16:08:27.735: E/CRASH(17866): r0 00000000 r1 af855618 r2 00000000 r3 ceda5e02
    06-05 16:08:27.735: E/CRASH(17866): r4 a4c13000 r5 af855798 r6 00000001 r7 a7e85af0
    06-05 16:08:27.735: E/CRASH(17866): r8 b3922f0c r9 c2bd1110 sl 0000eff4 fp bfd7da58
    06-05 16:08:27.735: E/CRASH(17866): ip bfd7db20 sp bfd7da58 lr af679648 pc af6799b8 cpsr c2c99d10
    06-05 16:08:27.735: E/CRASH(17866): backtrace:
    06-05 16:08:27.737: E/CRASH(17866): #00 pc 000089b8 ( System.Xml.XmlConvert:ToTimeSpan (string) + 0x38 (0xaf679980 0xaf679f4c) [0xbf8e4ee0 - Unity Root Domain]+35256)
    06-05 16:08:27.737: E/CRASH(17866): #01 pc 00008644 ( UnityEngine.Purchasing.SubscriptionInfo:.ctor (string,bool,System.DateTime,bool,bool,bool) + 0x1174 (0xaf6784d0 0xaf679858) [0xbf8e4ee0 - Unity Root Domain]+34372)
    06-05 16:08:27.737: E/CRASH(17866): #02 il ........ at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke (object,object[],System.Exception&) <IL 0x00030, 0xffffffff>
    06-05 16:08:27.737: E/CRASH(17866): #03 il 00000184 at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) [0x000c0] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222
    06-05 16:08:27.738: E/CRASH(17866): #04 il 0000004b at System.Reflection.MethodBase.Invoke (object,object[]) [0x00000] in /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115
    06-05 16:08:27.738: E/CRASH(17866): #05 il 0000010b at Opencoding.CommandHandlerSystem.MethodCommandHandler.Invoke (string[]) <IL 0x00080, 0x0010b>
    06-05 16:08:27.738: E/CRASH(17866): #06 il 000002bf at Opencoding.CommandHandlerSystem.CommandHandlers.HandleCommand (string) <IL 0x00139, 0x002bf>
    06-05 16:08:27.738: E/CRASH(17866): #07 il 00000053 at Opencoding.Console.HelpOverlay.HandleButtonPress (Opencoding.CommandHandlerSystem.CommandHandler,bool) <IL 0x00016, 0x00053>
    06-05 16:08:27.738: E/CRASH(17866): #08 il 00000643 at Opencoding.Console.HelpOverlay.OnGUI (UnityEngine.Rect) <IL 0x001cf, 0x00643>
    06-05 16:08:27.738: E/CRASH(17866): #09 il 00000213 at Opencoding.Console.DebugConsole.OnGUI () <IL 0x0009c, 0x00213>
    06-05 16:08:27.738: E/CRASH(17866): #10 il 0000006b at (wrapper runtime-invoke) object.runtime_invoke_void__this__ (object,intptr,intptr,intptr) <IL 0x0001c, 0x0006b>



    When looking at the logs it seems like the

    System.Xml.XmlConvert:ToTimeSpan
    method seems to be causing a crash which was called from
    UnityEngine.Purchasing.SubscriptionInfo
    .
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    I will research this and see if I can reproduce the error.
     
  3. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    I wasn't able to reproduce using Unity 2018.1.0f1 and IAP 1.19. I was able to get the subscription getExpireDate without error. I'm testing on a US-English locale device, can you confirm?
     
  4. MorenoBralts

    MorenoBralts

    Joined:
    May 23, 2017
    Posts:
    19
    Able to reproduce using the following configuration:

    Unity 2017.4.1f1
    IAP 1.19
    Samsung Galaxy S6
    Android 7.0
    Language 'English' with region 'United Kingdom'.

    I'll test again using the same region as yours in a bit.
     
  5. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    We are not able to reproduce this crash on a Samsung S4 using IAP 1.19 and setting the Language 'English' with region 'United Kingdom'. If you could, please provide a sample project that reproduces the issue. You could start with the sample project here: https://forum.unity.com/threads/sample-iap-project.529555/