Fresco: [Report from Firebase ] BucketsBitmapPool.java line 54.

Created on 12 Feb 2020  路  8Comments  路  Source: facebook/fresco

I can't reproduce this crash, but this is a report from Firebase.

Devices:

  1. Galaxy J3(2016) (20% )
  2. Vivo Y21 - (Vivo 40%)
  3. Vivo Y55s
  4. Huawei LISZT - (Huawei 40%)

OS: Android 5.1.1 (60%), Android 5.1 (40%)

Fresco Version:
'com.facebook.fresco:fresco:2.0.0'
'com.facebook.fresco:animated-gif:2.0.0'
'com.facebook.fresco:imagepipeline-okhttp3:1.12.1'

Fatal Exception: java.lang.OutOfMemoryError: Failed to allocate a 3467676 byte allocation with 2657936 free bytes and 2MB until OOM
       at dalvik.system.VMRuntime.newNonMovableArray(VMRuntime.java)
       at android.graphics.Bitmap.nativeCreate(Bitmap.java)
       at android.graphics.Bitmap.createBitmap(Bitmap.java:842)
       at android.graphics.Bitmap.createBitmap(Bitmap.java:812)
       at android.graphics.Bitmap.createBitmap(Bitmap.java:779)
       at com.facebook.imagepipeline.memory.BucketsBitmapPool.alloc(BucketsBitmapPool.java:54)
       at com.facebook.imagepipeline.memory.BucketsBitmapPool.alloc(BucketsBitmapPool.java:29)
       at com.facebook.imagepipeline.memory.BasePool.get(BasePool.java:266)
       at com.facebook.imagepipeline.platform.DefaultDecoder.decodeFromStream(DefaultDecoder.java:217)
       at com.facebook.imagepipeline.platform.DefaultDecoder.decodeJPEGFromEncodedImageWithColorSpace(DefaultDecoder.java:155)
       at com.facebook.imagepipeline.decoder.DefaultImageDecoder.decodeJpeg(DefaultImageDecoder.java:181)
       at com.facebook.imagepipeline.decoder.DefaultImageDecoder$1.decode(DefaultImageDecoder.java:58)
       at com.facebook.imagepipeline.decoder.DefaultImageDecoder.decode(DefaultImageDecoder.java:121)
       at com.facebook.imagepipeline.producers.DecodeProducer$ProgressiveDecoder.doDecode(DecodeProducer.java:281)
       at com.facebook.imagepipeline.producers.DecodeProducer$ProgressiveDecoder.access$200(DecodeProducer.java:128)
       at com.facebook.imagepipeline.producers.DecodeProducer$ProgressiveDecoder$1.run(DecodeProducer.java:170)
       at com.facebook.imagepipeline.producers.JobScheduler.doJob(JobScheduler.java:202)
       at com.facebook.imagepipeline.producers.JobScheduler.access$000(JobScheduler.java:22)
       at com.facebook.imagepipeline.producers.JobScheduler$1.run(JobScheduler.java:73)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
       at com.facebook.imagepipeline.core.PriorityThreadFactory$1.run(PriorityThreadFactory.java:51)
       at java.lang.Thread.run(Thread.java:831)

Most helpful comment

    ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
            .setDownsampleEnabled(true)
            .setResizeAndRotateEnabledForNetwork(true)
            .setBitmapsConfig(Bitmap.Config.RGB_565)
            .setMemoryTrimmableRegistry(frescoMemoryTrimmableRegistry)
            .build();
    Fresco.initialize(this, config);

Will this help?

Guys I have the same error. Can you tell me please where should I put this config? Which file? Will it help me?

