purchases-ios: Crash in `CustomerInfoManager`
- I have updated Purchases SDK to the latest version
- I have read the Contribution Guidelines
- I have searched the Community
- I have read docs.revenuecat.com
- I have searched for existing Github issues
Describe the bug Just now received one more crash in RevenueCat lib
- Environment
- Platform: iOS
- SDK version: 4.10.2
- StoreKit 2 (enabled with
useStoreKit2IfEnabled) (Y/N): Y - OS version: iOS 15.6.1
- Xcode version: 13.4.1
- idk, its first crash here
-
- App crashed on start, on becoming active. I think, after update to new version.
- Stack trace:
Crashed: com.apple.NSURLSession-delegate
0 CookingRecipes 0x217cc4 closure #1 in CustomerInfoManager.sendUpdateIfChanged(customerInfo:) + 4330765508 (<compiler-generated>:4330765508)
1 CookingRecipes 0x217748 CustomerInfoManager.cache(customerInfo:appUserID:) + 28 (Lock.swift:28)
2 CookingRecipes 0x215268 closure #1 in CustomerInfoManager.fetchAndCacheCustomerInfo(appUserID:isAppBackgrounded:completion:) + 53 (Logger.swift:53)
3 CookingRecipes 0x259230 closure #2 in GetCustomerInfoOperation.getCustomerInfo(completion:) + 35 (CustomerInfoResponseHandler.swift:35)
4 CookingRecipes 0x26767c specialized closure #1 in HTTPClient.Request.init<A>(httpRequest:headers:completionHandler:) + 4331091580
5 CookingRecipes 0x269244 partial apply for specialized closure #1 in HTTPClient.Request.init<A>(httpRequest:headers:completionHandler:) + 4331098692 (<compiler-generated>:4331098692)
6 CookingRecipes 0x24d030 HTTPClient.handle(urlResponse:request:urlRequest:data:error:) + 237 (HTTPClient.swift:237)
7 CookingRecipes 0x24e340 partial apply for closure #1 in HTTPClient.start(request:) + 4330988352 (<compiler-generated>:4330988352)
8 CookingRecipes 0x24d9d0 thunk for @escaping @callee_guaranteed (@guaranteed Data?, @guaranteed NSURLResponse?, @guaranteed Error?) ->
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 26 (12 by maintainers)
Commits related to this issue
- `CustomerInfoManager`: improved thread-safety Likely fixes #1877. Thread-safety was done through a `Lock`, but nothing ensured that we didn't access the underlying data without locking. This is done... — committed to RevenueCat/purchases-ios by NachoSoto a year ago
- `Purchases`: avoid potential crash when initializing in the background #2224 likely fixes #1877. This change also avoids running the code being triggered in that crashing stack trace, since it's not ... — committed to RevenueCat/purchases-ios by NachoSoto a year ago
- `Purchases`: avoid potential crash when initializing in the background (#2231) #2224 likely fixes #1877. This change also avoids running the code being triggered in that crashing stack trace, since ... — committed to RevenueCat/purchases-ios by NachoSoto a year ago
- `CustomerInfoManager`: improved thread-safety Likely fixes #1877. Thread-safety was done through a `Lock`, but nothing ensured that we didn't access the underlying data without locking. This is done... — committed to RevenueCat/purchases-ios by NachoSoto a year ago
#2224 and #2231 will likely fix this. Thanks everyone for providing those useful stack traces.
I think I just saw the issue. There’s a small thread-safety issue in
CustomerInfoManager. I was able to reproduce this:Oh that’s good to know, so it seems like an extremely rare crash. I’ll go ahead and close this but feel free to reopen if you see the issue again.
Yes, I’ll try
Quick answer - whole app lifetime, it lives in app’s service locator that property of AppDelegate