GoogleCloudPlatform / recaptcha-enterprise-mobile-sdk

Apache License 2.0
31 stars 6 forks source link

Upgrading to Android SDK 18.2.0 can produce an unhandled exception if there are unsent logs "Protocol message contained an invalid tag (zero)" #52

Closed tapeo closed 1 year ago

tapeo commented 1 year ago

Describe the bug

Crash when no internet available

Integration Method

SDK Version (e.g. 18.0.1):

18.2.0

To Reproduce

Disable device internet

Additional context

E/AndroidRuntime( 5575): com.google.android.recaptcha.internal.zzhp: Failed to parse the message.
E/AndroidRuntime( 5575):    at com.google.android.recaptcha.internal.zzis.zzi(com.google.android.recaptcha:recaptcha@@18.2.0:52)
E/AndroidRuntime( 5575):    at com.google.android.recaptcha.internal.zzex.zzo(com.google.android.recaptcha:recaptcha@@18.2.0:4)
E/AndroidRuntime( 5575):    at com.google.android.recaptcha.internal.zzis.zzs(com.google.android.recaptcha:recaptcha@@18.2.0:22)
E/AndroidRuntime( 5575):    at com.google.android.recaptcha.internal.zzis.zzi(com.google.android.recaptcha:recaptcha@@18.2.0:48)
E/AndroidRuntime( 5575):    at com.google.android.recaptcha.internal.zzhf.zzi(com.google.android.recaptcha:recaptcha@@18.2.0:4)
E/AndroidRuntime( 5575):    at com.google.android.recaptcha.internal.zzhf.zzu(com.google.android.recaptcha:recaptcha@@18.2.0:1)
E/AndroidRuntime( 5575):    at com.google.android.recaptcha.internal.zzmy.zzk(com.google.android.recaptcha:recaptcha@@18.2.0:1)
E/AndroidRuntime( 5575):    at com.google.android.recaptcha.internal.zzao.zzg(com.google.android.recaptcha:recaptcha@@18.2.0:6)
E/AndroidRuntime( 5575):    at com.google.android.recaptcha.internal.zzao.zzd(com.google.android.recaptcha:recaptcha@@18.2.0:1)
E/AndroidRuntime( 5575):    at com.google.android.recaptcha.internal.zzan.invokeSuspend(com.google.android.recaptcha:recaptcha@@18.2.0:15)
E/AndroidRuntime( 5575):    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
E/AndroidRuntime( 5575):    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
E/AndroidRuntime( 5575):    at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
E/AndroidRuntime( 5575):    at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
E/AndroidRuntime( 5575):    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
E/AndroidRuntime( 5575):    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
E/AndroidRuntime( 5575):    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
E/AndroidRuntime( 5575):    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
E/AndroidRuntime( 5575):    Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@448a49b, Dispatchers.IO]
mcorner commented 1 year ago

Thanks for the report and we will look into it. We can't immediately reproduce that with no internet. Do you have any more details on how you triggered this? Are you just disabling internet on the device with airplane mode etc? Does this happen every time? Did this happen on earlier SDKs?

Internal bug reference: b/282909604

tapeo commented 1 year ago

Sometimes it happens after execute setup, but maybe is not due to no network. Is this something related to the internal behaviour of the lib?

D/RecaptchaPlugin: Network Error
E/AndroidRuntime: FATAL EXCEPTION: DefaultDispatcher-worker-4
    com.google.android.recaptcha.internal.zzhp: Protocol message contained an invalid tag (zero).
        at com.google.android.recaptcha.internal.zzex.zzi(com.google.android.recaptcha:recaptcha@@18.2.0:15)
        at com.google.android.recaptcha.internal.zzis.zzi(com.google.android.recaptcha:recaptcha@@18.2.0:50)
        at com.google.android.recaptcha.internal.zzex.zzo(com.google.android.recaptcha:recaptcha@@18.2.0:4)
        at com.google.android.recaptcha.internal.zzis.zzs(com.google.android.recaptcha:recaptcha@@18.2.0:22)
        at com.google.android.recaptcha.internal.zzis.zzi(com.google.android.recaptcha:recaptcha@@18.2.0:48)
        at com.google.android.recaptcha.internal.zzhf.zzi(com.google.android.recaptcha:recaptcha@@18.2.0:4)
        at com.google.android.recaptcha.internal.zzhf.zzu(com.google.android.recaptcha:recaptcha@@18.2.0:1)
        at com.google.android.recaptcha.internal.zzmy.zzk(com.google.android.recaptcha:recaptcha@@18.2.0:1)
        at com.google.android.recaptcha.internal.zzao.zzg(com.google.android.recaptcha:recaptcha@@18.2.0:6)
        at com.google.android.recaptcha.internal.zzao.zzd(com.google.android.recaptcha:recaptcha@@18.2.0:1)
        at com.google.android.recaptcha.internal.zzan.invokeSuspend(com.google.android.recaptcha:recaptcha@@18.2.0:15)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
        at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:749)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
        Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@ecb726e, Dispatchers.IO]
I/Process: Sending signal. PID: 5421 SIG: 9
mcorner commented 1 year ago

@tapeo We know where in the code this is happening and we know how to fix it. However, we haven't found a reproduction of it yet. It is unlikely to have anything to do with being connected or not connected.

Can you tell me a few things?

1) This is happening locally, correct? Not in production? 2) Have you used any previous versions of the SDK on this device? 3) Does it happen on this device every time you call getClient or execute? 4) Does this happen on multiple devices? 5) Can you tell me the OS version of your Android device? 6) Can you send me the file stored on the device //data/data/<Your-Application-Package-Name>/databases/cesdb? You can put it somewhere and give me a link at my first name and my last name put together at google.com 7) Erase the app and try again.

Thanks for your help, -Mark

mcorner commented 1 year ago

@tapeo We have reproduced this. This can occur if: A) an app was using a previous Android SDK version AND B) A user uses the app, but did not have internet or for some reason reCAPTCHA was unable to send its logs AND C) The app is upgraded to 18.2.0

We are urgently working on a fix that will very likely only be fixed by a new Android SDK release (18.2.1)

mcorner commented 1 year ago

Great news: 18.2.1 is out and has the fix!