question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OutOfMemoryError with GenericDraweeHierarchy

See original GitHub issue
java.lang.OutOfMemoryError:
android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:594)
android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:429)
android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840)
android.content.res.Resources.loadDrawable(Resources.java:2174)
android.content.res.Resources.getDrawable(Resources.java:716)
com.facebook.drawee.generic.GenericDraweeHierarchyInflater.getDrawable(GenericDraweeHierarchyInflater.java:227)
com.facebook.drawee.generic.GenericDraweeHierarchyInflater.updateBuilder(GenericDraweeHierarchyInflater.java:116)
com.facebook.drawee.generic.GenericDraweeHierarchyInflater.inflateBuilder(GenericDraweeHierarchyInflater.java:77)
com.facebook.drawee.view.GenericDraweeView.inflateHierarchy(GenericDraweeView.java:58)
com.facebook.drawee.view.GenericDraweeView.<init>(GenericDraweeView.java:43)
com.facebook.drawee.view.SimpleDraweeView.<init>(SimpleDraweeView.java:62)

I use GenericDraweeHierarchy to change PlaceholderImage with different color image

    /**
     * 为SimpleDraweeView设置Controller
     *
     * @param simpleDraweeView 加载图片的simpleDraweeView
     * @param gifView          表示图片是否是gif的imageview
     * @param infos            图片数据
     * @param position         选中图片的位置
     * @param context          Context
     */
    private void setController(SimpleDraweeView simpleDraweeView, ImageView gifView, final List<AttachesEntity> infos, final int position, final Context context) {
        String filepath = "" + infos.get(position).getUrl();
        GenericDraweeHierarchy hierarchy = simpleDraweeView.getHierarchy();
        if (random == null) {
            random = new Random();
        }
        Drawable drawable = StaticUtil.ChangeColorsDrawable[random.nextInt(7)];
        hierarchy.setPlaceholderImage(drawable);
        hierarchy.setFailureImage(drawable);
        ImageRequest request = ImageRequestBuilder.newBuilderWithSource(getUriWithPath(filepath))
                .setResizeOptions(new ResizeOptions(500, 500))
                .build();
        PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder()
                .setOldController(simpleDraweeView.getController())
                .setImageRequest(request)
                .build();
        simpleDraweeView.setController(controller);
        simpleDraweeView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startViewpagerActivity(infos, position, context);
            }
        });
    }

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
oprisnikcommented, Jul 17, 2017

Looks like largeHeap fixed this issue.

0reactions
hljstardustcommented, Feb 10, 2021

i also think so

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fresco : Display Wrong Image in listitems - android
I am using fersco library for loading local image. Initially i am displaying placeholder image in each item.Once the image is downloaded then...
Read more >
GenericDraweeHierarchy - Fresco API
A SettableDraweeHierarchy that displays placeholder image until the actual image is set. If provided, failure image will be used in case of failure...
Read more >
My Experience using Fresco - Medium
Massive improvement in OutOfMemory in Android 4.x and below ... You will have to create a GenericDraweeHierarchy to set things like placeholder.
Read more >
Android – Images not loading in Fresco – iTecNote
GenericDraweeHierarchy@a0fa544 12-22 15:52:47.435 32462 32462 V ... Android – Strange OutOfMemory issue while loading an image to a Bitmap object.
Read more >
Files.java example - Javatips.net
GenericDraweeHierarchy.java · GenericDraweeHierarchyBuilder.java ... MAX_VALUE) { throw new OutOfMemoryError("file is too large to fit in a byte array: " + ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found