title: UICollectionView bad performance with UIImageViews with Core Image-manipulated images
body: <p>I've got a <code>UICollectionView</code> in my app whose cells mainly consist of <code>UIImageView</code>s containing images that have been manipulated with Core Image to have less color saturation.  Performance is absolutely horrible when scrolling.  When I profile it, the huge majority of time spent (80% or so) is not in my code or even in my stack.  It all appears to be in Core Animation code.  Might anyone know why this could be?</p>
  
  <p>In my <code>UICollectionViewCell</code> subclass I have something like this:</p>
  
  <pre><code>UIImage *img = [self obtainImageForCell];
  img = [img applySaturation:0.5];
  self.imageView.image = img;
  </code></pre>
  
  <p><code>applySaturation</code> looks like this:</p>
  
  <pre><code>CIImage *image = [CIImage imageWithCGImage:self.CGImage];
  CIFilter *filter = [CIFilter filterWithName:@"CIColorControls"];
  [filter setValue:image forKey:kCIInputImageKey];
  [filter setValue:[NSNumber numberWithFloat:saturation] forKey:@"inputSaturation"];
  return [UIImage imageWithCIImage:filter.outputImage];
  </code></pre>
  
  <p>My only guess is that Core Animation doesn't play well with Core Image.  The <a href="http://developer.apple.com/library/ios/DOCUMENTATION/GraphicsImaging/Reference/QuartzCoreFramework/Classes/CIImage_Class/Reference/Reference.html" rel="nofollow">Apple docs</a> say this about <code>CIImage</code>:</p>
  
  <blockquote>
    <p>Although a CIImage object has image data associated with it, it is not an image. You can think of a CIImage object as an image “recipe.” A CIImage object has all the information necessary to produce an image, but Core Image doesn’t actually render an image until it is told to do so. This “lazy evaluation” method allows Core Image to operate as efficiently as possible.</p>
  </blockquote>
  
  <p>Doing this evaluation at the last minute while animating might be tricky.</p>