error:trying to use a recycled bitmap
See original GitHub issueDataSource<CloseableReference<CloseableImage>> dataSource1 =
imagePipeline.fetchImageFromBitmapCache(imageRequest, CallerThreadExecutor.getInstance());
try {
CloseableReference<CloseableImage> imageReference = dataSource1.getResult().clone();
if (imageReference != null) {
try {
CloseableBitmap image = (CloseableBitmap)imageReference.get();
// do something with the image
Bitmap loadedImage = image.getUnderlyingBitmap();
if (loadedImage != null) {
doSomethingWithBitmap(loadedImage);
} else {
Utils.showToast("error");
}
} finally {
CloseableReference.closeSafely(imageReference);
}
}
} finally {
dataSource1.close();
}
this code run first time was right,when I run this code twice or third time, the app report error:trying to use a recycled bitmap
第一次跑这段代码是正确的,图片可以正确的显示出来。然后在这个页面上再一次调用这个方法,图片地址也是一样的,就显示bitmap被回收了。
我想应该是我的写法有问题,请问该怎么写才能让bitmap不回收呢?
类似的问题 我也见到不少了,freso的大神们,你们为啥不详细得给一套解决方案呢?
Issue Analytics
- State:
- Created 8 years ago
- Comments:11 (2 by maintainers)
Top Results From Across the Web
Canvas: trying to use a recycled bitmap android.graphics ...
In my case error was caused because I changed visibility from gone to visible (or vice versa) of an element ...
Read more >trying to use a recycled bitmap · Issue #504 · coil-kt/coil - GitHub
This is a very occasional error, how can I troubleshoot java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics ...
Read more >What is "trying to use a recycled bitmap"? - Android Community
What is "trying to use a recycled bitmap"? I found a file in my File Manager + -- CameraSumSungAS>error. crash-2019_08_20_09_29_41.txt.
Read more >Managing Bitmap Memory - Android Developers
If you call recycle() and later attempt to draw the bitmap, you will get the error: "Canvas: trying to use a recycled bitmap"...
Read more >RuntimeException (Canvas: trying to use a recycled bitmap) in ...
:/ The only thing that comes to mind for this error is 3235488, specifically removing the Bitmap copying in getBitmapFromView(). I can put...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had the similar issue.
because i had recycle bitmap by my self
我也遇到这个问题,也是因为在使用bitmap过程中我自己的代码回收了bitmap,解决办法就是除了用于显示在view里,不要对bitmap做任何处理 希望能帮到你们
好吧,仔细梳理了一遍代码,发现最终是我自己手动recycle了一次bitmap 闹了个乌龙,不好意思。 现在这个问题解决了,多谢。@aagnes