Search code examples
iosiphoneopengl-esgpuimage

Track progress of GPUImage processImage (iOS)


I am applying GPUImageKuwaharaFilter filter on a still image. It is a very expensive operation and processImage takes quite some time to complete. I would like to show the user progress on how much of processImage is remaining. Is there a way I can accomplish that?

Since an approximate progress does the job, I tried using a NSTimer and incrementing progress bar at regular intervals. However, for some reason NSTimer is getting held up once I start processImage. Is there a way I can keep the UI and NSTimer free while processImage is running in the background?


Solution

  • Unfortunately, there isn't a great way to measure the progress of a single shader. Applying a shader to a textured quad is effectively an atomic operation which either succeeds or fails (if the shader takes longer than the OpenGL ES driver watchdog allows). There really isn't a concept of progression through the rendering of an image.

    What you might be encountering in regards to the timer is that with an incredibly intensive shader like this one, it effectively jams up the entire system until it's done. It at least causes significant hitches in the interface, because it needs to finish its rendering before the GPU can do any other kind of display updates.

    I don't know a great way around this, short of improving the shader itself. That particular shader is slow even on desktop GPUs, and is horrible on pre-iPhone 5S devices. There is a rough attempt at optimizing it in a fixed-radius version of this operation, but even there I believe there's room for improvement.