fresco icon indicating copy to clipboard operation
fresco copied to clipboard

W/unknown:CloseableReference﹕Finalized without closing in logcat

Open lam-bun opened this issue 11 years ago • 8 comments

hi fresco, I have got logcat like this

W/unknown:CloseableReference﹕ Finalized without closing: 263cc769 30d915ee (type = NativePooledByteBuffer) W/unknown:CloseableReference﹕ Finalized without closing: 30c57b20 a595cd9 (type = NativePooledByteBuffer) W/unknown:CloseableReference﹕ Finalized without closing: b2cd69e 7afb57f (type = NativePooledByteBuffer) W/unknown:CloseableReference﹕ Finalized without closing: 2e57294c 679ed95 (type = NativePooledByteBuffer)

am I forget to do something?

lam-bun avatar May 26 '15 08:05 lam-bun

You are probably not using closing the CloseableReference properly. Please refer to http://frescolib.org/docs/closeable-references.html#_ for the proper usage.

TarangS avatar May 26 '15 15:05 TarangS

I edit my code like this, but still show me that logical, can anybody tell me how to fix it? @TarangS @daaku @natacado @benhiller @tageorgiou

ImageRequest imageRequest = ImageRequestBuilder.newBuilderWithSource(uri) .setResizeOptions(new ResizeOptions(width, height)) .build(); ImagePipeline imagePipeline = Fresco.getImagePipeline(); final DataSource<CloseableReference> dataSource = imagePipeline.fetchImageFromBitmapCache(imageRequest, simpleDraweeView); PipelineDraweeController controller = (PipelineDraweeController) Fresco.newDraweeControllerBuilder() .setImageRequest(imageRequest) .setAutoPlayAnimations(true) .setOldController(simpleDraweeView.getController()) .setControllerListener(new BaseControllerListener() { @Override public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) { CloseableReference imageReference = dataSource.getResult(); try { if (imageReference != null) { CloseableImage image = imageReference.get(); if (image != null && image instanceof CloseableStaticBitmap) { CloseableStaticBitmap closeableStaticBitmap = (CloseableStaticBitmap) image; Bitmap bitmap = closeableStaticBitmap.getUnderlyingBitmap(); if (bitmap != null) { simpleDraweeView.setImageBitmap(bitmap); } } } } finally { dataSource.close(); CloseableReference.closeSafely(imageReference); } } }) .build(); simpleDraweeView.setController(controller);

lam-bun avatar May 27 '15 06:05 lam-bun

You dont need to use the Imagepipeline explicitly. SimpleDraweeView does it for you. Also if you use the SimpleDraweeView then you dont have to worry about closing the references as DraweeHierarchy in the SimpleDraweeView handles that.

In your code snippet, a ControllerListener is not required So effectively you only need to do:


Uri uri; DraweeController controller = Fresco.newDraweeControllerBuilder() .setUri(uri) .setAutoPlayAnimations(true) . // other setters .build(); mSimpleDraweeView.setController(controller);


For Understanding Drawee better read these, however you only need anything other than the above snippet for ur purpose. http://frescolib.org/docs/using-drawees-xml.html#_ http://frescolib.org/docs/using-drawees-code.html#_ http://frescolib.org/docs/animations.html#_ http://frescolib.org/docs/using-controllerbuilder.html#_

TarangS avatar May 27 '15 09:05 TarangS

I am using SimpleDraweeView and if the code calls draweeView.setImageUri(Uri) multiple times, I get errors like this one

11-15 14:57:10.304  24258-24267/my.application W/unknown:CloseableReference﹕ Finalized without closing: 41fa4a40 420fa518 (type = CloseableStaticBitmap)

I'm reusing the drawee view in a recycler view, so this should be normal usage.

Zhuinden avatar Nov 15 '15 13:11 Zhuinden

@Zhuinden confirmed, exactly the same behavior on a Galaxy Tab A (SM-T550), 5.0.2 and Nexus 5 2013 (6.0.1). Would be nice to know the reason.

vad-zuev avatar Dec 28 '15 10:12 vad-zuev

I am code : Uri uri = Uri.fromFile(new File(path)); ImageRequestBuilder imageRequestBuilder = ImageRequestBuilder.newBuilderWithSource(uri) .setAutoRotateEnabled(true) .setResizeOptions(new ResizeOptions(mItemWidth, mItemWidth)); DraweeController controller = Fresco.newDraweeControllerBuilder() .setImageRequest(imageRequestBuilder.build()) .setOldController(holder.mImageView.getController()) .build(); holder.mImageView.setController(controller); has the same bug in gridview

QiuSean avatar Feb 19 '16 03:02 QiuSean

is it fixed? i suffer from same bug at ver.0.12.0

leeyc09 avatar Aug 03 '16 02:08 leeyc09

The original cause here should be fixed. However, this also happens if you re-initialize Fresco (call Fresco.initialize(...)) more than once. I guess you're doing that according to your other issue (#1397).

oprisnik avatar Aug 03 '16 11:08 oprisnik