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

Google Play ANR report: com.android.billingclient.api.SkuDetailsResponseListener.onSkuDetailsRespons

Discussion in 'Unity IAP' started by doubletapsoft, May 23, 2021.

  1. doubletapsoft

    doubletapsoft

    Joined:
    Sep 23, 2013
    Posts:
    32
    We are getting excessive ANR reports in Google Play and it is putting our game above the ANR "Bad behavior" threshold.

    We did the following but the issue remains:
    - Upgraded Unity IAP from 2.2.2 to 3.1.0
    - Clicked checkbox for “Automatically initialize UnityPurchasing (recommended)”
    - Upgraded from Unity 2020.1.15f1 to 2020.3.8f1 LTS

    It is mostly on Android 9, but also it happens on 8 and 10.

    Has anyone else had this issue or know what could be happening?

    They all contain this in the trace: com.android.billingclient.api.SkuDetailsResponseListener.onSkuDetailsResponse

    Below is what most of the logs look like:

    #00 pc 000000000017e4cc /data/app/com.doubletapsoftware.basketballbattle-Jg9gb6wWz4BAuRnHV0GIoQ==/lib/arm64/libunity.so (???)
    #00 pc 00000000000d6510 /data/app/com.doubletapsoftware.basketballbattle-Jg9gb6wWz4BAuRnHV0GIoQ==/oat/arm64/base.odex (Java_com_unity3d_player_ReflectionHelper_nativeProxyInvoke__JLjava_lang_String_2_3Ljava_lang_Object_2+208)
    at com.unity3d.player.ReflectionHelper.nativeProxyInvoke (Native method)
    at com.unity3d.player.ReflectionHelper.a (unavailable)
    at com.unity3d.player.ReflectionHelper$1.invoke (unavailable)
    at java.lang.reflect.Proxy.invoke (Proxy.java:913)
    at com.android.billingclient.api.SkuDetailsResponseListener.onSkuDetailsResponse
    at com.android.billingclient.api.zzac.run
    at android.os.Handler.handleCallback (Handler.java:808)
    at android.os.Handler.dispatchMessage (Handler.java:101)
    at android.os.Looper.loop (Looper.java:166)
    at android.app.ActivityThread.main (ActivityThread.java:7529)
    at java.lang.reflect.Method.invoke (Native method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:245)
    at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:921)[/code]
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    You are using Codeless? I might suggest using Scripted IAP instead, we may need to revisit the Codeless scripts. Are you able to reproduce, did it work in your Google testing?
     
  3. doubletapsoft

    doubletapsoft

    Joined:
    Sep 23, 2013
    Posts:
    32
    Hey Jeff. We are using scripting in combination with using the IAP Catalog. I cannot reproduce issue on any of my local devices.

    I would guess the ANR happens when we call the below code. It happens in 1.5% of sessions:

    Code (CSharp):
    1.  
    2. ConfigurationBuilder builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
    3. IAPConfigurationHelper.PopulateConfigurationBuilder(ref builder, ProductCatalog.LoadDefaultCatalog());
    4. UnityPurchasing.Initialize(this, builder);
    5.  
    Is this supported?
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Yes, it's supported. We would need specific steps to reproduce, your error is not familiar. Try logging out of the Play Store on the device as a test, and try to purchase.
     
  5. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    @doubletapsoft Oh wait, you do NOT want to check Automatically Initialize IAP in the Product catalog if you are doing that in code already. So ensure that setting is not selected if you are calling UnityPurchasing.Initialize(this, builder);
     
  6. doubletapsoft

    doubletapsoft

    Joined:
    Sep 23, 2013
    Posts:
    32
    I logged out of the Play Store and tried to make a purchase and it did not cause an ANR. We cannot reproduce it but here is more detailed information from the Google Play Console....








    I fear that many developers are having this issue and it causes Google Play to reduce the downloads that the game receives.
     
  7. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    No, not many developers, only you that I've seen. Please see my previous post, don't set the auto-initialize flag.
     
  8. doubletapsoft

    doubletapsoft

    Joined:
    Sep 23, 2013
    Posts:
    32
    We had that unchecked and still had the problem. I only checked it as a way to troubleshoot. Is there anything else that could be done to try and resolve the problem? A lot of developers don't know to pay attention to the Android Vitals I wonder if that is why we have not heard from others.
     
  9. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    So you published a version of your app with both configurations, and still see the error after monitoring the vitals for a few days? And you cannot reproduce? We have many major studios using IAP and we have not heard of this ANR. Can you provide the device logs from your testing? I may be able to spot something https://forum.unity.com/threads/how-to-capturing-device-logs-on-android.528680/
     
  10. doubletapsoft

    doubletapsoft

    Joined:
    Sep 23, 2013
    Posts:
    32
    Yes I published a version of the app with both configurations and monitored vitals for a few days. Even though I cannot reproduce, tomorrow I will provide you with device log so maybe you can catch something.
     
    JeffDUnity3D likes this.
  11. doubletapsoft

    doubletapsoft

    Joined:
    Sep 23, 2013
    Posts:
    32
    Hey Jeff!

    I put the logcat log and some screenshots and files related to our setup in the below Google Drive folder. Please click the link so that I can grant you access to it.

    https://drive.google.com/drive/folders/1twb5ujb5xEzAbpufFdlGGtpCO6OR2PV6?usp=sharing

    Thanks and let me know if I can provide any other files and information. One idea I have his to remotely turn off the below call for a day or two. This will break IAP but at least allow us to see if the ANR changes because of removing this line.

    Code (CSharp):
    1. UnityPurchasing.Initialize(this, builder);
    Joe
     
  12. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Engineering is taking a look at this also. Did you get my access request?
     
  13. doubletapsoft

    doubletapsoft

    Joined:
    Sep 23, 2013
    Posts:
    32
    Yes I granted access. Let me know if there are any issues.
     
  14. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    I do see a few exceptions and class not found errors in the logs, not sure if related. I passed along the information to engineering.
     
  15. doubletapsoft

    doubletapsoft

    Joined:
    Sep 23, 2013
    Posts:
    32
    Great, let me know what they think.
     
  16. doubletapsoft

    doubletapsoft

    Joined:
    Sep 23, 2013
    Posts:
    32
    Any update on what the issue could be?
     
  17. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Sorry no. So far you are the only person reporting this. We will need steps to reproduce. Are you able to address the class not found errors in the logs to rule it out?
     
  18. doubletapsoft

    doubletapsoft

    Joined:
    Sep 23, 2013
    Posts:
    32
    It looks like they are related to the multi dex. Does Unity IAP support multidex builds for Google Play?
     
  19. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please provide steps to reproduce, we'll check
     
  20. doubletapsoft

    doubletapsoft

    Joined:
    Sep 23, 2013
    Posts:
    32
    We don't have a way to reproduce. It is only provided by the ANR reports in Google Play.
     
  21. nicholasr

    nicholasr

    Unity Technologies

    Joined:
    Aug 15, 2015
    Posts:
    183
    Thank you for the thoughtful and detailed report @doubletapsoft. And thank you for continuing to work with us, exploring ideas to track down additional details.

    We found and are testing an experimental fix related to the issue described here. We plan to add it to an upcoming release of com.unity.purchasing.

    Details - We added a rescheduling of the thread of execution received from the Java side during initialization. Previously we simply continued execution on the same thread, with our UnityPurchasing.Initialize processing activity, after we received the SkuDetailsResponseListener.onSkuDetailsResponse listener callback from the Google Play Billing Library. We pass execution control back and forth between Java and CSharp inside Unity IAP. This Java callback is exposed to CSharp with an AndroidJavaProxy. If the follow-on CSharp work, triggered by the callback, takes too long then that risks raising an ANR watchdog timer on the Android side. With the experimental fix we critically immediately return to Java after receiving the callback, and simultaneously start a separate line of CSharp execution to complete the UnityPurchasing.Initialize work. So while we have not been able to reproduce the problem, this upcoming change should avoid this specific ANR call-stack.

    Thanks again for the details provided here so far. They are the basis for this upcoming experimental fix. Additional details can only help as we sadly still have not reproduced the behavior locally.
     
  22. doubletapsoft

    doubletapsoft

    Joined:
    Sep 23, 2013
    Posts:
    32
    Wow! Thank you so much for looking into this you guys really went above and beyond! Let me know if I can provide any other helpful information and I look forward to the experimental fix. Thanks again!
     
    nicholasr likes this.
  23. kkl888

    kkl888

    Joined:
    Dec 6, 2014
    Posts:
    52
    Having the same ANR issue as well. The following stacktrace is copied from Google Play console
    Input dispatching timed out (Waiting to send non-key event because the touched window has not finished processing certain input events that were delivered to it over 500.0ms ago. Wait queue length: 1. Wait queue head age: 10396.2ms.)
    Code (CSharp):
    1.   at com.unity3d.player.ReflectionHelper.nativeProxyInvoke (Native method)
    2.   at com.unity3d.player.ReflectionHelper.a (unavailable)
    3.   at com.unity3d.player.ReflectionHelper$1.invoke (unavailable)
    4.   at java.lang.reflect.Proxy.invoke (Proxy.java:913)
    5.   at com.android.billingclient.api.SkuDetailsResponseListener.onSkuDetailsResponse
    6.   at com.android.billingclient.api.zzac.run
    7.   at android.os.Handler.handleCallback (Handler.java:795)
    8.   at android.os.Handler.dispatchMessage (Handler.java:99)
    9.   at android.os.Looper.loop (Looper.java:166)
    10.   at android.app.ActivityThread.main (ActivityThread.java:6861)
    11.   at java.lang.reflect.Method.invoke (Native method)
    12.   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:450)
    13.   at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:936)
    I noticed Google has fixed the similar issue which causes ANR in PBL 4.0 https://issuetracker.google.com/issues/141918365. Is there any plan to get this version into Unity IAP?

    * Using Unity 2018.4.23f and Unity IAP 2.2.2 from Package Manager
     
    doubletapsoft likes this.
  24. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    I will pass this along to the developers, thanks for the heads up!
     
    doubletapsoft and kkl888 like this.
  25. doubletapsoft

    doubletapsoft

    Joined:
    Sep 23, 2013
    Posts:
    32
    Glad to hear that we are not the only ones running into this issue! Thanks for tacking on your message.
     
  26. ivertex

    ivertex

    Joined:
    Aug 3, 2012
    Posts:
    7
    Hi, we have the same ANR, same stacks.
    But we can't reproduce, only google console reports ((
    When it will be fixed?
     
  27. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    It will be addressed when we move to Google Play Billing Library v4, likely in a couple of months (hopefully sooner!)
     
  28. ivertex

    ivertex

    Joined:
    Aug 3, 2012
    Posts:
    7
    Hi, thank you for the quick response!
    Can we fix it now without waiting for update iap?
    This is very critical, we can not wait several months ((
    May be call iap initialize to a separate thread or something else?
     
  29. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Do you have access to the Google Play Billing Library v4? It's a Google issue, as mentioned.
     
  30. ivertex

    ivertex

    Joined:
    Aug 3, 2012
    Posts:
    7
    I didn't quite understand the question. What do you mean by "have access to Google Play Billing Library v4"? We are using Unity IAP library, which use Google Play Billing 3 inside.
     
  31. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Correct. Please see the previous posts. This is a Google issue, fixed in GPBL v4. We are currently using v3.
     
  32. ivertex

    ivertex

    Joined:
    Aug 3, 2012
    Posts:
    7
    To be clear: should we wait for the fix
    "With the experimental fix we critically immediately return to Java after receiving the callback, and simultaneously start a separate line of CSharp execution to complete the UnityPurchasing.Initialize work..."
    or should wait for the major update of the Unity IAP 4.x based on the GPBL v4?
     
  33. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    The fix is in GPBL v4, available with Unity IAP in a couple of months, hopefully sooner.
     
  34. ivertex

    ivertex

    Joined:
    Aug 3, 2012
    Posts:
    7
    Got it! Thank you.
     
  35. Medhaedu

    Medhaedu

    Joined:
    Mar 30, 2015
    Posts:
    5
    Any update on above issue fix. My game ANR threshold also cross even after updating Unity IAP to 4.0.0,
     
    Last edited: Aug 31, 2021
  36. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    It's still a few weeks out.
     
  37. Medhaedu

    Medhaedu

    Joined:
    Mar 30, 2015
    Posts:
    5
    Any Solution Around For Above Issue ....Until fix came in Unity IAP version
     
    Last edited: Sep 1, 2021
  38. doubletapsoft

    doubletapsoft

    Joined:
    Sep 23, 2013
    Posts:
    32
    This week Google Play started requiring that developers update to billing 3.0+ (we were hoping to avoid doing this with our titles until a fix for the ANR is available.) When will Unity IAP to 4.0.0 be available?

     
  39. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446