ARKit -[UIView setAnimationsEnabled:] 不支持从后台线程对 UIView 或子类执行任何操作 [英] ARKit -[UIView setAnimationsEnabled:] Performing any operation from a background thread on UIView or a subclass is not supported

查看:25
本文介绍了ARKit -[UIView setAnimationsEnabled:] 不支持从后台线程对 UIView 或子类执行任何操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 ViewController,里面有一个 collectionView.我在 ARSCNView 中显示 collectionView 单元格的内容.

当我将 ViewController 的 view 属性设置为 Material 的 content 属性 时,我从问题中得到了错误.

material.diffuse.contents = self.myViewController.view//产生错误,有时会崩溃.当它没有崩溃时,我可以很好地看到 collectionView 但错误仍然存​​在

我知道是 vc 的 view property 导致了问题,因为当我尝试设置 vc 而不使用它的 view 属性时,错误消失了.问题是我再也看不到场景上的 vc.

material.diffuse.contents = self.myViewController//不会产生错误但 collectionView 不再可见.

如何在 mainQueue 上设置 vc 的视图属性来避免这个问题?

解决方案

我联系了 Apple,他们说目前不支持此功能.他们在保密协议下向我发送了信息,因此我无法详细说明.

他们确实说过如果这是我想要的功能,我可以向他们的团队发送请求,看看他们是否会考虑添加它.

I have a ViewController that has a collectionView inside of it. I display the contents of the collectionView's cells inside an ARSCNView.

When I set the ViewController's view property to the Material's content property I get the error from the question.

material.diffuse.contents = self.myViewController.view // produces error and sometimes it crashes. When it does't crash I can see the collectionView fine but the error is still there

I know it's the vc's view property that is causing the problem because when I try to set the vc without using its view property the error goes away. The thing is I can no longer see the vc on the Scene.

material.diffuse.contents = self.myViewController // produces no error but the collectionView is no longer visible.

How I can set the vc's view property on the mainQueue to avoid this problem?

The same problem happened to this person.

My code (other then the delegate methods this is all the code inside the class):

MyViewController: UIViewController, ...CollectionViewDataSource && Delegate {

    lazy var collectionView: UICollectionView = {
        // create collectionView
    }()

    var dataSource = ["0", "1", "2", "3", "4" ...]

    override func viewDidLoad() {
        super.viewDidLoad()

        DispatchQueue.main.async {

            self.view.backgroundColor = UIColor.clear

            self.view.addSubview(collectionView)
            // set its anchors
        }
    }
}

ClassWithSceneKit:

lazy var sceneView: ARSCNView = { ... }()

let myVC = MyViewController()

override func viewDidLoad() {
    super.viewDidLoad()

    DispatchQueue.main.async  {

        self.myVC.tableData.append("9")
        self.myVC.tableData.append("10")
        self.myVC.tableData.append("11")
        self.myVC.collectionView.reloadData()

        self.myVC.view.isOpaque = false // the background is clear, look in the picture I attached

        let material = SCNMaterial()
        material.diffuse.contents = self.myVC.view // ** this is the line causing the problem ***

        let plane = SCNPlane(width: 0.5, height: 0.7)
        plane.materials = [material]
        plane.cornerRadius = 0.015

        let node = SCNNode()
        node.geometry = plane
        node.position = SCNVector3(0.36, 0.12, -0.8)

        self.sceneView.scene.rootNode.addChildNode(node)
    }
}

ARKit_4[20429:4746699] [Animation] +[UIView setAnimationsEnabled:] being called from a background thread. Performing any operation from a background thread on UIView or a subclass is not supported and may result in unexpected and insidious behavior.

