Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
740 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 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...