Added "Motivation" chapter
This commit is contained in:
parent
891b957ba8
commit
57b0dae146
13
README.md
13
README.md
|
@ -9,6 +9,19 @@ It provides:
|
|||
- Asynchronous image downloader
|
||||
- Asynchronous memory + disk image caching with automatic cache expiration handling
|
||||
|
||||
Motivation
|
||||
----------
|
||||
|
||||
As a dummy Objective-C developer working on my first iPhone application for my company (Dailymotion), I've been very frustrated by the lack of support in the Cocoa Touch framework for UITableView with remote images. After some googling, I found lot of forums and blogs coming with their solution, most of the time based on asynchronous usage have NSURLConnection, but none provides a simple library doing the work for you.
|
||||
|
||||
Actually there is one in the famous Three20 framework by Joe Hewitt, but it's yet massive and undocumented piece of code. You can't import just the the libraries you want without taking the whole framework (damn #import "TTGlobal.h"). Anyway, the Three20 implementation is based on NSURLConnection, and I don't find this solution to be performant enough, keep reading to find out why.
|
||||
|
||||
As many others, I implemented the NSURLConnection solution exposed everywhere on the net and it worked. But when I compared my application with its direct competitor - the built-in Youtube application - I was very unhappy with the loading speed of the images. After some network sniffing, I found that every HTTP request for my images was 10 times slower than Youtube's ones... On my own network, Youtube was 10 time faster than my own servers... WTF??
|
||||
|
||||
In fact, my server was well but a lot of latency was added to the requests, certainly because my application wasn't responsive enough to handle the requests at full speed. At this moment, I understood something important, asynchronous NSURLConnections are tied to the main runloop (I guess). It's certainly based on epoll, when a single thread can handle a huge number of simultaneous connections. It works well while nothing blocks in the loop, but in this loop, there is also the events handling. A simple test to recognize an application using NSURLConnection to load there remote images is to scroll the UITableView with your finger to disclose an unloaded image, and to keep your finger pressed on the screen. If the image doesn't load until you release you finger, the application is certainly using NSURLConnection (try with the Facebook app for instance). I'm not completely clear about the reason of this blocking, I thought the iPhone was running a dedicated run-loop for connections, but the fact is, NSURLConnection is affected by the application events and/or UI handling (or something else I'm not aware of).
|
||||
|
||||
Thus I explored another path and found this marvelous NSOperation class to handle concurrency with love. I ran some quick tests with this tool and I instantly got enhanced responsiveness of the image loading in my UITableView by... a lot. I thought this technic could benefits to a lot of other applications, thus I open-sourced its implementation and there it is!
|
||||
|
||||
How To Use It
|
||||
-------------
|
||||
|
||||
|
|
Loading…
Reference in New Issue