TPInAppReceipt icon indicating copy to clipboard operation
TPInAppReceipt copied to clipboard

This method should not be called on the main thread as it may lead to UI unresponsiveness.

Open geoffroymorel opened this issue 1 year ago • 2 comments
trafficstars

Hello,

I am getting the following double warnings in the console leading to an unresponsive UI for a couple seconds.

Warning is triggered when calling SecTrustEvaluateWithError in checkChainOfTrust() function after calling receipt.validate().

I have found the following on stackoverflow.com: https://stackoverflow.com/questions/73892668/sectrustevaluatewitherror-leads-to-ui-unresponsiveness

Xcode 15.2 iPhone 15 Pro Max iOS 17.3.1

Capture d’écran 2024-02-20 à 15 38 01

geoffroymorel avatar Feb 20 '24 14:02 geoffroymorel

The actual freeze was not related to this issue. But the warnings are still showing up.

geoffroymorel avatar Feb 20 '24 18:02 geoffroymorel

@geoffroymorel Thanks for bringing this up. You can validate your receipt in any thread you want.

Personally, I just call validate method from background thread and it works without the warning message:

let receipt = ...
DispatchQueue.global(qos: .background).async {
    do {
        try receipt.validate()
        DispatchQueue.main.async {
            // Go back to the main thread
        }
    } catch {
        // Catch the error
    }
}

I will think about adding an async validate method and move the validation logic out of the main thread at lib level.

tikhop avatar Feb 21 '24 13:02 tikhop