SceneKit flattenedClone - incorrect use of objc_storeWeak() and objc_loadWeak() error

[亡魂溺海] 提交于 2019-12-22 10:49:57

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!