AFNetworking/AFNetworking — pull request #1070 by mattt (2013-06-17 05:46:20+00:00)
Title: Improved Image Loading Performance By Inflating Image In Background

Following a hot tip from a couple developers at WWDC, I attempted to narrow the performance gap for image loading.

Currently, there is a noticeable stutter on some devices when settings images, because compressed image formats (such as PNG) are decompressed and set on the main thread in the callback.

In preliminary testing, this patch improves performance significantly—removing the aforementioned stutter completely. It does so in a couple of ways:

- Creating an inflated / decompressed image in the `responseImage` getter, which is normally accessed in the background during the `completionBlock`
- Staying close to the metal when allocating `CGImageRef` (i.e. using `CGImageCreateWithPNGDataProvider` or `CGImageCreateWithJPEGDataProvider` depending on the response headers of the operation).

I'm really excited by the initial success of this, but want to make sure I got everything right before merging this in (my Quartz-jitsu is a little rusty).

Any feedback? /cc @steipete @blakewatters @0xced