Weird behavior with some slider filters in iOS7
I have about 30 of the GPU image filters in my app which enable the user to apply a filter to a still photo via slider. All of them were working fine on iOS6, however when I recently installed iOS7 Beta 6, I began to have some problems with a couple of the filters. Sketch and Sobel Edge don't work, when you try to apply them, they turn the screen white and black respectively. Smooth Toon, Canny Edge, and Gaussian Blur all seem to go extremely slow (the slider updates very seldomly as you move it) and sometimes crash the app when applied with other filters. Has anyone else experienced problems like this with iOS7?
This is a known bug with still photos and two-pass filters. It's been present for a while in a more subtle fashion, but iOS 7 somehow amplifies the effect. I've been looking into this for a while, but I can't figure out what's causing it. It's something internal to the GPUImageTwoPassFilter, if you want to start investigating on your own.
Thanks for the response, will take a look at it this week.
Grab the latest code from the repository and see if you're still experiencing this. When I tested this now after the last series of pull requests, and a little tinkering of my own, I don't seem to see these artifacts anymore on my iOS 7 beta 6 device.
In particular, look at the SimpleImageFilter example application, which uses the Sobel edge detection filter. A month or so ago, that was returning black images on iOS 7. When I tested this today, the images were produced correctly.
Thanks Brad! That fixed the issue with Sketch and SobelEdgeDetection. I'm noticing two other issues with iOS7, don't know if I should open a separate issue for them:
-
On the blur related filters I'm using in my app (SmoothToon, CannyEdgeDetection, and GaussianBlur), when I go to apply these filters on a still image, the slider doesn't update it's UI properly (it appears like the slider is lagging and only updates seldomly), yet the filter applies to the picture at the normal rate. When I moved the CannyEdgeDetection around enough, it crashed the app.
-
It appears a lot or most of the filters are applying the filter to the entire screen, and not just the image. I have a black view which takes up the entire screen and the image is attached to it. For instance, when I apply Brightness, the black turns bright, or if I do swirl or pinch, the Image gets swirled / pinched outside of its bounds. Sketch also turns the black screen white. I think this is pretty much happening with every filter (though some don't have any effect on the black background). This wasn't happening on iOS6 with the same code.
Actually, I installed the GM version iOS7 today and both of the above problems went away. Not sure if these problems were occurring because of the last version of iOS7 had a bug, or because I was running an iOS6 style app on iOS7. Either way, happy to report they no longer exist and the filters seem smoother than ever on iOS7!
Hi Brad, This issue seems to still be present and is killing our app under iOS7. The performance difference between 6 and 7 is really pronounced. Even filters like brightness become extremely choppy when using a slider to change values. Is there anything that can be done? Once again, thanks for such a great framework - hopefully we can get this sorted!
Apologies - it appears it's not GPUImage that's slow on iOS7, it's something to do with UIImageView rendering much slower on iOS7.
Yeah seems to be an iOS7 issue. Just curious, but did you hear that from Apple? Did they mention it being a bug and it being fixed maybe in 7.0.2 or in future?
Kissfro - not from Apple. Just ran some timers on different tasks. GPUImage is performing well, it was the rendering of the resulting image into a UIImageView that was killing things for us. Offloading the imageview rendering using GCD did the trick. Still not perfect but at least the slider/rendering is a little smoother.
Why are you rendering to a UIImageView? Going directly to a GPUImageView is much, much faster due to the fact that it avoids having to convert to and from a Core Graphics representation. Everything stays on the GPU that way.
Hi Brad - the image is not necessarily the result of a GPUImage operation. It can be a standard image loaded off disk too, hence a standard UIImageView.
It's still going to be a lot slower to extract a UIImage from the framework and display it in a UIImageView than to feed the preview result directly to a GPUImageView. You might want to think about either splitting the preview off from the place where you display images loaded from disk, or to use a GPUImageView and then swap in GPUImagePicture instances for the UIImages you otherwise would have loaded from disk and placed in a UIImageView.
Thanks Brad - for sure. It's something I've been wanting to do for a while but it's a fair amount of refactoring in this project and there's always a TODO list a mile long. One day!