`Stripeldentity.onVerificationFailed` Crash error for Android users
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:
- Go to '...'
- Click on '....'
- Scroll down to '....'
- 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)
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.
This Issue is closed due to a long period of inactivity. If you still have issues, please open a new Issue. Best regards.
@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)
rdlabochecking if you were able to see the above call stack/trace that is causing crashes in android app
@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 I work with @yankostadinov and we'll get back to you soon!
@rdlabo what do you mean by number of times apps has been executed?
@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.
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?
@rdlabo would you need additional details to help fix the crash?
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?
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