We noticed when using async await with SpriteKit run function.
Self is retained until run action is completed which can cause memory leak.
Task {
try? await Task.sleep(nanoseconds: 2 * NSEC_PER_SEC)
await controller.startIntro()
print("intro done")
}
If you deallocate controller, memory won't be released until await is not completed.
calling:
scene.removeAllActions()
cause memory leak.
Here is project reproducing steps with possible workarounds:
https://github.com/maradic/SpriteKitConcurrencyBug
Is this SpriteKit bug or am I doing something wrong?