Description
On iOS 17.0 beta, when trying to display a product page with SKStoreProductViewController, "Call must be made on main thread" error occured and the app crashes. The completionBlock in the loadProductWithParameters method is is being called outside of the main thread. This phenomenon does not occur in versions prior to iOS 17.0 beta.
The documentation states, "The completion block is called on the main thread and receives the following parameters"
Since iOS 17.0 beta, the specification and the actual behavior seem to be different. Is this issue going to be fixed?
This issue also occurs in the latest environment at this time, iOS 17.0 beta 3 and Xcode 15.0 beta 4.
Log
The following is a log of the results of running loadProduct
according to this document.
Main Thread Checker: UI API called on a background thread: -[UIViewController presentViewController:animated:completion:]
PID: 11963, TID: 946567, Thread name: (none), Queue name: com.apple.NSXPCConnection.m-user.com.apple.storekitd, QoS: 0
Backtrace:
4 SkanApp 0x000000010433832c __43-[ViewController loadProductViewController]_block_invoke + 108
5 StoreKit 0x00000001d039c1a0 883E1703-40F8-362A-AF04-0D5DF2F54C60 + 164256
6 StoreKit 0x00000001d03aae30 883E1703-40F8-362A-AF04-0D5DF2F54C60 + 224816
7 CoreFoundation 0x00000001a81085c4 5580A260-85DE-375D-933E-4E6035C60CC1 + 484804
8 CoreFoundation 0x00000001a80b5ac0 5580A260-85DE-375D-933E-4E6035C60CC1 + 146112
9 Foundation 0x00000001a7159e64 D9049983-394E-3B07-894C-BF9802EDFCBA + 646756
10 Foundation 0x00000001a712c1e4 D9049983-394E-3B07-894C-BF9802EDFCBA + 459236
11 Foundation 0x00000001a785eea0 D9049983-394E-3B07-894C-BF9802EDFCBA + 8007328
12 libxpc.dylib 0x000000020f92fc14 A4D8D736-F9EE-3A24-9DE7-AFB0E13A8083 + 125972
13 libxpc.dylib 0x000000020f922584 A4D8D736-F9EE-3A24-9DE7-AFB0E13A8083 + 71044
14 libdispatch.dylib 0x00000001050bec1c _dispatch_client_callout3 + 20
15 libdispatch.dylib 0x00000001050ddd08 _dispatch_mach_msg_async_reply_invoke + 392
16 libdispatch.dylib 0x00000001050c682c _dispatch_lane_serial_drain + 376
17 libdispatch.dylib 0x00000001050c77c4 _dispatch_lane_invoke + 460
18 libdispatch.dylib 0x00000001050d4658 _dispatch_root_queue_drain_deferred_wlh + 328
19 libdispatch.dylib 0x00000001050d3c8c _dispatch_workloop_worker_thread + 444
20 libsystem_pthread.dylib 0x000000020f8cee50 _pthread_wqthread + 288
21 libsystem_pthread.dylib 0x000000020f8cebf0 start_wqthread + 8
Unsupported enumeration of UIWindowScene windows on non-main thread.
Unsupported enumeration of UIWindowScene windows on non-main thread.
Unsupported enumeration of UIWindowScene windows on non-main thread.
Unsupported enumeration of UIWindowScene windows on non-main thread.
Unsupported enumeration of UIWindowScene windows on non-main thread.
Unsupported enumeration of UIWindowScene windows on non-main thread.
Unsupported enumeration of UIWindowScene windows on non-main thread.
*** Assertion failure in -[UIApplication _performAfterCATransactionCommitsWithLegacyRunloopObserverBasedTiming:block:], UIApplication.m:3,205
warning: Module "/Users/***/Library/Developer/Xcode/iOS DeviceSupport/iPhone15,3 17.0 (21A5248v)/Symbols/usr/lib/libobjc.A.dylib" uses triple "arm64e-apple-ios17.0.0", which is not compatible with the target triple "arm64-apple-ios11.0.0". Enabling per-module Swift scratch context.
environment
- iOS 17.0 beta ~ iOS 17.0 beta 3
- iPhone 14 Pro Max
- Xcode 15.0 beta ~ Xcode 15.0 beta 4
This has been resolved in iOS 17.0 beta4 and Xcode 15beta5 released today. It seems to be mentioned in ReleaseNotes.
https://developer.apple.com/documentation/ios-ipados-release-notes/ios-ipados-17-release-notes
Resolved Issues
Fixed issue where loadProduct(withParameters:completionBlock:) was called from a background thread. (110640574)