SKView leaks memory when containing an SKLightNode which casts shadows
| Originator: | msealand | ||
| Number: | rdar://18041007 | Date Originated: | 8/16/2014 |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | iOS 8 |
| Classification: | Reproducible: | Always |
Summary:
When an SKView contains at an SKLightNode and an SKSpriteNode setup to cast a shadow, SKView's rendering pass will leak memory. This only occurs if the SKSpriteNode's shadowCastBitMask corresponds to the SKLightNode's categoryBitMask so that it casts a shadow. If more light sources are added, more memory is leaked on each pass. The leak itself appears to be a 32 byte malloc in SKCRenderer::calculateShadowsAndSubmitSprites(). This only seem to occur on iOS devices, and not in the iOS simulator.
Steps to Reproduce:
1. Create a new iOS Xcode project using the Sprite Kit template and Swift.
2. Replace the implementation of GameScene with the following:
class GameScene: SKScene {
override func didMoveToView(view: SKView) {
let center = CGPointMake(size.width / 2.0, size.height / 2.0)
let wall = SKSpriteNode(color: SKColor.whiteColor(), size: CGSizeMake(size.width / 8.0, 16.0))
wall.position = center
wall.shadowCastBitMask = 1
addChild(wall)
let light = SKLightNode()
light.position = CGPointMake(center.x, center.y - 100)
addChild(light)
}
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
for touch: AnyObject in touches {
let location = touch.locationInNode(self)
let light = SKLightNode()
light.position = location
addChild(light)
}
}
}
3. Run the app on a physical iOS device.
4. Use the Debug navigator in Xcode or Instruments to watch the memory slowly climb on each rendering pass.
5 (optional). Tap the screen a few times to add more light sources to watch memory climb faster.
Expected Results:
Memory usage should be basically steady over time as long as the scene isn't changing.
Actual Results:
Memory usage climbs on each rendering pass.
Version:
iOS 8.0 [12A4345d]
Notes:
Configuration:
iPhone 5S 32GB AT&T, iPad 3rd-gen WiFi
Attachments:
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!