问题
Can anyone please help me in debugging this issue, from the time i started working with Xcode 9 GM seed with iOS 11 GM seed, my code throwing me a warning in the console saying:
2017-09-18 16:22:52.872716+0530 **** *****[359:20158] [reports] Main Thread Checker: UI API called on a background thread: -[UIApplication
applicationState] .PID: 359, TID: 20158,
Thread name: Runtime Network Callback Thread,
Queue name: com.apple.root.default-qos.overcommit, QoS: 21
Backtrace:
also, i'm using ESRI maps in my application, when ever i zoom in or zoom out in ESRI maps i'm getting this error:
2017-09-18 16:22:53.176524+0530 *** ***[359:20063] Task <5F9376DB-9335-
4A45-B3F0-1D6FD69A19A3>.<29> finished with error - code: -999
2017-09-18 16:22:53.178923+0530 *** ***[359:20142] Task <0DE282EA-3FBD-
4036-8298-C75EFA65F15A>.<40> HTTP load failed (error code: -999 [1:89])
2017-09-18 16:22:53.179821+0530 *** *[359:20063] Task <BE2D8BAE-FFB8-
43CA-8723-111326DEF4FD>.<31> finished with error - code: -999
2017-09-18 16:22:53.180089+0530 *** ***[359:20063] Task <E7C819D4-C11A-
4915-B021-A73F31BE89CD>.<33> finished with error - code: -999
2017-09-18 16:22:53.180365+0530 *** ***[359:20063] Task <3B871761-B006-
4220-B857-6204B385AD34>.<34> finished with error - code: -999
2017-09-18 16:22:53.180523+0530 *** ***[359:20142] Failed to get
TCPIOConnection in addInputHandler.
Application works fine with Xcode 8 iOS 10.3.3. Problem seems to be with Xcode 9. Can anyone please help me in debugging this issue. Thanks
回答1:
Xcode 9 adds a new runtime checks which is the Main Thread Checker.
According to Apple documentation:
The Main Thread Checker is a standalone tool for Swift and C languages that detects invalid usage of AppKit, UIKit, and other APIs on a background thread. Updating UI on a thread other than the main thread is a common mistake that can result in missed UI updates, visual defects, data corruptions, and crashes.
You already had this issue in your app with Xcode 8. It's just that the tool to detect it was not there yet.
In your case, it seems that it's a call to UIApplication.shared.applicationState
that is causing this runtime issue.
You can configure your app scheme to stop execution when it happens. It is a checkbox in the Diagnostics tab, under the Main Thread Checker section.
来源:https://stackoverflow.com/questions/46278957/main-thread-checker-ui-api-called-on-a-background-thread-ios-11-xcode-9-gm-seed