Search Unity

Bug Unity IAP 4.5.1, Initialization Failed (Purchasing Unavailable) Errors

Discussion in 'Unity IAP' started by RainBow88, Nov 17, 2022.

  1. RainBow88

    RainBow88

    Joined:
    Mar 16, 2015
    Posts:
    4
    After updating Unity IAP (3.2.3 -> 4.5.1), we have started seeing a large number of “initialization failed” errors of the type PurchasingUnavailable.
    We log these errors to our backend each time we receive an OnInitializeFailed callback from Unity IAP.
    While using our previous version of IAP (3.2.3), these errors were exceptionally rare.

    With Unity IAP 3.2.3, we had a weekly total of just 2 OnInitializeFailed(PurchasingUnavailable) events.
    With Unity IAP 4.5.1, we have seen upwards of 400 events logged per day. On one day, we logged 1480 events from 40 unique users with 1000 of these logs coming from just one user.

    All logs are coming from Android users but for various device types, various Android OS versions, and various countries.
    These users all have GooglePlay available and we have no crash/exception logs for them.

    The events are not sporadic but come as continuous streams from the affected users, we are seeing instances where as many as 18 failure callbacks are received within one second from one user. We have logic in place so that if initialization fails we will not re-attempt it for at least 1 second so multiple OnIntializeFail callbacks should not occur simultaneously.

    It seems most likely to us that IAP 4.5.1 is generally mishandling some uncommon PurchasingUnavailable cases and either repeatedly calling the OnInitializeFail callback for a single initialization failure or internally retrying continuously and calling the OnInitializeFail callback every cycle.

    (Our Development Environment)
    Unity Editor: 2020.3.19f1
    Unity IAP: 4.5.1
    Unity Services Core: 1.5.2
     
  2. lblast

    lblast

    Joined:
    Dec 1, 2016
    Posts:
    68
    Very similar to my situation except I have noticed only on our Amazon platform does Unity IAP fail to initialize with a reason of PurchasingUnavailable. However, if I downgrade back to Unity IAP 4.1.5 purchasing works again.

    Environment
    Unity Editor: 2020.3.16f1
    Unity IAP: 4.5.1
    Unity Services Core: 1.4.0 (I am upgrading to 1.6.0 now and will test shortly)

    Edit: Same result on 1.6.0
     
    Last edited: Nov 17, 2022
  3. Yannick_D

    Yannick_D

    Unity Technologies

    Joined:
    Feb 21, 2022
    Posts:
    231
    Hello,

    Thank you for the detailed report, I was able to identify the cause of this and we will look to solve this soon.
    On GooglePlay, there's a case when attempting to retrieve products while the Google Play Store has failed to connect that will call the OnInitializeFailed once per product. We will look to reduce this to only one callback.


    For the issue on the Amazon platform, would you have a log to help us identify it better? We havn't done much work on Amazon lately and I'm not seeing any changes since 4.1.5 that could cause this.
     
  4. RainBow88

    RainBow88

    Joined:
    Mar 16, 2015
    Posts:
    4
    Thank you for looking into this for us so quickly.

    To supplement the initial report, we have only 6 products configured right now.

    It seems like the identified one callback per product issue explains some of the simultaneous callbacks but there may be a little more to the problem.

    1. Until IAP 4.5.1, we had very few PurchasingUnavailable logs but now many users are affected

    2. Even if a callback is made for all 6 products, this should only happen once. Most of our cases are more than 6 some are up to 1000 PurchasingUnavailable events.
     
  5. Yannick_D

    Yannick_D

    Unity Technologies

    Joined:
    Feb 21, 2022
    Posts:
    231
    1. In 4.2.0-pre.1, we fixed the following which is why you are seeing more cases than before:
    Fixed OnInitializeFailed never called if GooglePlay BillingClient is not ready during initialization.


    2. Can you confirm if those are happening all within 1 second (on the same Initialize call) or if there's 6 per call to Initialize?
    I've taken a look at the code again and it looks like it's the same call that would cause the OnInitializeFailed(PurchasingUnavailable). As long as it's within the same Initialize call, we should be able to limit it to 1.
     
  6. RainBow88

    RainBow88

    Joined:
    Mar 16, 2015
    Posts:
    4
    1. I understand. That explains the increase in unique users seeing this issue.
    2. We don't currently have a log for when we call initialize on IAP, so I cannot be 100% certain how many times the client is calling initialize yet.
      However, I have done a logic review and run a test build. Both of which found that we only call initialize on two occasions:
    i. Once, shortly after the app launches
    ii. Once again if IAP is not initialized (StoreController != null && StoreExtensionProvider != null) when the user manually requests the store by clicking a button. The user has to first confirm a retry popup so there is a physical limit on how many times this can occur.​

    Based on this, I understand that in the vast majority of cases init is likely to only be called once, and in other cases where the user requests the store after a failure, it is likely that the user only tries two or three times over maybe 10 seconds before giving up.

    When checking the logs I made the following observations which lead me to believe that the potential 6x callback is unrelated:​

    iii. I cannot find any instance where 6 OnInitializeFail events are received together.
    iv. Many of the logs seem to come as two logs / one second.
    v. The count is very random, from 2 to up to 155 OnInitializeFail events in the same second. The 155-count user continues streaming these fail logs for another 13 seconds after this. ​

    For data protection reasons I’ve had to strip a lot of information but I can share a day of logs for example of what we are looking at:
     

    Attached Files:

    Yannick_D likes this.
  7. Yannick_D

    Yannick_D

    Unity Technologies

    Joined:
    Feb 21, 2022
    Posts:
    231
    Thank you for taking the time to provide us with all this information!
    We will keep investigating this to better understand how we're getting more than 1 call per product per init and make sure we fix this properly.
     
    RainBow88 likes this.
  8. dogukankse

    dogukankse

    Joined:
    Dec 31, 2017
    Posts:
    1
    Hello,
    We having same issue with Purchasing (4.4.1). We use the same codebase from another project. The other project works just fine with version (4.0.3).
    We have 564 unique users with around 6.5K fail event. We want to upgrade the package but as I can see, the issue present 4.5.1 too.

    We are waiting next release the fix this issue.
     
    elaine_unity694 and RainBow88 like this.
  9. AsiBeachBumGames

    AsiBeachBumGames

    Joined:
    May 25, 2021
    Posts:
    2
    Hello, we are also seeing a marked increase in purchasing unavailable errors leading to an increase in failed purchase user complaints starting on about the seventh of December. (IAP Version 4.4.1)
    We are also seeing multiple error responses returning at the exact same time. Up to eight in the same millisecond.
     
    RainBow88 likes this.
  10. Yannick_D

    Yannick_D

    Unity Technologies

    Joined:
    Feb 21, 2022
    Posts:
    231
    Hello,
    What version of IAP were you using previously?

    The only thing we changed on our end was that those error were previously not sent to the OnInitializeFailed, but that should not have any effect on the behaviour since before it was failing silently.
    The other possibility we see is that something in Google Play Billing v4 changed, but we havn't been able to replicate on our side yet. Any new information is welcome!

    The solution that seems to work so far is to ask the users to log out from all the accounts on their device and log back in.

    For the high volume of errors, this is something we are aware of and we will be fixing this.
     
  11. didonecompany

    didonecompany

    Joined:
    May 24, 2022
    Posts:
    6
    I wonder how you imagine it. this is not a solution.
     
  12. Yannick_D

    Yannick_D

    Unity Technologies

    Joined:
    Feb 21, 2022
    Posts:
    231
    This is the only workaround we currently know of, but we are looking at different possible solutions with a client as we speak. A better solution is being worked on.

    Feel free to provide your logs or any relevant information if you are also encountering this issue.
     
  13. y0rshl

    y0rshl

    Joined:
    Jul 12, 2013
    Posts:
    20
    I have the same issue on my game and users have said that logging out of Google Play hasn't fixed the issue for them.
     
  14. jmcguirkdbg

    jmcguirkdbg

    Joined:
    Jul 10, 2020
    Posts:
    1
    +1 we've seen a substantial uptick in this error since upgrading to 4.5.1
     
  15. Brown2Fox

    Brown2Fox

    Joined:
    Mar 6, 2017
    Posts:
    7
    The same. Even after updating to 4.5.2
     
    elaine_unity694 likes this.
  16. VadimPyrozhok

    VadimPyrozhok

    Joined:
    Jul 28, 2016
    Posts:
    7
    No response here? Having same issues on IAP v4.5.2, v4.5.1, v4.4.1 and v4.1.1
     
  17. Arnaud_Gorain

    Arnaud_Gorain

    Unity Technologies

    Joined:
    Jun 28, 2022
    Posts:
    182
    Hi all,
    There is still no direct fix for this issue yet but it is still under investigation. Feel free to share the details of your investigation as well, it will help to solve this.

    In the meantime, you can refer to:
    Let me know if you have any questions.
     
  18. jlanisdev

    jlanisdev

    Joined:
    Jan 18, 2016
    Posts:
    76
    @agorain Any updates? We're experiencing the same problem

    Unity 2020.3.44f1
    IAP 4.5.2
     
  19. Arnaud_Gorain

    Arnaud_Gorain

    Unity Technologies

    Joined:
    Jun 28, 2022
    Posts:
    182
    This is still under investigation, but we miss details to have it fixed sooner. A new version of IAP SDK (4.6.0) will be released soon, and will include more traces to help us have it fixed.

    I would suggest updating to 4.6.0 when it's released to help us provide a fix, thanks to all collaborators!
     
  20. GSMaxe

    GSMaxe

    Joined:
    May 18, 2022
    Posts:
    2
    We are facing this error in even the older version of TF iOS , which was working well before, but recently all of them have the same errors, of Purchasing unavailable. Is there a workaround anyone has been able to find ?
     
  21. GSMaxe

    GSMaxe

    Joined:
    May 18, 2022
    Posts:
    2
    @agorain , have you guys had more issues reported for iOS too? as I could see above that most people are facing this issue in Android but for us its happening everytime without fail in iOS platform, during purchasing initialization.
     
  22. Arnaud_Gorain

    Arnaud_Gorain

    Unity Technologies

    Joined:
    Jun 28, 2022
    Posts:
    182
    Interesting @GSMaxe, can you share more details on the steps you are reproducing it on iOS, and if you can share any traces of a reproduced test you have? Which version of iap and editor are you on also?
     
  23. YBurakDurmus

    YBurakDurmus

    Joined:
    Feb 15, 2023
    Posts:
    1
    @agorain
    I have the same problem on iOS, too. Starting with this week all apps I have started producing "Product unavailable" warning for all the products and giving init error as "Initialization Failure: No products available". As @GSMaxe mentioned, this issue occurs even in older versions on TF, which were tested and verified that the IAP is working. Interestingly enough, the live apps are working without any problem.

    There was no change on the code, IAP package version (which is 4.5.2 btw and updating the package didn't change anything) or App Store configurations. All of them were working last week but not now. No idea why.
     
    ardacankirkoc likes this.
  24. ssommer_unity

    ssommer_unity

    Joined:
    Aug 6, 2021
    Posts:
    2
    Same issue as @YBurakDurmus , production side of the app still works fine.
    TF versions exhibit the problem for iOS versions 16+, devices with iOS 15 still work fine. Code-wise nothing changed, we use 4.5 and tried updating to 4.5.2 and 4.6 with no improvements.

    Edit: Rarely it retrieves a few items out of the defined but never all of them
     
    Last edited: Feb 21, 2023
  25. DaedalusGames

    DaedalusGames

    Joined:
    Aug 12, 2018
    Posts:
    7
    Hi @ssommer_unity I have exact same problem as you, have opened thread yesterday about it:
    https://forum.unity.com/threads/iap-items-stopped-showing.1402510/

    Nothing was changed code wise, IAP items simply stopped showing in production on iOS and Android, only one item is showing out of five.

    Using "com.unity.purchasing": "4.5.0".

    Was hoping that updating to 4.6 will solve this issue, will update here and inside my thread if I found solution to this.
     
  26. Yannick_D

    Yannick_D

    Unity Technologies

    Joined:
    Feb 21, 2022
    Posts:
    231
    Hello,
    It seems there was an issue on Apple's side introduced in iOS 16.0 that was fixed in 16.1+
    https://developer.apple.com/forums/thread/715696

    Could you confirm if this matches the versions of the devices you are experiencing this issue with?
    If the problem still occurs with 16.1+, would it be possible to see your device logs to have more information on the issue?
     
  27. ssommer_unity

    ssommer_unity

    Joined:
    Aug 6, 2021
    Posts:
    2
    Hi,
    for us Android and iOS TF with a version < 16 works fine. The production side of Android and iOS works for all versions.
    The issue is present on TF for all iOS version > 16, so far we tested 16.1, 16.2, 16.3.1. Updating the IAP package to a version > 4.5 did not fix the issue.

    As for the logs, I had to strip all non IAP related logs and change the ones identifying the app or products. Let me know if that helps in any form. The log is obtained from an iPhone X (iOS version 16.3.1) running a locally built iOS build using the IAP package version 4.6 but looks the same using packages 4.5 or 4.5.2.
     

    Attached Files:

  28. Yannick_D

    Yannick_D

    Unity Technologies

    Joined:
    Feb 21, 2022
    Posts:
    231
    If this is only happening on TestFlight, this is most likely on Apple's side.

    Based on the logs, we can see that the request is being sent for 30 products, but the responses contains 0 valid products. It seems IAP is correctly sending the request, but the response from Apple isn't the expected result.
    The 30 products are most likely in the SKProductsResponse.invalidProductIdentifiers.

    Apple has a few suggestions to try fixing this, but since this works for your other iOS versions, it might not solve the issue: this: https://developer.apple.com/documen...05985-invalidproductidentifiers?language=objc

    On our end, we will be conducting tests on TestFlight with these iOS versions to see if we can reproduce it.