-
Notifications
You must be signed in to change notification settings - Fork 796
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 in ProductsInfoController.retrieveProductsInfo #468
Comments
I have the same issue! |
Same here |
+1 |
|
Do you have concrete simple steps to reproduce/simulate this bug? |
Hello all! Please check out the latest commit on the |
70761d2 is reverting the #495 Like a workaround you can downgrade to old implementation (like i did): class ProductsInfoController: NSObject {
struct InAppProductQuery {
let request: InAppProductRequest
var completionHandlers: [InAppProductRequestCallback]
}
// As we can have multiple inflight requests, we store them in a dictionary by product ids
private let inflightRequestsQueue = DispatchQueue(label: "InflightRequestsQueue", attributes: .concurrent)
private var threadInflightRequests: [Set<String>: InAppProductQuery] = [:]
private var inflightRequests: [Set<String>: InAppProductQuery] {
get {
return inflightRequestsQueue.sync {
return threadInflightRequests
}
}
set {
inflightRequestsQueue.async(flags: .barrier) {
self.threadInflightRequests = newValue
}
}
}
func retrieveProductsInfo(_ productIds: Set<String>, completion: @escaping (RetrieveResults) -> Void) {
guard !Thread.current.isMainThread else {
DispatchQueue.global().async { [weak self] in
self?.retrieveProductsInfo(productIds, completion: completion)
}
return
}
if inflightRequests[productIds] == nil {
let request = InAppProductQueryRequest(productIds: productIds) { results in
if let query = self.inflightRequests[productIds] {
for completion in query.completionHandlers {
completion(results)
}
self.inflightRequests[productIds] = nil
} else {
// should not get here, but if it does it seems reasonable to call the outer completion block
completion(results)
}
}
inflightRequests[productIds] = InAppProductQuery(request: request, completionHandlers: [completion])
request.start()
} else {
inflightRequests[productIds]?.completionHandlers.append(completion)
}
}
func cancelAllInflightRequests() {
guard !Thread.current.isMainThread else {
DispatchQueue.global().async { [weak self] in
self?.cancelAllInflightRequests()
}
return
}
inflightRequests.forEach({ $0.value.request.cancel() })
inflightRequests.removeAll()
}
} |
Platform
In app purchase type
Environment
Version
0.15.0
Report
Issue summary
sometimes, it crash when it retrieve products info.
The text was updated successfully, but these errors were encountered: