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

call ON_FRAGMENT_CREATED before INIT_PAYMENTSHEET to prevent potential null pointer crashes #783

Conversation

remonh87
Copy link
Collaborator

We noticed that we get from the Flutter Stripe community some nullpinter exceptions that happen a bit randomly. See issue flutter-stripe/flutter_stripe#416 . In my current project I also saw this issue happen and it looks like a race condition that causes the following cast being executed in the StripeModule while the fragment is being null.

if (intent.action == ON_FRAGMENT_CREATED) {
        paymentSheetFragment = (currentActivity as AppCompatActivity).supportFragmentManager.findFragmentByTag("payment_sheet_launch_fragment") as PaymentSheetFragment
      }

After some investigation it looks like the promise is being resolved before the fragment is created. This fix will prevent this from happening.

@CLAassistant
Copy link

CLAassistant commented Jan 23, 2022

CLA assistant check
All committers have signed the CLA.

@charliecruzan-stripe
Copy link
Collaborator

Since intents are asynchronous, I think it's still possible to run into this issue even afterwards. What do you think of removing the need for the ON_FRAGMENT_CREATED intent altogether, like this: #788?

@remonh87
Copy link
Collaborator Author

remonh87 commented Feb 2, 2022

Since intents are asynchronous, I think it's still possible to run into this issue even afterwards. What do you think of removing the need for the ON_FRAGMENT_CREATED intent altogether, like this: #788?

@charliecruzan-stripe yes that can work. Let's go for your solution I will close this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants