9
votes

We are using Picasso to load all images in our app, from small avatars to large full screen images and we are getting 1 of these errors for every 10 daily active users. The Picasso cache is filling up, but our understanding that it should maintain itself.

Our logs indicate these errors are occurring most often when loading the large full screen images (1080x1920) and large avatars (720x720) on high end devices (Galaxy S4), but occasionally on small avatars (135x135).

com.couchsurfing.mobile.data.PicassoException: Error while loading image with Picasso
       at com.couchsurfing.mobile.data.DataModule$1.onImageLoadFailed(DataModule.java:158)
       at com.squareup.picasso.Picasso.complete(Picasso.java:374)
       at com.squareup.picasso.Picasso$1.handleMessage(Picasso.java:97)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:137)
       at android.app.ActivityThread.main(ActivityThread.java:5419)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:525)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
       at dalvik.system.NativeStart.main(NativeStart.java)
Caused by: java.lang.RuntimeException: ===============BEGIN PICASSO STATS ===============
Memory Cache Stats
  Max Cache Size: 19173961
  Cache Size: 17988408
  Cache % Full: 94
  Cache Hits: 228
  Cache Misses: 244
Network Stats
  Download Count: 131
  Total Download Size: 3375735
  Average Download Size: 25768
Bitmap Stats
  Total Bitmaps Decoded: 206
  Total Bitmap Size: 144932008
  Total Transformed Bitmaps: 160
  Total Transformed Bitmap Size: 40233240
  Average Bitmap Size: 703553
  Average Transformed Bitmap Size: 195306
===============END PICASSO STATS ===============

       at com.squareup.picasso.BitmapHunter.run(BitmapHunter.java:117)
       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
       at java.util.concurrent.FutureTask.run(FutureTask.java:234)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
       at java.lang.Thread.run(Thread.java:841)
       at com.squareup.picasso.Utils$PicassoThread.run(Utils.java:394)
Caused by: java.lang.OutOfMemoryError
       at android.graphics.BitmapFactory.nativeDecodeStream(BitmapFactory.java)
       at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:623)
       at com.squareup.picasso.NetworkBitmapHunter.decodeStream(NetworkBitmapHunter.java:118)
       at com.squareup.picasso.NetworkBitmapHunter.decode(NetworkBitmapHunter.java:72)
       at com.squareup.picasso.BitmapHunter.hunt(BitmapHunter.java:144)
       at com.squareup.picasso.BitmapHunter.run(BitmapHunter.java:101)
       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
       at java.util.concurrent.FutureTask.run(FutureTask.java:234)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
       at java.lang.Thread.run(Thread.java:841)
       at com.squareup.picasso.Utils$PicassoThread.run(Utils.java:394)
2
Are you using this in an adapter? - Michael
We are getting this error throughout the app. In ListAdapters PagerAdapters and in normal layouts. - nathanielwolf
Are you using your own singleton instance of Picasso across the app? - Michael
Can you share your implementation of Picasso? - Lord Sidious
I also have same issue can anyone help? Thank you in advance. - rajlaxmi_jagdale

2 Answers

1
votes

I've had same issue and one of the temporary workarounds is

<application
    ...
    android:largeHeap="true">

For now, I haven't found another solution (maybe I've searched not enough). But many people have OOM with Picasso.

0
votes

Are you calling fit() when loading images? I suspect this was my issue, I assumed images down sampled themselves with Picasso but you still need to tell it do so.