SKProductsRequestDelegate methods no longer called from main thread

Up until recently it seemed reasonable to assume that all StoreKit observer and delegate methods were called on the main thread. I'm not sure if this was documented, but I had ASSERTs in the relevant methods to check this was the case and they never fired.


Since updating to iPadOS 13.1 I have discovered that the productsRequest:didReceiveResponse: and requestDidFinish: methods of SKProductsRequestDelegate are no longer called from the main thread. It's best to assume that request:didFailWithError: is also affected, although I haven't tested it.


Given that these methods are typically used to update application state, it's now necessary to ensure this is performed in a thread-safe manner. I think the least intrusive solution would be to schedule the work to be performed on the main thead using dispatch_async(dispatch_get_main_queue(), ...).


I'd be interested to know if anyone else can confirm this.

Accepted Reply

The Storekit methods on macOS were always called on a background thread. Always thought it was strange that they called the methods on the main thread on iOS and on a background thread on macOS. Guess it's the same on both platforms now?

Replies

We're seeing the same thing in our application, and indeed it also applies to the request:didFailWithError: delegate function.

The Storekit methods on macOS were always called on a background thread. Always thought it was strange that they called the methods on the main thread on iOS and on a background thread on macOS. Guess it's the same on both platforms now?

We just started seeing this in our appn as well. Looks like a behavior change and at least a bug in the developer documentation; observed on iOS 13.1.2, iPhone SE

Thanks for confirming this behaviour. Out of interest, have you seen anything in the developer documentation which explicitly mentions the threading model for SKProductsRequestDelegate?

i run to this only on macOS

The doc for SKProductsRequestDelegate (https://developer.apple.com/documentation/storekit/skproductsrequestdelegate) mentions threading considerations.