[DO NOT MERGE] always call readyForPromotedProduct on main thread/actor #4613
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Potential fix for #4582
Description
#4582 describes an occasional crash that occurs when the SDK calls the PurchaseDelegate's readyForPromotedProduct function. The provided stacktraces show a threading issue occurring in both the SK1 & SK2 flows. Our working theory is that the calling code may expect
readyForPromotedProduct
to be called on the main thread/actor, and it is being called on a background thread.This PR ensures that
readyForPromotedProduct
is always called on the Main Actor (for SK2) and main thread (for SK1).SK1 & SK2 Differences
#4584 attempted to address this issue by always calling
readyForPromotedProduct
on the main actor, but we found that this caused very consistent, but still flaky, test failures in SK1 on iOS 14-16. Out of an abundance of caution, this was reverted in #4599.This PR calls
readyForPromotedProduct
on the main thread instead of the main actor for SK1, which seems to address these test failures. The SK1 tests have passed each time I've run them on this PR.