Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PIN Management - Method "retrievePinCode" seems to block the main thread #3499

Closed
bellierjonathan opened this issue Mar 22, 2021 · 5 comments · Fixed by #3507
Closed

PIN Management - Method "retrievePinCode" seems to block the main thread #3499

bellierjonathan opened this issue Mar 22, 2021 · 5 comments · Fixed by #3507
Assignees
Labels
triaged Issue has been reviewed by Stripe and is being tracked internally

Comments

@bellierjonathan
Copy link

bellierjonathan commented Mar 22, 2021

Summary

When I'm using retrievePin from IssuingCardPinService the call from the Stripe SDK to Stripe API seems to block the main thread.

What you suggest to avoid this? I tried to use Thread but not working.

Code to reproduce

IssuingCardPinService.create(
      context,
      stripePublishableKey,
      keyProvider
  ).retrievePin(
      cardId,
      verificationId,
      userOneTimeCode,
      listener
  )

Android version

11

SDK version

16.3.1

@mshafrir-stripe
Copy link
Collaborator

@bellierjonathan can you share your EphemeralKeyProvider implementation?

@mshafrir-stripe mshafrir-stripe self-assigned this Mar 23, 2021
@mshafrir-stripe mshafrir-stripe added the triaged Issue has been reviewed by Stripe and is being tracked internally label Mar 23, 2021
@bellierjonathan
Copy link
Author

bellierjonathan commented Mar 23, 2021

@mshafrir-stripe I use an Observable from Rx created by

.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())

Then inside my onSuccess I call onKeyUpdate

@mshafrir-stripe
Copy link
Collaborator

I think I see the issue on our end, will verify.

@bellierjonathan
Copy link
Author

bellierjonathan commented Mar 23, 2021

Oh and to give you more detail when I was using the SDK version 16.0.1 an NetworkOnMainThreadException was thrown.
Now with the last version of Stripe 16.3.1 the Exception disappears but still freeze the app.

On 16.0.1 I had to use this code (for testing)

val policy: StrictMode.ThreadPolicy = StrictMode.ThreadPolicy.Builder().permitAll().build()
StrictMode.setThreadPolicy(policy)

to avoid the throw NetworkOnMainThreadException for testing

mshafrir-stripe added a commit that referenced this issue Mar 23, 2021
Previously requests were being fired on the main thread
(`runBlocking`). Move requests to a background thread and dispatch
results on main thread.

Fixes #3499
@mshafrir-stripe
Copy link
Collaborator

I found the issue - it was on our end. Thanks for flagging!

mshafrir-stripe added a commit that referenced this issue Mar 23, 2021
Previously requests were being fired on the main thread
(`runBlocking`). Move requests to a background thread and dispatch
results on main thread.

Fixes #3499
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triaged Issue has been reviewed by Stripe and is being tracked internally
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants