Chris
Chris

Reputation: 1437

SceneView hittest crash on ios 11.4, runs on iOS 12+

I am experiencing a crash of the m_sceneView.hittest(...) function on iOS 11.4. The same code runs on iOS 12+ !

Code looks like this:

func renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval) {
  guard m_sceneView.session.currentFrame != nil else {return}

  DispatchQueue.main.async(execute: {
    if let camera = self.m_sceneView.session.currentFrame?.camera, 
                    case .normal = camera.trackingState {
      let results = self.m_sceneView.hitTest(self.m_sceneView.center, 
                    options: [SCNHitTestOption.searchMode: 2])
      guard let result = results.first else {
        print("No Hittest results received")
        return
      }

      // do something with the hittest result !
      // ...
      // ...
    }
  })
}

I get a "EXC_BAD_ACCESS (code=1, address=0x0)" crash on the hittest line.

Any ideas how to fix this issue ?

Upvotes: 1

Views: 228

Answers (1)

Victor Alonso Barberan
Victor Alonso Barberan

Reputation: 314

I got a Solution from Apple guys. It is actually a bug in the SceneKit API which was solved in IOS 12, but there is a workaround for versions earlier than 12:

let options: [SCNHitTestOption: Any] = [SCNHitTestOption.boundingBoxOnly: true]
let hitResults = scnView.hitTest(p, options: options)

Upvotes: 1

Related Questions