-[SKTexture textureByApplyingCIFilter:] leaks original texture
| Originator: | stephen.gazzard | ||
| Number: | rdar://20006967 | Date Originated: | 02-Mar-2015 11:11 AM |
| Status: | Open | Resolved: | No |
| Product: | iOS SDK | Product Version: | 8.1.3 (12B466) |
| Classification: | Serious Bug | Reproducible: | Always |
Summary:
When you have an SKTexture, and you create another texture with a CIFilter, the original texture is always retained and will not be released until the texture with the filter applied is dealloc'd. This can be a potential issue, as if I wanted to load the spaceship image, make it black and white, then blur it, it would require 3 textures to stay in memory at all times, even though only the effected texture may ever be on the screen.
Steps to Reproduce:
1. Create an SKTexture
2. Create a texture with a filter applied using -[SKTexture textureByApplyingCIFilter:]
This minimal code demonstrates the result. When run in instruments, single taps always tick up the count of live SKTextures, while double taps drop it down to the original number.
@interface GameScene()
@property (weak, nonatomic) SKSpriteNode *ship;
@end
@implementation GameScene
-(void)didMoveToView:(SKView *)view {
SKSpriteNode *sprite = [SKSpriteNode spriteNodeWithImageNamed:@"Spaceship"];
sprite.xScale = 1.5;
sprite.yScale = 1.5;
sprite.position = CGPointMake(500, 500);
[self addChild:sprite];
self.ship = sprite;
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
if (touches.count == 1) {
self.ship.texture = [self.ship.texture textureByApplyingCIFilter:[CIFilter filterWithName:@"CIGaussianBlur"]];
} else {
self.ship.texture = [SKTexture textureWithImageNamed:@"Spaceship"];
}
}
@end
Expected Results:
The # of textures in memory should stay the same, as only one texture is being shown to the user.
Actual Results:
The number of textures in memory will tick up each time, even though one texture is ever being shown to the user.
Version:
8.1.3 (12B466)
Notes:
Configuration:
Any iPhone or iPad, Sim or device
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!