SKEffectNode combined with CIFilter runs out of memory

爷,独闯天下 提交于 2019-11-28 06:09:42

问题


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.

来源:https://stackoverflow.com/questions/54431826/skeffectnode-combined-with-cifilter-runs-out-of-memory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!