title: Using CoreImage on the GPU and UIActivityIndicator
body: <h3>Background</h3>
  <p>I'm developing an iOS photo editing app extension.
  Now that I've got my Core Image code working as expected, I'm turning my attention to performance improvements (it isn't fast, at least on the Simulator).</p>
  <p>In order to keep the app responsive while my extension applies its filters (both the &quot;preview&quot; while editing and the final result when committing the edits), I'm rendering on a background queue.</p>
  <p>At the same time, I am <strong>presenting modally</strong> a custom view controller that displays an <strong>activity indicator view</strong>, to inform the user that a lengthy process is in progress</p>
  <p><a href="https://i.stack.imgur.com/Abc7q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Abc7q.png" alt="enter image description here" /></a></p>
  <p><em>(this only for the preview render; for the final commit, Photos.app takes over and displays its own activity indicator view)</em></p>
  <h3>The Problem</h3>
  <p>Reading through the Core Image Programming Guide, in the section &quot;<a href="https://developer.apple.com/library/archive/documentation/GraphicsImaging/Conceptual/CoreImaging/ci_performance/ci_performance.html#//apple_ref/doc/uid/TP30001185-CH10-SW2" rel="nofollow noreferrer">Getting the Best Performance</a>&quot;, I came across this piece of advice:</p>
  <blockquote>
  <p>Avoid Core Animation animations while rendering CIImage objects with a GPU context.</p>
  <p>If you need to use both simultaneously, you can set up both to use the CPU.</p>
  </blockquote>
  <p>This got me thinking; Doesn't UIKit, (and <code>UIActivityIndicatorView</code> in particular) use Core Animation?</p>
  <p>Regarding the final render, I am considering using the CPU anyway: reportedly it seems to produce higher quality results, and the GPU has size constraints that might be easily overwhelmed by the full-size of the original images typically found in the Photos library.</p>
  <p><strong>But for the screen-size, preview render I would prefer to use the GPU.</strong></p>
  <p>I can begin rendering immediately <em>after</em> the modal view controller has been presented (and avoid overlapping the presentation transition), but the activity indicator needs to animate while the GPU render is in progress.</p>
  <p><strong>How Can I Provide Animated Feedback While Applying CoreImage Filters to an Image on the GPU?</strong></p>
  <hr />
  <p>Similar (but <em>not</em> duplicate, if I'm not wrong) question: <a href="https://stackoverflow.com/q/34867883/433373">How do you run Core Animation and Core Image together on the CPU?</a></p>