Skip to content
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

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

Open
geoffroymorel opened this issue Feb 20, 2024 · 2 comments
Labels

Comments

@geoffroymorel
Copy link

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
Copy link
Author

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

@tikhop
Copy link
Owner

tikhop commented Feb 21, 2024

@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 tikhop added question and removed bug labels Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants