控制台在加载 UIWebView 时显示 AutoLayout Engine 警告,有时会使应用程序崩溃

Console shows AutoLayout Engine Warning while loading UIWebView and Crashes the app sometimes

总结: 尝试在 UIWebView 上加载 URL/HTML 字符串时,控制台会显示类似 "This application is modifying the autolayout engine from a background thread after the engine was accessed from the main thread. This can lead to engine corruption and weird crashes." 的警告,并在某些时候使应用程序崩溃。

重现步骤:

  1. UIWebView 上加载 URL/HTML 字符串。
  2. 控制台将显示 AutoLayout 引擎警告。
  3. 应用程序崩溃了几次(未捕获的异常:主线程上只有 运行!)。

预期结果: 应用程序不应在加载时显示任何警告 UIWebView 并且不应因该警告而使应用程序崩溃。

实际结果: 在从主线程访问引擎后,此应用程序正在从后台线程修改自动布局引擎。这可能会导致引擎损坏和奇怪的崩溃。

    Stack:(
        0   CoreFoundation                      0x0000000188e35998 <redacted> + 148
        1   libobjc.A.dylib                     0x00000001884304bc objc_exception_throw + 56
        2   CoreFoundation                      0x0000000188e358c8 <redacted> + 0
        3   Foundation                          0x00000001899a3da0 <redacted> + 192
        4   Foundation                          0x00000001899a3b00 <redacted> + 76
        5   Foundation                          0x0000000189808548 <redacted> + 108
        6   Foundation                          0x00000001899a2788 <redacted> + 104
        7   UIKit                               0x000000018ebbc76c <redacted> + 1464
        8   QuartzCore                          0x000000018c0e0d6c <redacted> + 148
        9   QuartzCore                          0x000000018c0d5aac <redacted> + 292
        10  QuartzCore                          0x000000018c0d596c <redacted> + 32
        11  QuartzCore                          0x000000018c0554fc <redacted> + 252
        12  QuartzCore                          0x000000018c07c7c4 <redacted> + 512
        13 

 QuartzCor

iOS版本: iOS 10 beta 1

Xcode版本: Xcode 8 beta

此问题已在 iOS 10 beta2 中得到解决。

谢谢!

这个问题发生在 iOS 10 beta1 中,我在 Apple Bug 报告中用示例项目提交了一个问题。现在问题已在 iOS 10 beta 2.

中得到解决

谢谢!