I have a SceneKit SCNRenderer that I'm using to draw some objects into an existing OpenGL application.
renderer = SCNRenderer( context: EAGLContext.current(), options: nil )
I invoke it from the glkView method for each frame, after updating its camera transforms:
override func glkView(_ view: GLKView, drawIn rect: CGRect) {
// render my OpenGL stuff
...
// Render the SceneKit
cameraNode.transform = SCNMatrix4Invert(SCNMatrix4FromGLKMatrix4(matrices.mvMatrix))
cameraNode.camera!.projectionTransform = SCNMatrix4FromGLKMatrix4(matrices.cameraMatrix)
SCNTransaction.flush() // <= This solved the problem!
renderer.render(atTime: 0)
My OpenGL app renders at 60fps by itself and if I only render the SceneKit as above it also renders fluidly. But when I combine them what happens is the SceneKit seems to lag behind rendering maybe 1 fps. In the following screencap (reduced to gif) the plane is being drawn by OpenGL and it tracks my finger perfectly, but the box drawn by SceneKit lags way behind. If I comment out the plane drawing code the box tracks perfectly.
I'm afraid the answer is going to be to invert this and do my OpenGL drawing inside the SceneKit run loop. Hoping there's some other path.
UPDATE: I can't post the animated gif but here's the link.
UPDATE 2: Adding the scene flush() call as suggested by Toyos solved the problem.