#shiva_code

1 messages · Page 1 of 1 (latest)

urban gulchBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1422925784091459655

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

cosmic cypress
#

Sharing the full code for here

        do {
            print(3)
            let intentConfiguration = PaymentSheet.IntentConfiguration(
                mode: .payment(
                    amount: booking.revenueInCents,
                    currency: "MYR",
                    setupFutureUsage: .offSession
                )
            ) { _, _, intentCreationCallback in
                self.handleConfirm(booking, intentCreationCallback)
            }
            
            print(4)
            let customerSession = try await stripeService.getStripeSession()
            
            print(5)
            var configuration = EmbeddedPaymentElement.Configuration()
            configuration.merchantDisplayName = "MyApp"
            configuration.returnURL = "com.myapp.app://stripe-redirect"
            configuration.customer = .init(id: customerSession.stripeCustomerId, ephemeralKeySecret: customerSession.ephemeralKey)
            try await stripeEmbeddedViewModel.load(intentConfiguration: intentConfiguration, configuration: configuration)
            print(6)
            currentIntentConfig = intentConfiguration
            print(7)
        } catch {
            print(8)
            debugPrint("Unable to load embedded view model: \(error.localizedDescription)")
        }
    }
delicate crescent
#

👋 Hi there. Let me take a look!

cosmic cypress
#

What I am seeing is that everything works well till print 5, then the app crashed at print 6.

Note that the stripeEmbeddedViewModel is just below:
@StateObject private var stripeEmbeddedViewModel = EmbeddedPaymentElementViewModel()

#

Hey @delicate crescent appreciate your time 🙂

delicate crescent
#

Where is stripeEmbeddedViewModel coming from in this case?

urban gulchBOT
cosmic cypress
#

Hey @delicate crescent it’s from here
@StateObject private var stripeEmbeddedViewModel = EmbeddedPaymentElementViewModel()

tender sleet
#

Hi there, taking over for @delicate crescent as they had to step away

cosmic cypress
#

Hey @tender sleet thanks for stepping in

tender sleet
#

Just for clarification, when you say this is a memory leak, does that mean you're seeing the memory being consumed until it crashes? If so, have you tried using Xcode's Memory Graph Debugger to gather more detailed information?

cosmic cypress
#

Okay sorry, not sure if it’s a memory leak but you can have a look at the screenshot above for what I’m seeing

tender sleet
#

So when the code crashes, it's not outputting any error messages?

cosmic cypress
#

Nope, there are no errors. It basically happens after the .load is triggered. The app freezes for a few seconds, then the error message above shows up

#

It was working perfectly fine prior to my Xcode update

#

Everything in the code above runs fine and I’m able to see print(5), but print 6,7,8 never shows up

#

Hey @tender sleet, I can confirm that by remove the stripeEmbeddedViewModel.load(), everything works fine.

tender sleet
#

Got it. We will need more time to do a deeper investigation, can I send you a DM so we can convert this into a case and be able to follow up with you directly?

cosmic cypress
#

Yes, that sounds good to me. Thanks a lot, I too am trying to see how best to resolve this