I’ve been having some fun in the last few days blitting video into SceneKit textures. Now going back to AVPlayerLayer in the same project today, I found an internal SceneKit assertion failing.

Assertion failed: (renderSize.x != 0), function -[SCNRenderContextMetal _setupDescriptor:forPass:isFinalTechnique:], file /BuildRoot/Library/Caches/com.apple.xbs/Sources/SceneKit/SceneKit-332.6/sources/Core3DRuntime/NewRenderer/SCNRenderContextMetal.mm, line 688.

After checking that my SceneKit properties weren’t being used (sceneView isn’t even added to the view hierarchy), I changed the initialization of my SCNView to use an explicit frame.

class BestAppEverViewController: UIViewController {
    // MARK:  I fail!
    let sceneView = SCNView()

    // MARK: - I work!
    let sceneView = SCNView(frame: CGRect(x: 0, y: 0, width: 1, height: 1))
}

Sure enough, using a frame with some pixels in it works. Even if your SCNView is not on screen. This would definitely seem to be a SceneKit bug in iOS 9.3 and perhaps going back earlier.