Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpriteKit/SceneKit Retain Cycles #46

Open
jaredsinclair opened this issue Sep 16, 2016 · 0 comments
Open

SpriteKit/SceneKit Retain Cycles #46

jaredsinclair opened this issue Sep 16, 2016 · 0 comments

Comments

@jaredsinclair
Copy link
Contributor

jaredsinclair commented Sep 16, 2016

The following should be submitted to Apple as a bug radar.

Bug

Setting an SKScene as the contents of an SCNMaterialProperty leads to numerous retain cycles in internal SceneKit and SpriteKit classes.

Steps to Reproduce

  1. Set up an SKScene with a single SKVideoNode child.
  2. Set up an SCNNode using a primitive geometry.
  3. Assign the SKScene as the contents of the SCNNode’s geometry.firstMaterial.diffuse.contents.
  4. Relinquish all references to the SKScene and SCNNode.

Expected Behavior

The SKScene and the SCNNode should be deallocated.

Actual Result

The SKScene and many other instances are leaked due to numerous retain cycles.

Notes

Please run the attached sample code on iOS 10. You can see the retain cycles plainly illustrated using Xcode 8's visual memory debugger. The Leaks instrument will also show some of these leaks when running on a real device running iOS 10. I have not been able to get Instruments to report a leak on iOS 9, and intermittently on iOS 10. However, the visual memory debugger in Xcode 8 always reveals the retain cycles.

You can verify that SCNMaterialProperty.contents is the culprit by commenting out Line 63 in PlayerScene.m.

Uploads

Sample Project: https://www.dropbox.com/s/1j0ib2ojbr1xbym/Memory%20Leak.zip?dl=0

Screenshot

sk-retain-cycle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants