主线程检查器:在后台线程上调用的UI API iOS 11 Xcode 9 GM Seed [英] Main Thread Checker: UI API called on a background thread iOS 11 Xcode 9 GM Seed

查看:385
本文介绍了主线程检查器:在后台线程上调用的UI API iOS 11 Xcode 9 GM Seed的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从我开始使用iOS 11 GM种子开始使用Xcode 9 GM种子开始,有人可以帮助我调试此问题,我的代码在控制台中向我抛出警告:

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:

此外,我在应用程序中使用ESRI地图,每当我放大或缩小ESRI地图时,我都会收到此错误:

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.

应用程序可以在Xcode 8 iOS 10.3.3上正常运行.问题似乎与Xcode 9有关.任何人都可以帮助我调试此问题.谢谢

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

推荐答案

Xcode 9添加了新的运行时检查,即主线程检查器.

Xcode 9 adds a new runtime checks which is the Main Thread Checker.

根据Apple文档:

主线程检查器是用于Swift和C语言的独立工具 检测到无效使用的AppKit,UIKit和其他API 后台线程.在主线程以外的其他线程上更新UI 是一个常见的错误,可能会导致错过UI更新(视觉效果) 缺陷,数据损坏和崩溃.

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.

使用Xcode 8在您的应用中已经存在此问题.只是检测它的工具还不存在.

You already had this issue in your app with Xcode 8. It's just that the tool to detect it was not there yet.

在您的情况下,似乎是对UIApplication.shared.applicationState的调用导致了此运行时问题.

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.

这篇关于主线程检查器:在后台线程上调用的UI API iOS 11 Xcode 9 GM Seed的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