purchases-ios: Crash in `CustomerInfoManager`

Describe the bug Just now received one more crash in RevenueCat lib

  1. Environment
    1. Platform: iOS
    2. SDK version: 4.10.2
    3. StoreKit 2 (enabled with useStoreKit2IfEnabled) (Y/N): Y
    4. OS version: iOS 15.6.1
    5. Xcode version: 13.4.1
    6. idk, its first crash here
  2. App crashed on start, on becoming active. I think, after update to new version.
  3. 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

Most upvoted comments

#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:

DispatchQueue.concurrentPerform(iterations: 100) { _ in
    let userID = UUID().uuidString
    let info = try! CustomerInfo(data: [
        "request_date": "2019-08-16T10:30:42Z",
        "subscriber": [
            "original_app_user_id": userID,
            "first_seen": "2019-06-17T16:05:33Z",
            "subscriptions": [:],
            "other_purchases": [:]
        ]])
    self.customerInfoManager.cache(customerInfo: info, appUserID: userID)
}

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.

Could you try compiling your project

Yes, I’ll try

Also another quick question: what’s the lifetime of your StoreService?

Quick answer - whole app lifetime, it lives in app’s service locator that property of AppDelegate