问题
I am building a simple game in SceneKit. It's a car racing game on a highway.
My lane
is a SCNNode
which holds children that are actually flattened clones of other static non-moving geometry models (vegetation, grass roadside, etc.). The problem is happening when I remove parts of the road that are invisible in camera by simply:
func removeLastLane() {
guard let laneNode = lanes.first else { return }
if lanes.count > 0 {
lanes.removeFirst()
}
laneNode.removeFromParentNode()
}
In the console the error appears:
objc[37558]: __weak variable at 0x600002701cf0 holds 0x600002701d99 instead of 0x600002200b40. This is probably incorrect use of objc_storeWeak() and objc_loadWeak(). Break on objc_weak_error to debug.
I have tried to debug it, but the trace is not showing anything sensible.
When I'm not using the flattenedClone()
method, then above error is not occurring, but then I have more draw calls :(
Do you know why this error occurs?
EDIT 1: Added link to the obj-c implementation of failing method in runtime https://opensource.apple.com/source/objc4/objc4-646/runtime/objc-weak.mm
来源:https://stackoverflow.com/questions/54053254/scenekit-flattenedclone-incorrect-use-of-objc-storeweak-and-objc-loadweak