You need to place this in your Application class, also you need to create a new class for the TrimmableRegistry. For example create a new class as -

     public class FrescoMemoryTrimmableRegistry implements MemoryTrimmableRegistry {

          private final List<MemoryTrimmable> trimmables = new LinkedList<>();

          @Override
           public void registerMemoryTrimmable(final MemoryTrimmable trimmable) {
              trimmables.add(trimmable);
           }

         @Override
          public void unregisterMemoryTrimmable(final MemoryTrimmable trimmable) {
             trimmables.remove(trimmable);
          }

         public synchronized void trim(final MemoryTrimType trimType) {
            for (MemoryTrimmable trimmable : trimmables) {
              trimmable.trim(trimType);
         }
     }

Then inside your Application class use it as

    private final FrescoMemoryTrimmableRegistry frescoMemoryTrimmableRegistry = new FrescoMemoryTrimmableRegistry();

After that use

    ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
        .setDownsampleEnabled(true)
        .setResizeAndRotateEnabledForNetwork(true)
        .setBitmapsConfig(Bitmap.Config.RGB_565)
        .setMemoryTrimmableRegistry(frescoMemoryTrimmableRegistry)
        .build();
   Fresco.initialize(this, config);

All 8 comments

Looks like your application is displaying too many images. You only have 2MB left and are trying to display a larger image.

Is there any fix to this. I am also getting this crash

Is there any fix to this. I am also getting this crash

I have to migrate to Glide to resolve these crashes on Firebase. Or you can resize your image base on config.

    ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
            .setDownsampleEnabled(true)
            .setResizeAndRotateEnabledForNetwork(true)
            .setBitmapsConfig(Bitmap.Config.RGB_565)
            .setMemoryTrimmableRegistry(frescoMemoryTrimmableRegistry)
            .build();
    Fresco.initialize(this, config);

Will this help?

That should help yes

    ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
            .setDownsampleEnabled(true)
            .setResizeAndRotateEnabledForNetwork(true)
            .setBitmapsConfig(Bitmap.Config.RGB_565)
            .setMemoryTrimmableRegistry(frescoMemoryTrimmableRegistry)
            .build();
    Fresco.initialize(this, config);

Will this help?

Guys I have the same error. Can you tell me please where should I put this config? Which file? Will it help me?

    ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
            .setDownsampleEnabled(true)
            .setResizeAndRotateEnabledForNetwork(true)
            .setBitmapsConfig(Bitmap.Config.RGB_565)
            .setMemoryTrimmableRegistry(frescoMemoryTrimmableRegistry)
            .build();
    Fresco.initialize(this, config);

Will this help?

Guys I have the same error. Can you tell me please where should I put this config? Which file? Will it help me?

You need to place this in your Application class, also you need to create a new class for the TrimmableRegistry. For example create a new class as -

     public class FrescoMemoryTrimmableRegistry implements MemoryTrimmableRegistry {

          private final List<MemoryTrimmable> trimmables = new LinkedList<>();

          @Override
           public void registerMemoryTrimmable(final MemoryTrimmable trimmable) {
              trimmables.add(trimmable);
           }

         @Override
          public void unregisterMemoryTrimmable(final MemoryTrimmable trimmable) {
             trimmables.remove(trimmable);
          }

         public synchronized void trim(final MemoryTrimType trimType) {
            for (MemoryTrimmable trimmable : trimmables) {
              trimmable.trim(trimType);
         }
     }

Then inside your Application class use it as

    private final FrescoMemoryTrimmableRegistry frescoMemoryTrimmableRegistry = new FrescoMemoryTrimmableRegistry();

After that use

    ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
        .setDownsampleEnabled(true)
        .setResizeAndRotateEnabledForNetwork(true)
        .setBitmapsConfig(Bitmap.Config.RGB_565)
        .setMemoryTrimmableRegistry(frescoMemoryTrimmableRegistry)
        .build();
   Fresco.initialize(this, config);
    ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
            .setDownsampleEnabled(true)
            .setResizeAndRotateEnabledForNetwork(true)
            .setBitmapsConfig(Bitmap.Config.RGB_565)
            .setMemoryTrimmableRegistry(frescoMemoryTrimmableRegistry)
            .build();
    Fresco.initialize(this, config);

Will this help?

Guys I have the same error. Can you tell me please where should I put this config? Which file? Will it help me?

You need to place this in your Application class, also you need to create a new class for the TrimmableRegistry. For example create a new class as -

     public class FrescoMemoryTrimmableRegistry implements MemoryTrimmableRegistry {

          private final List<MemoryTrimmable> trimmables = new LinkedList<>();

          @Override
           public void registerMemoryTrimmable(final MemoryTrimmable trimmable) {
              trimmables.add(trimmable);
           }

         @Override
          public void unregisterMemoryTrimmable(final MemoryTrimmable trimmable) {
             trimmables.remove(trimmable);
          }

         public synchronized void trim(final MemoryTrimType trimType) {
            for (MemoryTrimmable trimmable : trimmables) {
              trimmable.trim(trimType);
         }
     }

Then inside your Application class use it as

    private final FrescoMemoryTrimmableRegistry frescoMemoryTrimmableRegistry = new FrescoMemoryTrimmableRegistry();

After that use

    ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
        .setDownsampleEnabled(true)
        .setResizeAndRotateEnabledForNetwork(true)
        .setBitmapsConfig(Bitmap.Config.RGB_565)
        .setMemoryTrimmableRegistry(frescoMemoryTrimmableRegistry)
        .build();
   Fresco.initialize(this, config);

Could you please describe what does this do?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hanhmh1203 picture hanhmh1203  路  4Comments

satyarths picture satyarths  路  3Comments

rhettor picture rhettor  路  3Comments

bigfreeZhou picture bigfreeZhou  路  4Comments

eresid picture eresid  路  4Comments