-
Notifications
You must be signed in to change notification settings - Fork 329
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
Crash on launch in Purchases.readyForPromotedProduct(_:purchase:)
#4582
Comments
👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out! |
Hey @vrutberg, thanks for reporting! I'll take a look at it. You mentioned that there are three variants of the crash. If the stacktraces from the other two variants are different, would you mind sharing them here? Thanks! |
Hey @fire-at-will, thanks for taking a look at it. Absolutely, here are the other two variants:
|
Thank you @vrutberg! I'll take a look at this and get back to you on it. |
Hey @vrutberg, would you mind sharing some of your code in your It looks like this is a threading issue, and my current theory is that the SDK could be calling the PurchaseDelegate's Thanks! |
We also received many crashes report with this. It all happens on iOS 18, including iOS 18.2, which was just released, and on iPhone only. But have no idea how to reproduce this crash. SDK Version: 5.12.1
It's strange that the problem was related to an unrelated call with Here is how we call extension AppDelegate: @preconcurrency PurchasesDelegate {
func purchases(
_ purchases: Purchases,
readyForPromotedProduct product: StoreProduct,
purchase startPurchase: @escaping StartPurchaseBlock
) {
startPurchase { transaction, info, error, cancelled in
guard let customerInfo = info else { return }
Global.shared.customerInfo = customerInfo
}
}
} PS: Our project is Swift 6 strict mode enabled. @fire-at-will If this is relative to the |
@fire-at-will Thanks for getting back to me! Sure, I can absolutely share some code. I'm not sure exactly which code it is you want me to share, the only reference I can find to extension PurchaseManager: @preconcurrency PurchasesDelegate {
func purchases(_ purchases: Purchases,
readyForPromotedProduct product: StoreProduct,
purchase makeDeferredPurchase: @escaping StartPurchaseBlock) {
makeDeferredPurchase { (transaction, info, error, cancelled) in
if let purchaserInfo = info {
self.handlePurchaserInfo(purchaserInfo, completion: nil)
if PremiumManager.shared.hasPremium {
OnboardingController.finishOnboarding(presentTabbar: true)
}
}
}
}
} And yes, Please let me know if I should be making some changes to my code, or if this is something that will be fixed in the SDK. |
@fire-at-will I can now reproduce the problem by opening the app via https://developer.apple.com/documentation/storekit/testing-promoted-in-app-purchases The app will immediately crash after the app is opened. To stop this, I have to completely remove the Tested on SDK Version: 5.14.3 Hope this help. |
@fire-at-will The To reproduce and test the crash locally, open the link |
Thanks for sharing your findings @catfan. Returning from holiday leave, I took a look at what's been posted in this thread, and managed to find a workaround in our project, which I thought I should share in case anyone else encounters this issue (and until there's a fix in the library). In short, my workaround is based on creating a delegate implementation not annotated with final class NonMainActorDelegate: NSObject, PurchasesDelegate {
var callback: (@Sendable () -> Void)?
func purchases(
_ purchases: Purchases,
readyForPromotedProduct product: StoreProduct,
purchase makeDeferredPurchase: @escaping StartPurchaseBlock
) {
// do whatever you want to do here, and then call the callback
callback?()
}
} This can then be used like this: import RevenueCat
@MainActor
final class PurchaseManager {
private let nonMainActorDelegate = NonMainActorDelegate()
init() {
nonMainActorDelegate.callback = { [weak self] in
Task { @MainActor in
// perform main thread logic here...
}
}
Purchases.shared.delegate = nonMainActorDelegate
}
} Of course, this works for our use case, in our project, so your mileage may vary. Furthermore, FWIW, I was also able to reproduce the crash using the |
We've been seeing a crash that has been occurring since the launch of iOS 18. It hasn't generated any user feedback, and it doesn't seem to happen all that often, but it has been occurring since iOS 18 was released, and it's still occurring. According to Crashlytics, it seems to be occurring shortly after launch, but we haven't been able to reproduce this issue for ourselves.
Crashlytics reports 3 different variants of this crash, I'll post the most recent here:
.with(storeKitVersion: .storeKit1)
)Purchases.logLevel = .verbose
will help us debug this issue.Sorry, I don't have any debug logs from this crash.
Sorry, I don't know hot to reproduce it.
See stacktrace above.
The crash seems to be iOS 18 only.
The text was updated successfully, but these errors were encountered: