Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
714 views
in Technique[技术] by (71.8m points)

ios - SKEffectNode combined with CIFilter runs out of memory

I tried to combine a SKEffectNode with a CIFilter and a child SKSpriteNode and while its seems to work for a few moments, the result is that all device memory is consumed and my iPad Retina (A7 GPU) just reboots. I also sometime see "Message from debugger: Terminated due to memory issue" printed to the debugger log. The full source is on github at SKEffectNodeFiltered.

I am creating the filter like so:

  // Pixelate CoreImage filter

  CIFilter *pixellateFilter = [CIFilter filterWithName:@"CIPixellate"];
  [pixellateFilter setDefaults]; // Remember to setDefaults...
  [pixellateFilter setValue:@(25.0) forKey:@"inputScale"];

  SKEffectNode *effectNode = [[SKEffectNode alloc] init];
  effectNode.shouldEnableEffects = TRUE; // enable CoreImage filtering
  effectNode.shouldRasterize = FALSE; // generate and then discard tmp framebuffer
  effectNode.shouldCenterFilter = TRUE;
  effectNode.filter = pixellateFilter;
  self.effectNode = effectNode;

  [effectNode addChild:background];
  [self addChild:effectNode];

  effectNode.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame));

I looked at the allocations tool, I do see a triple buffered set of CoreSurface objects, but there is not an obvious memory leak. The memory usage is quite large at around 140 Megs total, this is large but this is testing the use of a very large input image at 4096x4096 which is the max texture size. What is going on here? If I did not use a filter, then performance is 60 FPS and there is no problem with memory usage.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.8k users

...