Hi all,

I'm trying to optimize our application for smooth scrolling, but it looks like 
I'm at the end and I don't know what else I can try. Simple description of what 
I did so far ... Screen looks like ...

 - background image, which doesn't scroll and is below UIScrollView
 - UIScrollView, which is transparent and contains 16 rectangles with semi 
transparent background
 - each rectangle contains three UILabels and two images - one is UIImageView 
and is static, same for all rectangles and one, which is displayed in UIView 
and is downloaded remotely or from local cache

... here's the screenshot of the app screen - http://cl.ly/016f76b7276b1f752189 
- so you can have better idea of what's going on.

Avatar picture, which causes the problem, is quite small (square is 40x40 
pixels only) and remotely downloaded image is 60x60 or something like this. 
It's quite small.

User can scroll horizontally only and it's optimized in this way ...

 - all rectangles are reused (something like UITableView & cells), so, when it 
leaves screen, it's reused immediately for new rectangles
 - when reused, only three UILabels are modified, avatar picture is nilled and 
downloaded remotely or from cache (concurrent NSOperation)
 - reusing means that I do not remove them from UIScrollView, but I just modify 
rectangles frame and I also cancel NSOperation for image preparation if in 
progress

... it's pretty fast until I start updating avatar pictures. It's erratic and 
sometimes quite slow. So, I wrote ImageProvider, which does load images in this 
way ...

 - each image request is concurrent operation (main method is dettached in 
separate thread)
 - main method does this
   + checks local cache and if image does exist, image is not remotely 
downloaded
   + if image doesn't exist in local cache, image is remotely downloaded via 
NSURLConnection (asynchronously in dettached thread)
   + when image is downloaded or loaded from cached, image is decompressed 
(still separate thread)
   + and when image is prepared, avatar picture is updated via delegate

... and avatar image update is done in this way ...

 - it's simple UIView
 - CGImage is assigned to CALayer of this UIView
 - everything is done in non blocking manner, ie. I read somewhere that I can 
update CALayer directly from different thread and it does work (I have to check 
this, just read it somewhere)

... before this optimization, scrolling was erratic and I did use UIImageView 
for avatar too (later replaced with UIView & CALayer).

When my operation queue has maximum concurrent operations set to 1, it's fast 
as hell and there's no sign of any slowness. But when I increase number of 
concurrent operations to 4 for example, it's erratic as it was before. I did 
spent two days with Shark, etc. and I did found that the delay is caused by 
avatar image updates (among other things I did already fix).

My question is - what is the best way for updating avatar pictures in this case 
in very fast way, so, UIScrollView scrolling will be still smooth even if I 
update 2, 3, 4, 5, ... avatars "at once"?

Best regards,
Robert_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to