stripe icon indicating copy to clipboard operation
stripe copied to clipboard

`Stripeldentity.onVerificationFailed` Crash error for Android users

Open cjmisenas-stripe opened this issue 1 year ago • 1 comments

Platform

  • [ ] Web
  • [ ] iOS
  • [x] Android

Describe the bug Seeing a frequent crash happen with the following stack trace for 5.4.2 on Android

Stripeldentity.onVerificationFailed
java.lang.NullPointerException - Attempt to invoke virtual method 'void com.getcapacitor. PluginCall.resolve(com.getcapacitor. JSObject) on a null object reference

To Reproduce Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

Usage Product If you adopt this plugin, please let us know which product you are using.

Product Name: Product URL : Using Function:

  • [ ] Payment Sheet / Payment Flow
  • [ ] Apple Pay
  • [ ] Google Pay
  • [x] Identity (@capacitor-community/stripe-identity)
  • [ ] Terminal(@capacitor-community/stripe-terminal)

cjmisenas-stripe avatar Jul 24 '24 16:07 cjmisenas-stripe

I checked with Demo and onVerificationFailed did not cause a Crash error. There seems to be another cause. Please give me a small reproduction code or step where the problem occurs.

rdlabo avatar Aug 11 '24 03:08 rdlabo

This Issue is closed due to a long period of inactivity. If you still have issues, please open a new Issue. Best regards.

rdlabo avatar Oct 25 '24 02:10 rdlabo

@rdlabo This issue has been causing crashes in our android app continuously for months now.

It seems to be happening because the call variable is null in this file: https://github.com/capacitor-community/stripe/blob/7b3a81ea646417da0b4dbcb3a2c9cdde43a2700f/packages/identity/android/src/main/java/com/getcapacitor/community/stripe/identity/StripeIdentity.java#L75-L76

The call variable is supposed to be setup in thebridge, but there is no saved call. https://github.com/capacitor-community/stripe/blob/7b3a81ea646417da0b4dbcb3a2c9cdde43a2700f/packages/identity/android/src/main/java/com/getcapacitor/community/stripe/identity/StripeIdentityPlugin.java#L52

The error seems to happening within the first 5 seconds (as per Crashlytics) of a user's session in our app. So it seems to be a crash happening during initialization of the plugin or when resuming an activity with the plugin, which could help with reproducing it (I haven't been able to do so myself yet).

For what it's worth, we have had reports for users (and session recordings) that indicate this issue could be more common on Motorola devices, although most of the crashlytics reports are on Samsung devices still.

error:

Fatal Exception: java.lang.RuntimeException
Unable to resume activity {***********/**********.MainActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=2012565167, result=0, data=null} to activity {*********/********.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.getcapacitor.PluginCall.resolve(com.getcapacitor.JSObject)' on a null object reference

call stack:

android.app.ActivityThread.performResumeActivity (ActivityThread.java:5106)
android.app.ActivityThread.handleResumeActivity (ActivityThread.java:5139)
android.app.servertransaction.ResumeActivityItem.execute (ResumeActivityItem.java:57)
android.app.servertransaction.ActivityTransactionItem.execute (ActivityTransactionItem.java:45)
android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:180)
android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:98)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:2567)
android.os.Handler.dispatchMessage (Handler.java:111)
android.os.Looper.loopOnce (Looper.java:242)
android.os.Looper.loop (Looper.java:362)
android.app.ActivityThread.main (ActivityThread.java:8448)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:552)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:992)

yankostadinov avatar Nov 13 '24 09:11 yankostadinov

rdlabochecking if you were able to see the above call stack/trace that is causing crashes in android app

manpreet-stripe avatar Nov 27 '24 23:11 manpreet-stripe

@yankostadinov Thanks for information. Now we can finally discuss it!

This alone makes me think that IdentityVerificationSheet.Companion is being executed more than once. Can you check the number of times apps has been executed? (I think the quickest way is to check in the Log)

Also make sure that present() is not mistakenly executed twice.

rdlabo avatar Dec 03 '24 09:12 rdlabo

@rdlabo I work with @yankostadinov and we'll get back to you soon!

rkarroll avatar Dec 06 '24 15:12 rkarroll

@rdlabo what do you mean by number of times apps has been executed?

Julian-Sam avatar Dec 10 '24 10:12 Julian-Sam

@Julian-Sam I don't know what the implementation is, but I suspect a double-click-like process. The best thing to do is to create a repository where the problem can be reproduced and share it with us.

rdlabo avatar Dec 10 '24 11:12 rdlabo

Hey @rdlabo, we still have not been able to reproduce this, and its still continuing to affect our users as per our crash logs. We see that users app crashes on app startup. I wanted to propose that we gracefully handle the scenario when the call variable is null. This would help stop these crashes, especially since it happens at app startup, theres no reason for the app to crash altogether here when the user might not even be going through the Stripe flow.. wdyt?

Julian-Sam avatar Jan 05 '25 13:01 Julian-Sam

@rdlabo would you need additional details to help fix the crash?

manpreet-stripe avatar Jan 14 '25 16:01 manpreet-stripe

Hi @Julian-Sam @rdlabo I've investigated this issue as best I can (full disclaimer, I am not familiar at all with Capacitor's native bridge system) and I've made a PR that will hopefully fix this https://github.com/capacitor-community/stripe/pull/420. Please let me know your feedback and whether or not this will fix this issue.

Also, @yankostadinov I noticed that you referenced an older commit with Java source, do we need to also update an older version of this package?

kentwilliams-stripe avatar Jan 15 '25 19:01 kentwilliams-stripe

Try this to see if it fixes it. If you get the same error with this, it seems to be returning multiple results.

https://github.com/capacitor-community/stripe/pull/426

rdlabo avatar Feb 01 '25 05:02 rdlabo