-
Notifications
You must be signed in to change notification settings - Fork 997
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
Payment sheet leaking memory in swiftui #1881
Comments
Thanks for the detailed report @stshelton! We are currently working on PaymentSheet and will take a look at this memory issue |
Hi @stshelton, We just released a new version of the SDK last week that includes fixes to SwiftUI memory leaks. I recommend giving it a try. I would also like to suggest this small change to if let paymentSheetFlowController = stripeBuilder.paymentSheetFlowController {
PaymentSheet.FlowController.PaymentOptionsButton(paymentSheetFlowController: paymentSheetFlowController) {
+ [weak paymentSheetFlowController] in
- stripeBuilder.doesUserHavePayment = paymentSheetFlowController.paymentOption != nil ? true : false
+ stripeBuilder.doesUserHavePayment = paymentSheetFlowController?.paymentOption != nil ? true : false
stripeBuilder.onOptionsCompletion()
} ...
} ... Regarding the text underneath becoming bold, I'm not able to reproduce the issue in our test app. Could it be related to this SwiftUI bug? |
Thanks, give me a day or two to update the sdk and add the change you suggested. Also, you may be right on that swifui bug will also look into that. I'll update you guys once I implement changes. Thanks for the help! |
Looks like this is fixed. I have found another small bug with the latest version. Gonna try to reproduce on example project and create issue when I do. Thanks again |
Awesome! Thank you for the update. I'm closing this issue for now. Feel free to create a new issue once you are able to reproduce the other bug. We are happy to help! |
Summary
Having an issue when presenting the payment sheet. The payment sheet doesn't get deallocated when leaving view that it was presented on. When I view the memory debug memory graph I'm seeing this
.
I am presenting the payment sheet in a view that was presented with ".fullScreenCover" which contains a navigation view. Then the payment sheet is presented in the second view on the nav stack. I also notice that when I present the payment sheet it makes all my text go bold while its presented then back to normal size when it dismisses. Once this navview that was presented by fullScreenCover is dismissed. if I view the memory debug graph all STPClasses still exists. if I do this multiple times in the same session there are multiple instances of multiple stpclasses still in memory.
Picture of memory graph multiple stpClasses still in memory after view as dismissed
Code to reproduce
View for payment methods:
View that payment methods view is shown:
Checkout ViewModel:
iOS version
IOS 14.6
Installation method
Swift package manger
SDK version
21.8.1
Other information
Not sure if my pop up view modifier would effect anything can include that code if needed to.
The text was updated successfully, but these errors were encountered: