ARKIT:在一个SCNNode与另一个SCNNode之间画线时观察滞后

问题描述 投票:-2回答:1

我有画线和创建尺寸框。面对iPhone 8及以上版本的滞后问题,但在iPhone7上运行顺畅。

更新行:

fileprivate func updateLine(_ line: SCNNode, from position: SCNVector3, distance: Float, axis: SCNVector3.Axis) {
        guard let box = line.geometry as? SCNBox else {
            fatalError("Tried to update something that is not a line")
        }

        let absDistance = CGFloat(abs(distance))
        let offset = distance * 0.5
        switch axis {
        case .x:
            box.width = absDistance
            line.position = position + SCNVector3(x: offset, y: 0, z: 0)
        case .y:
            box.height = absDistance
            line.position = position + SCNVector3(x: 0, y: offset, z: 0)
        case .z:
            box.length = absDistance
            line.position = position + SCNVector3(x: 0, y: 0, z: offset)
        }
    }

enter image description here

iPhone 7:

CPU:48%

内存:199MB

FPS:60

帧渲染时间:1.9毫秒

iPhone 8 Plus:CPU:48%

内存:236 MB

GPU:4.5

FPS:60

帧渲染时间:16.6 ms

项目中没有内存泄漏。

ios swift xcode augmented-reality arkit
1个回答
0
投票

我正面临着iphone 8 plus及以上的滞后问题,但绘制线在iPhone7上运行顺畅,所以我实现了

 // Show statistics such as fps and timing information
        sceneView.showsStatistics = true

为了比较iPhone7和iPhone8之间的区别,我注意到iPhone 8Plus及以上版本占用了18ms的帧渲染时间,对于iphone 7而言,帧时间仅为1ms,因此我将FPS从默认值60FPS降低

sceneView.preferredFramesPerSecond = 40

现在,滞后的问题已经解决了

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.