trace=(
    0   UIKitCore                           0x000000019a855fa4 B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 15241124
    1   libdispatch.dylib                   0x0000000103356bd8 _dispatch_client_callout + 16
    2   libdispatch.dylib                   0x00000001033584c8 _dispatch_once_callout + 84
    3   UIKitCore                           0x000000019a855f08 B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 15240968
    4   UIKitCore                           0x000000019a856090 B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 15241360
    5   UIKitCore                           0x0000000199b9d030 B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 1900592
    6   UIKitCore                           0x000000019a5fdd0c B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 12782860
    7   UIKitCore                           0x000000019a40462c B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 10712620
    8   UIKitCore                           0x000000019a5fbaa4 B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 12774052
    9   UIKitCore                           0x000000019a401b8c B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 10701708
    10  UIKitCore                           0x000000019a4029ac B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 10705324
    11  UIKitCore                           0x000000019a402710 B7E79AF1-F09F-3BCE-B073-ECEA027BC0E8 + 10704656
    12  SceneKit                            0x00000001aa496864 5DCB330E-65B4-3BA3-8648-D7BB0F7849CC + 2283620
    13  SceneKit                            0x00000001aa4969c8 5DCB330E-65B4-3BA3-8648-D7BB0F7849CC + 2283976
    14  SceneKit                            0x00000001aa4b67d8 5DCB330E-65B4-3BA3-8648-D7BB0F7849CC + 2414552
    15  SceneKit                            0x00000001aa329168 5DCB330E-65B4-3BA3-8648-D7BB0F7849CC + 786792
    16  SceneKit                            0x00000001aa2f94c8 5DCB330E-65B4-3BA3-8648-D7BB0F7849CC + 591048
    17  SceneKit                            0x00000001aa2f93f0 5DCB330E-65B4-3BA3-8648-D7BB0F7849CC + 590832
    18  SceneKit                            0x00000001aa31c0f0 5DCB330E-65B4-3BA3-8648-D7BB0F7849CC + 733424
    19  SceneKit                            0x00000001aa31935c 5DCB330E-65B4-3BA3-8648-D7BB0F7849CC + 721756
    20  SceneKit                            0x00000001aa31809c 5DCB330E-65B4-3BA3-8648-D7BB0F7849CC + 716956
    21  SceneKit                            0x00000001aa31700c 5DCB330E-65B4-3BA3-8648-D7BB0F7849CC + 712716
    22  SceneKit                            0x00000001aa43f878 5DCB330E-65B4-3BA3-8648-D7BB0F7849CC + 1927288
    23  SceneKit                            0x00000001aa43f5cc 5DCB330E-65B4-3BA3-8648-D7BB0F7849CC + 1926604
    24  SceneKit                            0x00000001aa44684c 5DCB330E-65B4-3BA3-8648-D7BB0F7849CC + 1955916
    25  SceneKit                            0x00000001aa2d2554 5DCB330E-65B4-3BA3-8648-D7BB0F7849CC + 431444
    26  SceneKit                            0x00000001aa2d3ea4 5DCB330E-65B4-3BA3-8648-D7BB0F7849CC + 437924
    27  SceneKit                            0x00000001aa3cbe28 5DCB330E-65B4-3BA3-8648-D7BB0F7849CC + 1453608
    28  SceneKit                            0x00000001aa3cc694 5DCB330E-65B4-3BA3-8648-D7BB0F7849CC + 1455764
    29  SceneKit                            0x00000001aa3ccc00 5DCB330E-65B4-3BA3-8648-D7BB0F7849CC + 1457152
    30  SceneKit                            0x00000001aa3ccf94 5DCB330E-65B4-3BA3-8648-D7BB0F7849CC + 1458068
    31  SceneKit                            0x00000001aa4672f0 5DCB330E-65B4-3BA3-8648-D7BB0F7849CC + 2089712
    32  ARKit                               0x00000001b176d104 4003283E-C369-3DBD-A6D1-3D04690F6674 + 958724
    33  SceneKit                            0x00000001aa32d8d0 5DCB330E-65B4-3BA3-8648-D7BB0F7849CC + 805072
    34  SceneKit                            0x00000001aa432b1c 5DCB330E-65B4-3BA3-8648-D7BB0F7849CC + 1874716
    35  libdispatch.dylib                   0x0000000103356bd8 _dispatch_client_callout + 16
    36  libdispatch.dylib                   0x0000000103365858 _dispatch_lane_barrier_sync_invoke_and_complete + 124
    37  SceneKit                            0x00000001aa432aac 5DCB330E-65B4-3BA3-8648-D7BB0F7849CC + 1874604
    38  GPUToolsCore                        0x000000010357d5f8 -[DYDisplayLinkInterposer forwardDisplayLinkCallback:] + 168
    39  QuartzCore                          0x000000019cc72860 8705A7FE-6FD6-301F-BE30-D32F13CB6C0E + 71776
    40  IOKit                               0x00000001972a4930 IODispatchCalloutFromCFMessage + 488
    41  CoreFoundation                      0x00000001962ba670 FF63481D-FB6A-353B-B2C1-AC4EAECF594D + 525936
    42  CoreFoundation                      0x00000001962e3e40 FF63481D-FB6A-353B-B2C1-AC4EAECF594D + 695872
    43  CoreFoundation                      0x00000001962e356c FF63481D-FB6A-353B-B2C1-AC4EAECF594D + 693612
    44  CoreFoundation                      0x00000001962de440 FF63481D-FB6A-353B-B2C1-AC4EAECF594D + 672832
    45  CoreFoundation                      0x00000001962dd8a0 CFRunLoopRunSpecific + 464
    46  Foundation                          0x000000019661d824 3C682044-3249-3938-8111-F2F12D066D2B + 30756
    47  SceneKit                            0x00000001aa32dcac 5DCB330E-65B4-3BA3-8648-D7BB0F7849CC + 806060
    48  SceneKit                            0x00000001aa32def4 5DCB330E-65B4-3BA3-8648-D7BB0F7849CC + 806644
    49  libsystem_pthread.dylib             0x00000001960821d0 _pthread_start + 124
    50  libsystem_pthread.dylib             0x0000000196085ae0 thread_start + 8
)

解决方案

I contacted Apple and they said this feature currently isn't supported. They sent me the info under a nda so I can't elaborate beyond that.

They did say if it was a feature I wanted I can send a request to their team to see if they would consider adding it.

这篇关于ARKit -[UIView setAnimationsEnabled:] 不支持从后台线程对 UIView 或子类执行任何操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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