GlideWebpDecoder icon indicating copy to clipboard operation
GlideWebpDecoder copied to clipboard

WebpDecoder 多线程问题

Open Linda0509 opened this issue 2 years ago • 1 comments

WebpDecoder.java :

entryRemoved 回调里 mBitmapProvider.release(oldValue); 最终会调用bitmap.recycle()

prepareCanvasWithBlending 方法里 Bitmap bitmap = mFrameBitmapCache.get(index); if (bitmap != null && !bitmap.isRecycled()) { canvas.drawBitmap(bitmap, 0, 0, null); } canvas.drawBitmap 的 bitmap 可能在判断isRecycled后 被另一个线程立刻调用bitmap.recycle() 实际调用drawBitmap时被recycled的bitmap最终将导致崩溃:Error, cannot access an invalid/free'd bitmap here

Linda0509 avatar Aug 05 '22 07:08 Linda0509

getNextFrame()应该是由glide框架在同一个线程里驱动的,mFrameBitmapCache里Bitmap不会被上层业务和glide持有,为什么会出现多线程问题?你这个case是怎么使用的,直接调用了WebpDecoder的API?

zjupure avatar Aug 14 '22 07:08 zjupure