-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
Bug with the PostProcessor gives recycled bitmap #259
Comments
Oh, I forgot to say. I'm using the version 1.8.4. |
First of all I DON'T RECOMMEND use do so: .taskExecutor(AsyncTask.THREAD_POOL_EXECUTOR)
.taskExecutorForCachedImages(AsyncTask.THREAD_POOL_EXECUTOR) It can cause UI lags. At second: do you recycle Bitmap ( |
No, I'm not recycling anywhere in my code. For a while, my workaround was Thank you for your recommendation, I'll remove that configuration. |
Show me please exception stacktrace from LogCat. |
Here is the stacktrace:
And here is the processor: public class CapaBitmapProcessor implements BitmapProcessor {
@Inject
private CapaUtils capaUtils;
@Inject
private BitmapUtils bitmapUtils;
@Override
public Bitmap process(Bitmap bitmap) {
// capaUtils.adicionarEfeitos(bitmap, false) creates a LayerDrawable
return bitmapUtils.getBitmap(capaUtils.adicionarEfeitos(bitmap, false));
}
}
// Here is the code used to create the Bitmap
public Bitmap getBitmap(Drawable drawable) {
Bitmap capa = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(capa);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);
return capa;
} |
It's interesting. Can you check if incoming Bitmap is recycled in post-processor? LIke this: @Override
public Bitmap process(Bitmap bitmap) {
if (bitmap.isRecycled()) {
L.w("Incoming bitmap is recycled!");
}
// capaUtils.adicionarEfeitos(bitmap, false) creates a LayerDrawable
return bitmapUtils.getBitmap(capaUtils.adicionarEfeitos(bitmap, false));
} I want to be sure UIL gives you recycled bitmap. |
I changed my code to the following: @Override
public Bitmap process(Bitmap bitmap) {
if (bitmap.isRecycled()) {
Log.e("Soongz", "Bitmap recycled!");
}
return bitmapUtils.getBitmap(capaUtils.adicionarEfeitos(bitmap, false));
} And I see this in log one or more times:
As I mentioned, it occurs in a ListView, when the same image is displayed in another item and I scroll to it. |
We experience the same issue |
Prevent recycling of cached in memory images.
I have a ListView that display some custom views with images and these images can be repeated in the ListView.
What happens is the I want to apply some effects in this images before displaying them. Since the BitmapDisplayer runs in the UI Threads and the effects I'm applying can be slow, I'm putting these effects in a BitmapProcessor that is registered as postProcessor. The problem is that my BitmapProcessor is receiving recycled bitmaps and it gives me a exception when I try to write another bitmap with my effects applied.
I can't put it in the preProcessor because these same images is used with different effects in other activities.
This is my configuration:
In each effect I'm going to apply, I create a new DisplayImageOptions like this:
One of the effects I apply is blurring the image (it happens in an Activity where there's only an image), other is applied with the creation of LayerDrawable and I transform it into a Bitmap in the PostProcessor.
I think I'm reaching the memory cache's limite and it's recycling the images. And, instead of recreating, it's passing the recycled image to my postProcessor.
The text was updated successfully, but these errors were encountered: