In the following code:
public class Foo {
public func createNode() -> SCNNode {
return SCNNode()
}
public func createNode() -> SKNode {
return SKNode()
}
}
Compiling with Swift 6 strict concurrency checking, the line return SKNode() doesn't compile with the error Call to main actor-isolated initializer 'init()' in a synchronous nonisolated context and the proposed fix Add '@MainActor' to make instance method 'createNode()' part of global actor 'MainActor'.
Any call to a SKNode method or property does the same.
This doesn't happen with the return SCNNode().
In my app, these methods should be called inside my SCNSceneRendererDelegate methods, such as renderer(_:updateAtTime:), so I can't take the penalty of going back to the MainActor.
Why is SKNode bound to MainActor (when SCNNode is not), and how to walk this around ?
SKNodeis a subclass ofUIResponder, andUIResponderis isolated to the main actor, soSKNodeis, too.