ARKit-[UIView setAnimationsEnabled:]不支持从UIView上的后台线程或子类执行任何操作 [英] ARKit -[UIView setAnimationsEnabled:] Performing any operation from a background thread on UIView or a subclass is not supported
问题描述
我有一个ViewController,里面有一个collectionView.我在ARSCNView中显示collectionView单元的内容.
I have a ViewController that has a collectionView inside of it. I display the contents of the collectionView's cells inside an ARSCNView.
当我将ViewController的view属性设置为Material的content property
时,我从问题中得到了错误.
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
我知道是导致问题的是vc的view property
,因为当我尝试不使用其view属性设置vc时,错误就消失了.问题是我无法再在场景中看到vc.
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.
如何在mainQueue上设置vc的view属性以避免此问题?
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:
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:] 从后台线程被调用.从 不支持UIView或子类上的后台线程,并且可能 导致意外和阴险的行为.
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
)
推荐答案
我联系了Apple,他们说目前不支持此功能.他们通过nda向我发送了信息,因此我无法详细说明.
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屋!