Closed rantianhua closed 1 year ago
👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!
It can be that the problem is on Google side. I am not using RevenueCat, but have a similar problem with Billing client. https://github.com/android/play-billing-samples/issues/636 I tried to open a case on Google IssueTracker, but I don't see it after submitting.
Hi @rantianhua, we're taking a look at this issue but we haven't been able to reproduce. A few questions that might help us:
As mentioned in this ticket and as can be seen in that tracing, the likely explanation to this issue is that we get several consecutive onBillingServiceDisconnected
calls from Google play. We do schedule reconnects with exponential backoff, but those should be scheduled in the future, so it shouldn't perform much work at that point in time. This seems to be an issue on Google's side as discussed but we will study our options. Please let us know the above information if you can to be able to understand the issue better.
@tonidero
What device model are you testing on?
Device Model : Pixel 6 Android 13
Just to confirm, does that device have the play services/play store installed?
Yes
Is it consistent? If not, how often does it reproduce?
Frequency : Almost 30%. Maybe it's relevant with the network situation.
@tonidero I saw you merged https://github.com/RevenueCat/purchases-android/pull/1300 to optimize the problem. When will you publish a new version containing the optimization?
Hi @rantianhua, sorry for the delay! Yeah, we should be releasing a version with this fix this week. Will update this issue once that ships 🙏
Hi @rantianhua, we just released 7.0.1 which includes that optimization change. Could you try it out and see if it improves the situation for you?
Ok, I'll have a try.
@tonidero I've tried 7.0.1, but the problem still exists.
Partial Log:
2023-10-14 20:51:53.173 28946-28946 [Purchases] - WARN xxx W 🤖‼️ Billing is not available in this device. DebugMessage: Google Play In-app Billing API version is less than 3. ErrorCode: BILLING_UNAVAILABLE.
2023-10-14 20:51:53.173 28946-29439 [Purchases] - ERROR xxx E 🤖‼️ PurchasesError(code=StoreProblemError, underlyingErrorMessage=Error when querying subscriptions. DebugMessage: Service connection is disconnected.. ErrorCode: SERVICE_DISCONNECTED., message='There was a problem with the store.')
2023-10-14 20:51:53.173 28946-29426 [Purchases] - ERROR xxx E 🤖‼️ PurchasesError(code=StoreProblemError, underlyingErrorMessage=Error when querying subscriptions. DebugMessage: Service connection is disconnected.. ErrorCode: SERVICE_DISCONNECTED., message='There was a problem with the store.')
2023-10-14 20:51:53.173 28946-28946 [Purchases] - ERROR xxx E 🤖‼️ PurchasesError(code=PurchaseNotAllowedError, underlyingErrorMessage=Billing is not available in this device. DebugMessage: Google Play In-app Billing API version is less than 3. ErrorCode: BILLING_UNAVAILABLE., message='The device or user is not allowed to make the purchase.')
2023-10-14 20:51:53.173 28946-29427 [Purchases] - ERROR xxx E 🤖‼️ PurchasesError(code=StoreProblemError, underlyingErrorMessage=Error when querying subscriptions. DebugMessage: Service connection is disconnected.. ErrorCode: SERVICE_DISCONNECTED., message='There was a problem with the store.')
2023-10-14 20:51:53.173 28946-29439 BillingClient xxx W Got exception trying to get purchasesm try to reconnect
java.lang.NullPointerException: Attempt to invoke interface method 'android.os.Bundle com.google.android.gms.internal.play_billing.zze.zzj(int, java.lang.String, java.lang.String, java.lang.String, android.os.Bundle)' on a null object reference
at com.android.billingclient.api.BillingClientImpl.zzN(com.android.billingclient:billing@@6.0.1:5)
at com.android.billingclient.api.zzy.call(com.android.billingclient:billing@@6.0.1:1)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
2023-10-14 20:51:53.173 28946-29426 BillingClient xxx W Got exception trying to get purchasesm try to reconnect
java.lang.NullPointerException: Attempt to invoke interface method 'android.os.Bundle com.google.android.gms.internal.play_billing.zze.zzj(int, java.lang.String, java.lang.String, java.lang.String, android.os.Bundle)' on a null object reference
at com.android.billingclient.api.BillingClientImpl.zzN(com.android.billingclient:billing@@6.0.1:5)
at com.android.billingclient.api.zzy.call(com.android.billingclient:billing@@6.0.1:1)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
2023-10-14 20:51:53.173 28946-29428 BillingClient xxx W Got exception trying to get purchasesm try to reconnect
java.lang.NullPointerException: Attempt to invoke interface method 'android.os.Bundle com.google.android.gms.internal.play_billing.zze.zzj(int, java.lang.String, java.lang.String, java.lang.String, android.os.Bundle)' on a null object reference
at com.android.billingclient.api.BillingClientImpl.zzN(com.android.billingclient:billing@@6.0.1:5)
at com.android.billingclient.api.zzy.call(com.android.billingclient:billing@@6.0.1:1)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
2023-10-14 20:51:53.173 28946-29439 [Purchases] - ERROR xxx E 🤖‼️ PurchasesError(code=StoreProblemError, underlyingErrorMessage=Error when querying subscriptions. DebugMessage: Service connection is disconnected.. ErrorCode: SERVICE_DISCONNECTED., message='There was a problem with the store.')
2023-10-14 20:51:53.173 28946-29200 BillingClient xxx W Got exception trying to get purchasesm try to reconnect
java.lang.NullPointerException: Attempt to invoke interface method 'android.os.Bundle com.google.android.gms.internal.play_billing.zze.zzj(int, java.lang.String, java.lang.String, java.lang.String, android.os.Bundle)' on a null object reference
at com.android.billingclient.api.BillingClientImpl.zzN(com.android.billingclient:billing@@6.0.1:5)
at com.android.billingclient.api.zzy.call(com.android.billingclient:billing@@6.0.1:1)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
2023-10-14 20:51:53.173 28946-29426 [Purchases] - ERROR xxx E 🤖‼️ PurchasesError(code=StoreProblemError, underlyingErrorMessage=Error when querying subscriptions. DebugMessage: Service connection is disconnected.. ErrorCode: SERVICE_DISCONNECTED., message='There was a problem with the store.')
2023-10-14 20:51:53.173 28946-29308 [Purchases] - ERROR xxx E 🤖‼️ PurchasesError(code=StoreProblemError, underlyingErrorMessage=Error when querying subscriptions. DebugMessage: Service connection is disconnected.. ErrorCode: SERVICE_DISCONNECTED., message='There was a problem with the store.')
2023-10-14 20:51:53.173 28946-29310 [Purchases] - ERROR xxx E 🤖‼️ PurchasesError(code=StoreProblemError, underlyingErrorMessage=Error when querying subscriptions. DebugMessage: Service connection is disconnected.. ErrorCode: SERVICE_DISCONNECTED., message='There was a problem with the store.')
2023-10-14 20:51:53.174 28946-28946 [Purchases] - WARN xxx W ⚠️ Billing Service disconnected for com.android.billingclient.api.BillingClientImpl@30762a3
2023-10-14 20:51:53.174 28946-28946 [Purchases] - WARN xxx W ⚠️ BillingClient connection retry already scheduled. Ignoring
2023-10-14 20:51:53.174 28946-29308 BillingClient xxx W Got exception trying to get purchasesm try to reconnect
java.lang.NullPointerException: Attempt to invoke interface method 'android.os.Bundle com.google.android.gms.internal.play_billing.zze.zzj(int, java.lang.String, java.lang.String, java.lang.String, android.os.Bundle)' on a null object reference
at com.android.billingclient.api.BillingClientImpl.zzN(com.android.billingclient:billing@@6.0.1:5)
at com.android.billingclient.api.zzy.call(com.android.billingclient:billing@@6.0.1:1)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
2023-10-14 20:51:53.174 28946-29439 BillingClient xxx W Got exception trying to get purchasesm try to reconnect
java.lang.NullPointerException: Attempt to invoke interface method 'android.os.Bundle com.google.android.gms.internal.play_billing.zze.zzj(int, java.lang.String, java.lang.String, java.lang.String, android.os.Bundle)' on a null object reference
at com.android.billingclient.api.BillingClientImpl.zzN(com.android.billingclient:billing@@6.0.1:5)
at com.android.billingclient.api.zzy.call(com.android.billingclient:billing@@6.0.1:1)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
2023-10-14 20:51:53.174 28946-29308 [Purchases] - ERROR xxx E 🤖‼️ PurchasesError(code=StoreProblemError, underlyingErrorMessage=Error when querying subscriptions. DebugMessage: Service connection is disconnected.. ErrorCode: SERVICE_DISCONNECTED., message='There was a problem with the store.')
2023-10-14 20:51:53.174 28946-29200 [Purchases] - ERROR xxx E 🤖‼️ PurchasesError(code=StoreProblemError, underlyingErrorMessage=Error when querying subscriptions. DebugMessage: Service connection is disconnected.. ErrorCode: SERVICE_DISCONNECTED., message='There was a problem with the store.')
2023-10-14 20:51:53.174 28946-28946 [Purchases] - WARN xxx W ⚠️ Billing Service disconnected for com.android.billingclient.api.BillingClientImpl@30762a3
2023-10-14 20:51:53.174 28946-29439 [Purchases] - ERROR xxx E 🤖‼️ PurchasesError(code=StoreProblemError, underlyingErrorMessage=Error when querying subscriptions. DebugMessage: Service connection is disconnected.. ErrorCode: SERVICE_DISCONNECTED., message='There was a problem with the store.')
2023-10-14 20:51:53.174 28946-28946 [Purchases] - WARN xxx W ⚠️ BillingClient connection retry already scheduled. Ignoring
2023-10-14 20:51:53.174 28946-29427 BillingClient xxx W Got exception trying to get purchasesm try to reconnect
java.lang.NullPointerException: Attempt to invoke interface method 'android.os.Bundle com.google.android.gms.internal.play_billing.zze.zzj(int, java.lang.String, java.lang.String, java.lang.String, android.os.Bundle)' on a null object reference
at com.android.billingclient.api.BillingClientImpl.zzN(com.android.billingclient:billing@@6.0.1:5)
at com.android.billingclient.api.zzy.call(com.android.billingclient:billing@@6.0.1:1)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
2023-10-14 20:51:53.174 28946-29428 [Purchases] - ERROR xxx E 🤖‼️ PurchasesError(code=StoreProblemError, underlyingErrorMessage=Error when querying subscriptions. DebugMessage: Service connection is disconnected.. ErrorCode: SERVICE_DISCONNECTED., message='There was a problem with the store.')
2023-10-14 20:51:53.174 28946-29440 BillingClient xxx W Got exception trying to get purchasesm try to reconnect
java.lang.NullPointerException: Attempt to invoke interface method 'android.os.Bundle com.google.android.gms.internal.play_billing.zze.zzj(int, java.lang.String, java.lang.String, java.lang.String, android.os.Bundle)' on a null object reference
at com.android.billingclient.api.BillingClientImpl.zzN(com.android.billingclient:billing@@6.0.1:5)
at com.android.billingclient.api.zzy.call(com.android.billingclient:billing@@6.0.1:1)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
2023-10-14 20:51:53.174 28946-29440 [Purchases] - ERROR xxx E 🤖‼️ PurchasesError(code=StoreProblemError, underlyingErrorMessage=Error when querying subscriptions. DebugMessage: Service connection is disconnected.. ErrorCode: SERVICE_DISCONNECTED., message='There was a problem with the store.')
2023-10-14 20:51:53.174 28946-29427 [Purchases] - ERROR xxx E 🤖‼️ PurchasesError(code=StoreProblemError, underlyingErrorMessage=Error when querying subscriptions. DebugMessage: Service connection is disconnected.. ErrorCode: SERVICE_DISCONNECTED., message='There was a problem with the store.')
2023-10-14 20:51:53.174 28946-28946 [Purchases] - WARN xxx W ⚠️ Billing Service disconnected for com.android.billingclient.api.BillingClientImpl@30762a3
2023-10-14 20:51:53.175 28946-29308 BillingClient xxx W Got exception trying to get purchasesm try to reconnect
java.lang.NullPointerException: Attempt to invoke interface method 'android.os.Bundle com.google.android.gms.internal.play_billing.zze.zzj(int, java.lang.String, java.lang.String, java.lang.String, android.os.Bundle)' on a null object reference
at com.android.billingclient.api.BillingClientImpl.zzN(com.android.billingclient:billing@@6.0.1:5)
at com.android.billingclient.api.zzy.call(com.android.billingclient:billing@@6.0.1:1)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)
2023-10-14 20:51:53.175 28946-28946 [Purchases] - WARN xxx W ⚠️ BillingClient connection retry already scheduled. Ignoring
Maybe we need to check the error code. Some errors are non-retriable, such as https://developer.android.com/google/play/billing/errors#non-retriable_billingresult_responses.
Maybe we need to check the error code. Some errors are non-retriable, such as https://developer.android.com/google/play/billing/errors#non-retriable_billingresult_responses.
Hi @rantianhua, we do indeed check the error code when trying to connect to determine whether we need to reconnect: https://github.com/RevenueCat/purchases-android/blob/main/purchases/src/main/kotlin/com/revenuecat/purchases/google/BillingWrapper.kt#L679.
As for the error, I see this in the new logs you sent:
2023-10-14 20:51:53.173 28946-28946 [Purchases] - WARN xxx W 🤖‼️ Billing is not available in this device. DebugMessage: Google Play In-app Billing API version is less than 3. ErrorCode: BILLING_UNAVAILABLE.
That error may happen if the version of play services/play store in the device is very old.
As for the original issue, did you notice a performance improvement with 7.0.1? The fix provided there won't actually fix the issue of getting multiple disconnect callbacks simultaneously since that seems to come from Google. But hopefully the changes made it so we don't cause as much performance overhead in this situation.
As far as I understand, this problem is related to the Google Billing library. Even though I updated my RevenueCat version to 7.0.1, it did not improve and some of my users cannot make purchases in the application (around 3%). I removed RevenueCat from the project and added Google Billing directly, and it keeps connecting-disconnecting. Has anyone found a solution to the problem?
@tonidero The 7.0.1 doesn't fix the performance issue. Now I do a tricky way to solve it:
BillingClient.newBuilder(context)
.enablePendingPurchases()
.setListener { _, _ -> }
.build()
.let { billingClient ->
val handler = Handler(Looper.getMainLooper())
billingClient.startConnection(
object : BillingClientStateListener {
override fun onBillingSetupFinished(billingResult: BillingResult) {
if (billingResult.responseCode == BillingResponseCode.OK) {
// According to empirical observations, if disconnect is received immediately after receiving OK,
// then this service is basically unavailable, which will cause repeated reconnections in RevenueCat
// and cause the main thread to be stuck.
// According to empirical observation, the delay of checking whether there is a disconnection after 1s is enough.
handler.postDelayed({
billingClient.endConnection()
if (receivedDisconnect) return@postDelayed
if (initialized) return@postDelayed
initialized = true
initialize(context)
}, 1000)
}
}
override fun onBillingServiceDisconnected() {
receivedDisconnect = true
}
},
)
}
That error may happen if the version of play services/play store in the device is very old.
Actually no, my google play service is fresh, the connection will be normal after I clear all data of Google Play Store.
Hmm I see... Could you share the logs when this happens using 7.0.1 @rantianhua? We want to make sure it's following the path we expect (after that change, it should only schedule one reconnect, even if we receive multiple onBillingServiceDisconnected
.
@ahmtbrk, we are currently investigating the issue, but we haven't been able to reproduce yet. As you said, it seems to be an issue on the billing library, but we haven't found a reliable solution, since we would prefer not to delay initialization by a whole second if possible.
https://github.com/RevenueCat/purchases-android/issues/1288#issuecomment-1762890918 here is the log in version 7.0.1
@rantianhua Oh right, sorry I missed that 🙇.
So, seems that it is going through the new paths so we only try to reconnect once, but seems that it didn't help with the performance issue, so it seems that the performance issue happens on the billing library side, since we don't do almost any processing at that point in time anymore.
the connection will be normal after I clear all data of Google Play Store.
I was wondering about this. Do you have any steps to repro again after you clear data on the Play Store? It might helps us to reproduce the issue.
I'm also encountering a similar issue in version 7.0.1. after switching the language in the system settings and relaunching the app, there's a possibility of encountering repeated logs below 🙏
W ⚠️ BillingClient connection retry already scheduled. Ignoring
W ⚠️ Billing Service disconnected for com.android.billingclient.api.BillingClientImpl@ba98497
W ⚠️ BillingClient connection retry already scheduled. Ignoring
W ⚠️ Billing Service disconnected for com.android.billingclient.api.BillingClientImpl@ba98497
W ⚠️ BillingClient connection retry already scheduled. Ignoring
W ⚠️ Billing Service disconnected for com.android.billingclient.api.BillingClientImpl@ba98497
W ⚠️ BillingClient connection retry already scheduled. Ignoring
W ⚠️ Billing Service disconnected for com.android.billingclient.api.BillingClientImpl@ba98497
W ⚠️ BillingClient connection retry already scheduled. Ignoring
W ⚠️ Billing Service disconnected for com.android.billingclient.api.BillingClientImpl@ba98497
W ⚠️ BillingClient connection retry already scheduled. Ignoring
W ⚠️ Billing Service disconnected for com.android.billingclient.api.BillingClientImpl@ba98497
W ⚠️ BillingClient connection retry already scheduled. Ignoring
W ⚠️ Billing Service disconnected for com.android.billingclient.api.BillingClientImpl@ba98497
W ⚠️ BillingClient connection retry already scheduled. Ignoring
@chris-lin thanks for that! We've finally been able to reproduce those logs by changing the language then opening the app.
What's interesting is that the app will continue to be in that state forever, at least in my device, until I reopen the Play Store 🤔
Same for me, this issue happened after switching my language in my system settings. For me restarting my phone fixed it. Samsung Galaxy A53
We just released 7.1.1, which has a fix that improves the performance issues you've been seeing.
We are in the process of making more improvements on the handling of the interactions with the BillingClient
Please let us know if the performance hasn't improved
This issue has been automatically locked due to no recent activity after it was closed. Please open a new issue for related reports.
Describe the bug It looks like a dead loop in retrying BillingClient connection.
The CPU is occupied by the retrying.
Additional context Add any other context about the problem here.