简体   繁体   中英

ARKIT: Observe lagging while drawing line between one SCNNode to another SCNNode

I have draw lines and create box with dimension. Facing lagging issue on iPhone 8 and above but working smooth on iPhone7.

For updating lines:

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)
        }
    }

在此处输入图片说明

iPhone 7:

CPU: 48%

Memory: 199MB

FPS: 60

Frame Rendering Time: 1.9 ms

iPhone 8 Plus: CPU: 48%

Memory: 236 MB

GPU: 4.5

FPS: 60

Frame Rendering Time: 16.6 ms

There is no memory leaks in the project.

I was facing lagging issue for iphone 8 plus and above but drawing line was working smooth on iPhone7 so i implemented

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

To Compare difference between iPhone7 and iPhone8-plus what i notice that iPhone 8Plus and above taking 18ms frame rendering time and for iphone 7 it was just 1ms frame rendering time so I reduce FPS from default value of 60FPS

sceneView.preferredFramesPerSecond = 40

Now The lagging issue is solved

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM