4

I've been developing Android apps for six years now, and using a simple "home-grown" image caching library for just as long. I recently started using a component that depends Picasso, and decided that it might be time to make the switch to a general library, rather than keep my old solution written many years ago.

Most of my images are local ones stored in the drawable folders, with modest dimensions (100-200 px a side).

However, I'm seeing a noticeable performance penalty when loading images with Picasso into the ImageViews of my layout. There is a visible "blip" between the layout being rendered and the bitmaps becoming visible (this blip disappears once the images are cached). With my HG library, which is basically just BitmapFactory.decodeResource with some cache coding around a sparse array of SoftReferences (this is old, as I said), loading for the same view is seamless and appears to be instantaneous.

Obviously, there are big differences in how I normally load the images and the asynch loading in Picasso, but is this really the expected behavior? This would seem to make Picasso ill-suited for the loading of local drawables into the UI, which I find rather surprising. I load images with the very simple:

Picasso.with(getActivity())
    .load(getPixId)
    .into(imageView);

Is there any way to tune this for better performance? What may I be overlooking?

Michael A.
  • 4,163
  • 3
  • 28
  • 47

2 Answers2

12

You can disable fade animation to improve load speed

Picasso.with(getActivity()).load(getPixId).noFade().into(imageView);

If you load a lot of image, try to use resize for better memory performance:

Picasso.with(getActivity()).load(getPixId).resize('widthImageView', 'heightImageView').noFade().into(imageView);

If you use a listview, you can stop load image onScroll for improve performance:

Picasso.with(getActivity()).load(getPixId).resize('widthImageView', 'heightImageView').noFade().tag('a group tag').into(imageView);

@Override public void onScrollStateChanged(AbsListView view, int scrollState) { final Picasso picasso = Picasso.with(context); if (scrollState == SCROLL_STATE_IDLE || scrollState == SCROLL_STATE_TOUCH_SCROLL) { picasso.resumeTag(context); } else { picasso.pauseTag(context); } }

For other solution you can see this post Picasso Github

If none of these solutions is for you, try a different library. Here you can find the most famous image libraries with their pros and cons Stackoverflow Answer

Community
  • 1
  • 1
  • 1
    Thanks for the response. Unfortunately, this doesn't solve the problem - still a noticeable lag in the loading. – Michael A. May 02 '16 at 18:51
  • You're welcome. Have you test to load only 1 image? You see this lag? – Francesco Bonnì May 02 '16 at 19:02
  • Haven't tested with only one image (6-7 images), but there isn't any situation anyway for me where it would be useful to just have one anyway. Also not using a ListView, just images placed in a plain LinearLayout. Resizing didn't help, unfortunately. Have tried using Glide also, now, and I see the same issue there, so I'm thinking this is simply a consequence of the asynch loading approach. – Michael A. May 03 '16 at 21:44
  • what is 'a group tag', where do I use this? – Noor Hossain Mar 31 '20 at 14:16
1

This is a late answer, but I was curious about the same question. Here's what I found from Jake himself. Hope this helps. LINK enter image description here

seekingStillness
  • 4,833
  • 5
  • 38
  • 68