SCNNode.position is sometimes not reflected on screen

The desired outcome of the code below is that both the red and yellow spheres should be at the same position at the center of the scene, (0, 0, 0), but instead the red sphere remains at its initial position (1, 0, 0). Commenting out any of the lines marked in the code, strangely, solves the issue. The code shows a simplified version of some other code, so it would be desirable to keep the order of the lines as they currently are. Am I doing something wrong?

class GameViewController: NSViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let scene = SCNScene(named: "art.scnassets/ship.scn")!
        
        let cameraNode = SCNNode()
        cameraNode.camera = SCNCamera()
        scene.rootNode.addChildNode(cameraNode)
        cameraNode.position = SCNVector3(x: 0, y: 0, z: 15)
        
        let lightNode = SCNNode()
        lightNode.light = SCNLight()
        lightNode.light!.type = .omni
        lightNode.position = SCNVector3(x: 0, y: 10, z: 10)
        scene.rootNode.addChildNode(lightNode)
        
        let scnView = self.view as! SCNView
        scnView.scene = scene
        
        let parent0 = SCNNode()
        scene.rootNode.addChildNode(parent0)

        let parent1 = SCNNode()
        scene.rootNode.addChildNode(parent1)

        let sphere0 = SCNNode(geometry: SCNSphere(radius: 1))
        sphere0.geometry!.firstMaterial!.diffuse.contents = NSColor.red
        
        let sphere1 = SCNNode(geometry: SCNSphere(radius: 1))
        sphere1.geometry!.firstMaterial!.diffuse.contents = NSColor.yellow
        
        sphere0.position = SCNVector3(x: -1, y: 0, z: 0) // commenting out this line solves the issue
        parent1.addChildNode(sphere0) // or commenting out this line solves the issue
        sphere0.position = SCNVector3(x: 0, y: 0, z: 0)
        parent0.addChildNode(sphere1) // or commenting out this line solves the issue
        
        DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
            print(sphere0.worldPosition, sphere1.worldPosition)
        }
    }

}

Hello,

Please file a bug report for this issue using Feedback Assistant.

An aside:

If you wrap your position changes in an SCNTransaction, you will see your expected result at the end of the animation. Without the animated transaction, you should still see the same end result (but do not, which is why I'd like you to file the bug report.)

SCNTransaction.begin()
sphere0.position = SCNVector3(x: -1, y: 0, z: 0) // commenting out this line solves the issue
parent1.addChildNode(sphere0) // or commenting out this line solves the issue
sphere0.position = SCNVector3(x: 0, y: 0, z: 0)
parent0.addChildNode(sphere1) // or commenting out this line solves the issue
SCNTransaction.commit()
SCNNode.position is sometimes not reflected on screen
 
 
Q