zjupure / GlideWebpDecoder

A Glide WebpDecoder Intergration Library for decoding and displaying webp images
Apache License 2.0
740 stars 91 forks source link

WebpDecoder 多线程问题 #97

Open Linda0509 opened 1 year ago

Linda0509 commented 1 year ago

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

zjupure commented 1 year ago

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