Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.RuntimeException: Canvas: trying to use a recycled bitmap-BasePostprocessor #850

Closed
HildaChen opened this issue Dec 21, 2015 · 1 comment
Labels

Comments

@HildaChen
Copy link

12-21 11:01:14.045: E/AndroidRuntime(6819): java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@41801038
12-21 11:01:14.045: E/AndroidRuntime(6819):     at android.graphics.Canvas.throwIfCannotDraw(Canvas.java:1084)
12-21 11:01:14.045: E/AndroidRuntime(6819):     at android.view.GLES20Canvas.drawBitmap(GLES20Canvas.java:844)
12-21 11:01:14.045: E/AndroidRuntime(6819):     at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:490)
12-21 11:01:14.045: E/AndroidRuntime(6819):     at android.widget.ImageView.onDraw(ImageView.java:1037)
12-21 11:01:14.045: E/AndroidRuntime(6819):     at android.view.View.draw(View.java:14465)
12-21 11:01:14.045: E/AndroidRuntime(6819):     at android.view.View.getDisplayList(View.java:13362)
12-21 11:01:14.045: E/AndroidRuntime(6819):     at android.view.View.getDisplayList(View.java:13404)
12-21 11:01:14.045: E/AndroidRuntime(6819):     at android.view.View.draw(View.java:14182)
12-21 11:01:14.045: E/AndroidRuntime(6819):     at android.view.ViewGroup.drawChild(ViewGroup.java:3103)
12-21 11:01:14.045: E/AndroidRuntime(6819):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2940)
12-21 11:01:14.045: E/AndroidRuntime(6819):     at android.widget.AbsListView.dispatchDraw(AbsListView.java:2458)

I build a new class and make it extends BasePostprocessor, I do nothing in it. But when it ran, the sample throw the above exception; I just use imagepipeline to download the image, don't use the simpledraweeview.

com.facebook.imagepipeline.request.ImageRequestBuilder requestBuilder = com.facebook.imagepipeline.request.ImageRequestBuilder
                .newBuilderWithSource(uri);

        if (imageRequest.getTargetWidth() > 0 && imageRequest.getTargetHeight() > 0) {
            requestBuilder.setResizeOptions(new com.facebook.imagepipeline.common.ResizeOptions(imageRequest
                    .getTargetWidth(), imageRequest.getTargetHeight()));
        }

        requestBuilder.setAutoRotateEnabled(true);
        requestBuilder.setPostprocessor(new FPostProcessor(getImageConfig()));


public class FPostProcessor extends BasePostprocessor{

    private FImageConfig mImageConfig;

    public FPostProcessor(FImageConfig imageConfig){
        mImageConfig = imageConfig;
    }
    /*
    @Override
    public CloseableReference<Bitmap> process(Bitmap sourceBitmap, PlatformBitmapFactory bitmapFactory) {
        return super.process(sourceBitmap, bitmapFactory);
    }*/
    }
@tyronen tyronen added the bug label Jan 4, 2016
@oprisnik
Copy link
Contributor

I suppose you're not handling the lifecycle of the underlying bitmap correctly. You have to keep the CloseableReference around until the image is not needed any more, see http://frescolib.org/docs/closeable-references.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants