问题描述
我正在使用AR Kit进行图像跟踪,一旦检测到图像,我就使用GIFU播放GIF https: //github.com/kaishin/Gifu 库.使用以下代码成功完成此操作.
I'm doing image tracking using AR Kit, once image is detected i'm playing GIF with GIFUhttps://github.com/kaishin/Gifu library. This is successful with below code.
在VC中,我添加了GIFImageView,如下所示:
In VC i added GIFImageView as below:
var imageView = GIFImageView(frame: CGRect(x: 0, y: 0, width: 600, height: 600))
在ARSceneView中,委托didAdd节点方法如下:
And in ARSceneView delegate didAdd node method is below:
func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) {
DispatchQueue.main.async { self.instructionLabel.isHidden = true }
if let imageAnchor = anchor as? ARImageAnchor {
// handleFoundImage(imageAnchor, node)
let size = imageAnchor.referenceImage.physicalSize
DispatchQueue.main.async(){ // If we remove this we are getting UIview setAnimation is being call from background thread error is coming.
self.imageView.animate(withGIFNamed: "tenor.gif") // I actually access gif from Document folder i.e Data format
}
let imgMaterial = SCNMaterial()
imgMaterial.diffuse.contents = imageView
let imgPlane = SCNPlane(width: size.width, height: size.height)
imgPlane.materials = [imgMaterial]
let imgNode = SCNNode(geometry: imgPlane)
imgNode.eulerAngles.x = -.pi / 2
node.addChildNode(imgNode)
node.opacity = 1
}
}
我不知道控制台中的问题,我在下面看到了这些东西,玩了GIF后,我无法与应用程序中的UI元素进行交互.如果有人在处理此类问题,请提供帮助.
I don't know the problem here in console i saw this below stuff and after playing GIF i can't able to interact with UI elements in app. Please help if anybody worked on this kind of issue.
[Animation] + [UIView setAnimationsEnabled:].不支持从UIView的后台线程或子类执行任何操作,这可能会导致意外和隐匿的行为.
trace =( 0 UIKitCore 0x00000001c2e87d70 27D3041D-A1DE-3C3A-8DC0-994B5982DC49 + 15252848 1个libdispatch.dylib 0x00000001035b6bd8 _dispatch_client_callout + 16 2 libdispatch.dylib 0x00000001035b84c8 _dispatch_once_callout + 84 3 UIKitCore 0x00000001c2e87cd4 27D3041D-A1DE-3C3A-8DC0-994B5982DC49 + 15252692 4 UIKitCore 0x00000001c2e87e5c 27D3041D-A1DE-3C3A-8DC0-994B5982DC49 + 15253084 5 UIKitCore 0x00000001c21ccb8c 27D3041D-A1DE-3C3A-8DC0-994B5982DC49 + 1903500 6 UIKitCore 0x00000001c2c2ec9c 27D3041D-A1DE-3C3A-8DC0-994B5982DC49 + 12790940 7 UIKitCore 0x00000001c2a357b0 27D3041D-A1DE-3C3A-8DC0-994B5982DC49 + 10721200 8 UIKitCore 0x00000001c2c2c9ec 27D3041D-A1DE-3C3A-8DC0-994B5982DC49 + 12782060 9 UIKitCore 0x00000001c2a32d10 27D3041D-A1DE-3C3A-8DC0-994B5982DC49 + 10710288 10 UIKitCore 0x00000001c2a33b30 27D3041D-A1DE-3C3A-8DC0-994B5982DC49 + 10713904 11 UIKitCore 0x00000001c2a33894 27D3041D-A1DE-3C3A-8DC0-994B5982DC49 + 10713236 12 SceneKit 0x00000001d2afe7cc 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 2283468 13 SceneKit 0x00000001d2afe930 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 2283824 14 SceneKit 0x00000001d2b1e740 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 2414400 15 SceneKit 0x00000001d2990d8c 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 785804 16 SceneKit 0x00000001d2961138 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 590136 17 SceneKit 0x00000001d2961060 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 589920 18 SceneKit 0x00000001d2983d14 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 732436 19 SceneKit 0x00000001d2980f80 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 720768 20 SceneKit 0x00000001d297fcc0 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 715968 21 SceneKit 0x00000001d297ec30 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 711728 22 SceneKit 0x00000001d2aa7870 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 1927280 23 SceneKit 0x00000001d2aa75c4 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 1926596 24 SceneKit 0x00000001d2aae844 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 1955908 25 SceneKit 0x00000001d293a178 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 430456 26 SceneKit 0x00000001d293bac8 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 436936 27 SceneKit 0x00000001d2a33a4c 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 1452620 28 SceneKit 0x00000001d2a342b8 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 1454776 29 SceneKit 0x00000001d2a34824 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 1456164 30 SceneKit 0x00000001d2a34bb8 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 1457080 31 SceneKit 0x00000001d2acf310 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 2089744 32 ARKit 0x00000001d9ec1104 64C95206-B840-361E-B8AC-F70B23A324B4 + 958724 33 SceneKit 0x00000001d29954f4 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 804084 34 SceneKit 0x00000001d2a9ab14 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 1874708 35 libdispatch.dylib 0x00000001035b6bd8 _dispatch_client_callout + 16 36 libdispatch.dylib 0x00000001035c5858 _dispatch_lane_barrier_sync_invoke_and_complete + 124 37 SceneKit 0x00000001d2a9aaa4 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 1874596 38 GPUToolsCore 0x00000001037655f8-[DYDisplayLinkInterposer forwardDisplayLinkCallback:] + 168 39 QuartzCore 0x00000001c52b988c 84C3CD6E-F832-3F6F-BE62-5A4348853273 + 71820 40 IOKit 0x00000001bf8d5934 IODispatchCalloutFromCFMessage + 488 41 CoreFoundation 0x00000001be8e18ac 1B9B1E61-8CB4-3903-9870-402C3DE959BB + 526508 42 CoreFoundation 0x00000001be90b07c 1B9B1E61-8CB4-3903-9870-402C3DE959BB + 696444 43 CoreFoundation 0x00000001be90a7a8 1B9B1E61-8CB4-3903-9870-402C3DE959BB + 694184 44 CoreFoundation 0x00000001be90567c 1B9B1E61-8CB4-3903-9870-402C3DE959BB + 673404 45 CoreFoundation 0x00000001be904adc CFRunLoopRunSpecific + 464 46基金会0x00000001bec447f4 503900AF-2ECD-329F-B742-C07C3E672BEB + 30708 47 SceneKit 0x00000001d29958d0 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 805072 48 SceneKit 0x00000001d2995b18 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 805656 49 libsystem_pthread.dylib 0x00000001be6a7d8c _pthread_start + 156 50 libsystem_pthread.dylib 0x00000001be6ab76c thread_start + 8)这是重现问题的项目:
trace=( 0 UIKitCore 0x00000001c2e87d70 27D3041D-A1DE-3C3A-8DC0-994B5982DC49 + 15252848 1 libdispatch.dylib 0x00000001035b6bd8 _dispatch_client_callout + 16 2 libdispatch.dylib 0x00000001035b84c8 _dispatch_once_callout + 84 3 UIKitCore 0x00000001c2e87cd4 27D3041D-A1DE-3C3A-8DC0-994B5982DC49 + 15252692 4 UIKitCore 0x00000001c2e87e5c 27D3041D-A1DE-3C3A-8DC0-994B5982DC49 + 15253084 5 UIKitCore 0x00000001c21ccb8c 27D3041D-A1DE-3C3A-8DC0-994B5982DC49 + 1903500 6 UIKitCore 0x00000001c2c2ec9c 27D3041D-A1DE-3C3A-8DC0-994B5982DC49 + 12790940 7 UIKitCore 0x00000001c2a357b0 27D3041D-A1DE-3C3A-8DC0-994B5982DC49 + 10721200 8 UIKitCore 0x00000001c2c2c9ec 27D3041D-A1DE-3C3A-8DC0-994B5982DC49 + 12782060 9 UIKitCore 0x00000001c2a32d10 27D3041D-A1DE-3C3A-8DC0-994B5982DC49 + 10710288 10 UIKitCore 0x00000001c2a33b30 27D3041D-A1DE-3C3A-8DC0-994B5982DC49 + 10713904 11 UIKitCore 0x00000001c2a33894 27D3041D-A1DE-3C3A-8DC0-994B5982DC49 + 10713236 12 SceneKit 0x00000001d2afe7cc 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 2283468 13 SceneKit 0x00000001d2afe930 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 2283824 14 SceneKit 0x00000001d2b1e740 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 2414400 15 SceneKit 0x00000001d2990d8c 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 785804 16 SceneKit 0x00000001d2961138 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 590136 17 SceneKit 0x00000001d2961060 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 589920 18 SceneKit 0x00000001d2983d14 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 732436 19 SceneKit 0x00000001d2980f80 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 720768 20 SceneKit 0x00000001d297fcc0 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 715968 21 SceneKit 0x00000001d297ec30 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 711728 22 SceneKit 0x00000001d2aa7870 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 1927280 23 SceneKit 0x00000001d2aa75c4 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 1926596 24 SceneKit 0x00000001d2aae844 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 1955908 25 SceneKit 0x00000001d293a178 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 430456 26 SceneKit 0x00000001d293bac8 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 436936 27 SceneKit 0x00000001d2a33a4c 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 1452620 28 SceneKit 0x00000001d2a342b8 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 1454776 29 SceneKit 0x00000001d2a34824 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 1456164 30 SceneKit 0x00000001d2a34bb8 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 1457080 31 SceneKit 0x00000001d2acf310 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 2089744 32 ARKit 0x00000001d9ec1104 64C95206-B840-361E-B8AC-F70B23A324B4 + 958724 33 SceneKit 0x00000001d29954f4 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 804084 34 SceneKit 0x00000001d2a9ab14 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 1874708 35 libdispatch.dylib 0x00000001035b6bd8 _dispatch_client_callout + 16 36 libdispatch.dylib 0x00000001035c5858 _dispatch_lane_barrier_sync_invoke_and_complete + 124 37 SceneKit 0x00000001d2a9aaa4 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 1874596 38 GPUToolsCore 0x00000001037655f8 -[DYDisplayLinkInterposer forwardDisplayLinkCallback:] + 168 39 QuartzCore 0x00000001c52b988c 84C3CD6E-F832-3F6F-BE62-5A4348853273 + 71820 40 IOKit 0x00000001bf8d5934 IODispatchCalloutFromCFMessage + 488 41 CoreFoundation 0x00000001be8e18ac 1B9B1E61-8CB4-3903-9870-402C3DE959BB + 526508 42 CoreFoundation 0x00000001be90b07c 1B9B1E61-8CB4-3903-9870-402C3DE959BB + 696444 43 CoreFoundation 0x00000001be90a7a8 1B9B1E61-8CB4-3903-9870-402C3DE959BB + 694184 44 CoreFoundation 0x00000001be90567c 1B9B1E61-8CB4-3903-9870-402C3DE959BB + 673404 45 CoreFoundation 0x00000001be904adc CFRunLoopRunSpecific + 464 46 Foundation 0x00000001bec447f4 503900AF-2ECD-329F-B742-C07C3E672BEB + 30708 47 SceneKit 0x00000001d29958d0 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 805072 48 SceneKit 0x00000001d2995b18 5BEC4C23-5650-30CD-96CC-314CDAF2E954 + 805656 49 libsystem_pthread.dylib 0x00000001be6a7d8c _pthread_start + 156 50 libsystem_pthread.dylib 0x00000001be6ab76c thread_start + 8)Here is the project to reproduce issue:
只需在Device中运行它即可. https://drive.google.com/file/d/1FKHPO6SkdOEZ-w_GFnrU5CeeeMQrNT-h/view?usp = sharing
Just run this in Device.https://drive.google.com/file/d/1FKHPO6SkdOEZ-w_GFnrU5CeeeMQrNT-h/view?usp=sharing
您只需在设备中运行该项目并扫描dinosaur.png图像(添加了ion xcode),您将gif在其顶部播放.一旦返回到firstVC,所有应用程序都将冻结,您将无法在First VC中点击任何按钮,并且也无法再次启动AR场景.我无法弄清楚这个问题,为什么在申请GIF后可以进行检查并让我知道.
You just run this project in device and scan dinosaur.png image(added ion xcode) you will gif playing on top of it. Once if you go back to firstVC that's all app is freezed you can't tap on any button in First VC and also hyou can't start AR scene again.I can't figure out this issue why it's happening after palying GIF can you pleach check and let me know.
如果需要任何内容,请告诉我..预先感谢.
If anything is required please let me know.. Thanks in advance.
推荐答案
问题已解决.
我们必须将imageView图层添加到SCNMaterial()
we have to add imageView layer to the SCNMaterial()
imgMaterial.diffuse.contents = self.imageView.layer
感谢您的回复.
这篇关于使用SceneKit中的GIFU库播放GIF会导致应用程序UI冻结任何解决方案?从后台线程调用的UIView Animated的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!