zjupure / GlideWebpDecoder

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

recyclerview展示动图,长列表上下来回滑动,native内存持续上涨 #85

Closed chipssss closed 3 years ago

chipssss commented 3 years ago

你好,使用这个库遇到native内存占用过大的case,场景是recyeclerview长列表动图加载,上下来回滑动。请问是需要手动释放webpDrawable吗? 有没有相关解决方案? Glide加载代码示例:

Glide.with(context)
        .asDrawable()
        .load(src)
        .apply(options)
        .into(object : CustomTarget<Drawable>() {
            override fun onLoadStarted(placeholder: Drawable?) {
                handler.imageLoadCompletion(null, null)
            }
            override fun onLoadCleared(placeholder: Drawable?) {
            }
            override fun onResourceReady(resource: Drawable, transition: Transition<in Drawable>
                (resource as? Animatable)?.start()
                resource.setBounds(0, 0, resource.intrinsicWidth, resource.intrinsicHeight)
                handler.imageLoadCompletion(resource, null) // imageView.setDrawable(resource)
            }
        })
chipssss commented 3 years ago

解决了, 采用CustomTarget加载drawable的方式需要自己回收, 在view.onStateDetach回调中调用Glide.with(context).clear(target)。 感谢楼主的库,使用方便。