【问题标题】:iOS9 'modifying the autolayout engine from a background thread' without using autolayoutiOS9'从后台线程修改自动布局引擎'而不使用自动布局
【发布时间】:2016-04-27 20:14:18
【问题描述】:

我开始收到此警告:

此应用程序正在从后台修改自动布局引擎 线程,这可能导致引擎损坏和奇怪的崩溃。这 将在未来的版本中导致异常。

这是带有警告消息的回溯:

Stack:(
0   CoreFoundation                      0x25542303 <redacted> + 150
1   libobjc.A.dylib                     0x24d0edff objc_exception_throw + 38
2   CoreFoundation                      0x25542231 <redacted> + 0
3   Foundation                          0x25e25bbb <redacted> + 170
4   Foundation                          0x25ccb637 <redacted> + 38
5   UIKit                               0x297e0431 <redacted> + 52
6   UIKit                               0x297e0e1f <redacted> + 222
7   UIKit                               0x297fd52d <redacted> + 96
8   UIKit                               0x29efe579 <redacted> + 320
9   UIKit                               0x299dc8e9 <redacted> + 148
10  UIKit                               0x299cb44f <redacted> + 42
11  UIKit                               0x296d5a83 <redacted> + 714
12  QuartzCore                          0x277b1ad5 <redacted> + 128
13  QuartzCore                          0x277ad1d1 <redacted> + 352
14  QuartzCore                          0x277ad061 <redacted> + 16
15  QuartzCore                          0x277ac581 <redacted> + 368
16  QuartzCore                          0x277ac233 <redacted> + 614
17  QuartzCore                          0x277d9b63 <redacted> + 310
18  libsystem_pthread.dylib             0x25279905 <redacted> + 508
19  libsystem_pthread.dylib             0x25279507 <redacted> + 86
20  libsystem_pthread.dylib             0x2527a485 pthread_exit + 28
21  Foundation                          0x25ca31d7 <redacted> + 10
22  Foundation                          0x25d5e34f <redacted> + 1178
23  libsystem_pthread.dylib             0x2527ac7f <redacted> + 138
24  libsystem_pthread.dylib             0x2527abf3 _pthread_start + 110
25  libsystem_pthread.dylib             0x25278a08 thread_start + 8

据我所知,我不使用自动布局(因为我希望该应用程序与 iOS 5.1.1 兼容)。而且我似乎不在报告的回溯范围内。

我还启用了 PSPDFUIKitMainThreadGuard 类,它应该检查主线程访问,但没有任何触发。

有什么办法可以查出是什么在做这样的事情吗?

问题This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes 没有解释如何调试这样的东西。

【问题讨论】:

  • 对主队列以外的任何 UI 组件的任何更新都会生成此消息 - 因此请查看从完成处理程序等更新 UI 的位置
  • 添加异常断点。向我们展示导致崩溃的代码,而不是错误。 :D
  • 应用程序没有崩溃,它只是在调试日志中产生这个警告,我真的不知道代码的哪一部分是这样做的......调试与 PSPDFUIKitMainThreadGuard 类一起工作得很好,但它对这个问题没有任何作用
  • 找到你所有的后台作业(线程、调度...),看看它是否有任何 UI 变化。

标签: ios multithreading autolayout


【解决方案1】:

您是否直接使用Autolayout 不是当前的问题。操作系统正在将传统的 autoresizingMask 转换为现代的 NSLayoutConstraint

这个问题与从主踏板以外的任何地方修改 UI 有关。 这通常发生在:

  • 回复NSNotification
  • 从异步方法返回
  • 在您无法控制的线程上执行完成块
  • 在后台显式调度任务

关于应用程序不会崩溃的注意事项...
应用崩溃。您所需要的只是时间和几千名用户...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-14
    • 2016-06-20
    • 2018-01-23
    • 1970-01-01
    相关资源
    最近更新 更多