StoreKit1Wrapper: process transactions in a background thread#2115
Merged
Conversation
See #2107. That's a rare issue where a user ends up with thousands of transactions. That exposed the fact that we're processing all of these transactions on the main thread. This fixes that.
NachoSoto
commented
Dec 5, 2022
| private let operationDispatcher: OperationDispatcher | ||
|
|
||
| init(paymentQueue: SKPaymentQueue) { | ||
| init(paymentQueue: SKPaymentQueue, operationDispatcher: OperationDispatcher) { |
Contributor
Author
There was a problem hiding this comment.
I need to pass the same one down from Purchases here.
NachoSoto
commented
Dec 5, 2022
2e72461 to
6112829
Compare
cd6258a to
c9af0f0
Compare
8d1cce5 to
da0b5b8
Compare
5 tasks
NachoSoto
added a commit
that referenced
this pull request
Dec 15, 2022
…ottle errors (#2146) Fixes #2116. Depends on #2134, #2144, #2145. We've known that, especially for sandbox accounts with lots of purchases, the SDK can get flooded with a lot of transactions to process at once. I've been making some improvements for this (like #2115). Another consequence of this behavior, is that we can end up failing due to `StoreKit` throttling us (see #2116): > 2022-12-03 12:31:58.670892+0100 app[673:61074] <SKReceiptRefreshRequest: 0x283edc860>: Finished refreshing receipt with error: Error Domain=ASDErrorDomain Code=603 "Request throttled" UserInfo={NSLocalizedFailureReason=Unified receipt is valid and current, NSLocalizedDescription=Request throttled, AMSServerErrorCode=0} This change avoids that by skipping the refresh if less than 2 seconds have elapsed. I chose 2 to make this a low-ish risk change, with a huge benefit for multiple semi-concurrent requests coming from a big transaction queue.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #2107 and SDKONCALL-180. That's a rare issue where a user ends up with thousands of transactions.
That exposed the fact that we're processing all of these transactions on the main thread. This fixes that.