Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request addresses a data race in the in_app_purchase_storekit package by ensuring that StoreKit 1 product and receipt refresh request completions are executed on the main thread. A helper method runOnMainThread has been introduced to run blocks on the main thread, and the completion handlers for product requests and receipt refreshes have been updated to use this helper. Additionally, unit tests have been added to verify that these completions occur on the main thread, and the package version has been bumped to 0.4.17+1. There are no review comments to address.
2d89ff0 to
edb39d7
Compare
|
This pull request is not mergeable in its current state, likely because of a merge conflict. Pre-submit CI jobs were not triggered. Pushing a new commit to this branch that resolves the issue will result in pre-submit jobs being scheduled. |
|
can you fix the merge conflict, then I can run the cicd tests? |
edb39d7 to
f5b1b3b
Compare
…tions StoreKit calls product and receipt refresh request completions on a background queue, but they mutate productsCache and requestHandlers, which are also used from the main thread. Run the completions on the main thread. Fixes flutter/flutter#193989
f5b1b3b to
6814eac
Compare
|
Thanks @LouiseHsu, I rebased onto the latest main and fixed the conflict. It should be good to run the CI tests now. |
|
Rebased onto main and resolved the conflict, so it should be ready for you to kick off CI. Thanks! |
StoreKit 1 delivers
SKProductsRequest/ refresh receipt responses on a background dispatch queue. The completions forstartProductRequestProductIdentifiersandrefreshReceiptReceiptPropertieswere running on that queue and mutatingproductsCache(anNSMutableDictionary) andrequestHandlers(anNSHashTable). Neither is thread safe, and both are also used from the main thread (addPaymentPaymentMap,shouldAddStorePayment, and the Pigeon entry points), so overlapping requests could corrupt them and crash withEXC_BAD_ACCESSor anNSHashTablecount underflow.Both completions now run on the main thread. This also means the Pigeon replies are sent from the platform thread. If a completion is already on the main thread it runs inline, so behaviour for the existing synchronous test stubs is unchanged.
Added two tests that finish the request from
DispatchQueue.global()and assert the plugin's completion arrives on the main thread. The StoreKit 1 suite passes (34 tests). The StoreKit 2 tests fail in my simulator environment with and without this change.Fixes flutter/flutter#193989
Pre-Review Checklist
[shared_preferences]///).Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2