Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[Solved] IAP Initialization Not Completing ~5%

Discussion in 'Unity IAP' started by albert8716, Feb 21, 2020.

  1. albert8716

    albert8716

    Joined:
    Nov 14, 2019
    Posts:
    8
    • Description of your issue

      • All though IAP is working great most of the time, about 5% of app launches result in an IAP that is never initialized with no Success or Failure callback

      • The error occurs both on AOS and iOS

      • There is no critical error reported in logcat but an app launch with successful IAP initialization has log differences to that with IAP failure (attached files)

      • The first error seems to occur when the ConfigurationBuilder is made.

      • Then products are added to the builder as normal

      • ‘UnityIAP: invoking callback’ does not succeed, no further behavior from UnityIAP
    • Your purchasing script

      • Attached as (EXIAPService) -> Line 33/34 is where the inconsistency in logcat emerges.
    • Device logs

      • Logcat attached shows the issue from where it occurs on android. *We cannot share the entire logcat as the debug build contains too much information to secure.

      • The included log shows normal running and a failure case

      • Replication of the failure results in the same log inconsistency
    • Unity Version

      • 2018.3.14f1
    • Unity IAP version

      • 1.23.0
    • Platform you are building for

      • AOS

      • iOS
    • Store you are targeting

      • GooglePlay

      • Apple
    • Receipts

      • N/A
     

    Attached Files:

  2. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    600
    Are these devices that failed to initialize logged into a valid Google or Apple account?
     
  3. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please test with 1.23.1
     
  4. albert8716

    albert8716

    Joined:
    Nov 14, 2019
    Posts:
    8
    They are valid Google Play Test and Sandbox accounts. I will confirm the behavior for ver 1.23.1 and reply here. Thanks
     
  5. albert8716

    albert8716

    Joined:
    Nov 14, 2019
    Posts:
    8
    iOS does not appear to have the issue. Sorry for my earlier misunderstanding. Unity IAP is much slower to complete initialization than we had expected. 5-10 seconds on some older devices.

    On AOS I tested 5 devices simultaneously. While they succeeded in initializing about 90% of the time, when one device failed, they all did. I was able to repeat this synchronized failure consistently and without exception. This leads me to believe there is a problem in communicating with either Unity Services or Google Play rather than any client implementation shortcoming. I don’t have any reason to suspect our office wifi as being the cause.

    I also upgraded IAP to 1.23.1 and put that APK onto one device signed into a genuine Google Play account (not a test account). On a second device with IAP 1.23.0 I signed into a Google Play Test account. I launched the app on each device simultaneously and 7 times received successful initialization. On the 8th attempt for each device, initialization did not complete and I did not receive a callback. The issue seems unrelated to the Unity IAP version.

    Edit: On the final test, I checked over a 15 minute period in which I did not receive any callback.
     
  6. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    We (Unity) do not handle any of the transactions, they go directly from the device to the corresponding store. In your case, if you what you claim is true, then an app using Apple or Google library native code would behave the same way. However, we have not heard of this behavior previously, so it appears it may be limited to your code. I might suggest that you publish your own version of the Sample IAP app here, and compare. And you'll want to try on a different network to compare also https://forum.unity.com/threads/sample-iap-project.529555/ If you can narrow it down to a specific OS version or similar, that would be helpful. And by AOS, you mean Android?
     
  7. albert8716

    albert8716

    Joined:
    Nov 14, 2019
    Posts:
    8
    We do not have any problems with transactions. When IAP is initialized successfully, we can always purchase the products. The issue is that Unity IAP sometimes not completing its initialization. No failure or success callback.

    Our assumption was that there is some communication occurring within this initialization either with Unity Services or with the Play Store and that that was for some reason responsible for it not completing the initialization process. If there is no external communication during initialization, it seems very hard to explain the simultaneous noncomplete IAP initializations of multiple devices.

    Yes, this issue is only occurring on android (AOS). It has occurred on the office wifi for my own tests and for our testers playing outside on data and/on other wifi connections. For isolating the issue, my own tests have been done within the office. We did compare our initialization code with the sample code but initialization is 3 main steps (create config builder -> add products -> Init). We do not see where there can be an error except within the creation of the config builder.

    We had a suspicion that the error was with the config builder not being created successfully due to a scene transition but given that we now know the failures are occurring concurrently across devices this seems unlikely.
     
  8. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    I would suggest to compare with the Sample IAP app
     
  9. albert8716

    albert8716

    Joined:
    Nov 14, 2019
    Posts:
    8
    We seem to have resolved the issue after discovering inconsistencies in IAP behavior which were dependent on how the app was shut down previously. If the app was closed with Application.Quit(), IAP initialization callbacks will not be received the next time the app is run. We worked around this using the native library method in this post: https://forum.unity.com/threads/sol...ont-initialize-after-application-quit.665497/
     
  10. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Yes, the Application.Quit behavior is known, and leaves some components still in memory.