BigImageViewPager
BigImageViewPager copied to clipboard
存在多张预览图时,左右滑动的手势有时候会失灵
如下面的视频所示,有时候在中间的图向左或者向右滑无响应,再次向左向右滑即可。
https://user-images.githubusercontent.com/99880210/208514551-bb5e9c1b-569e-4224-a4d5-9bd6765797ca.mp4
应该不是内存的问题,8GB 实体内存 + 5GB 虚拟内存 手机型号: Oppo Reno 8 Pro + 安卓版本: 13 BigImageViewPager, Glide, OkHttp 均使用最新版本
使用代码如下, parent 是 Fragment
val builder = when (val parent = adapterParent) {
is Fragment -> ImagePreview.instance.setContext(parent.requireActivity())
is AppCompatActivity -> ImagePreview.instance.setContext(parent)
else -> throw Exception("Invalid parent")
}
builder.setIndex(index)
.setLoadStrategy(ImagePreview.LoadStrategy.Default)
.setImageInfoList(ImageHelper.processImageInfo(item.imageUrl))
.start()
这个问题很有意思,可以用同款机型测试一下demo有没有同样的问题。我这边也找一下相关机型模拟一下。
Henry Wu @.***>于2022年12月20日 周二04:25写道:
如下面的视频所示,有时候在中间的图向左或者向右滑无响应,再次向左向右滑即可。
https://user-images.githubusercontent.com/99880210/208514551-bb5e9c1b-569e-4224-a4d5-9bd6765797ca.mp4
应该不是内存的问题,8GB 实体内存 + 5GB 虚拟内存 手机型号: Oppo Reno 8 Pro + 安卓版本: 13 BigImageViewPager, Glide, OkHttp 均使用最新版本
使用代码如下, parent 是 Fragment
val builder = when (val parent = adapterParent) {
is Fragment -> ImagePreview.instance.setContext(parent.requireActivity()) is AppCompatActivity -> ImagePreview.instance.setContext(parent) else -> throw Exception("Invalid parent")
}
builder.setIndex(index)
.setLoadStrategy(ImagePreview.LoadStrategy.Default) .setImageInfoList(ImageHelper.processImageInfo(item.imageUrl)) .start()
— Reply to this email directly, view it on GitHub https://github.com/SherlockGougou/BigImageViewPager/issues/182, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEIXE2MF6X4MO4536P6S2D3WODACRANCNFSM6AAAAAATDYAWH4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>
结合coil的issues排查发现,这个应该还是和HEIF有关系,在读取EXIF信息时报错,导致主进程阻塞。 我看能不能HEIF的图片不读取EXIF信息做旋转了。
好像不行,我将库中读取EXIF的地方增加了判断,如果是HEIF时直接return,依旧会报错,依旧会卡顿。暂时先这样,后续发现解决方案时再优化。
可能还是跟这个 issue 有关系?https://github.com/SherlockGougou/BigImageViewPager/issues/184#issue-1506431077
我测试过的,还是会卡顿
我测试过的,还是会卡顿
我去看了一下 Glide 的 issue,这貌似是一个 Glide 的问题?
https://github.com/bumptech/glide/issues/4608
我测试过的,还是会卡顿
我去看了一下 Glide 的 issue,这貌似是一个 Glide 的问题?
嗯,glide中也有读取exif的流程。看这个issue至少一年了,好像也没解决方案。
Henry Wu @.***>于2022年12月22日 周四22:19写道:
bumptech/glide#4608 https://github.com/bumptech/glide/issues/4608
我测试过的,还是会卡顿
我去看了一下 Glide 的 issue,这貌似是一个 Glide 的问题?
— Reply to this email directly, view it on GitHub https://github.com/SherlockGougou/BigImageViewPager/issues/182#issuecomment-1362894407, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEIXE2JVTXK4SVKS37X6FZDWORPPNANCNFSM6AAAAAATDYAWH4 . You are receiving this because you commented.Message ID: @.***>
嗯,glide中也有读取exif的流程。看这个issue至少一年了,好像也没解决方案。
不如换成 Coil 吧,貌似是个新起之秀。或者开放自定义图片加载库也是个好方法,现在手机厂商拍照默认就 HEIC,这个影响确实有点大了
自定义引擎这个我有计划,一直没时间弄,等🐏好了再说🥲
Henry Wu @.***>于2022年12月22日 周四22:30写道:
嗯,glide中也有读取exif的流程。看这个issue至少一年了,好像也没解决方案。
不如换成 Coil 吧,貌似是个新起之秀。或者开放自定义图片加载库也是个好方法,现在手机厂商拍照默认就 HEIC,这个影响确实有点大了
— Reply to this email directly, view it on GitHub https://github.com/SherlockGougou/BigImageViewPager/issues/182#issuecomment-1362906776, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEIXE2JM7JCVWY4AMGYUWFDWORQYRANCNFSM6AAAAAATDYAWH4 . You are receiving this because you commented.Message ID: @.***>
自定义引擎这个我有计划,一直没时间弄,等🐏好了再说🥲 Henry Wu @.>于2022年12月22日 周四22:30写道: … 嗯,glide中也有读取exif的流程。看这个issue至少一年了,好像也没解决方案。 不如换成 Coil 吧,貌似是个新起之秀。或者开放自定义图片加载库也是个好方法,现在手机厂商拍照默认就 HEIC,这个影响确实有点大了 — Reply to this email directly, view it on GitHub <#182 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEIXE2JM7JCVWY4AMGYUWFDWORQYRANCNFSM6AAAAAATDYAWH4 . You are receiving this because you commented.Message ID: @.>
大佬注意安全啊,身体重要
我查了一些资料,我想到了一种可能的绕过方式。Glide 提供了自定义解码器的能力,阿里云刚好也有一个开源的解码器。如果集成这个 HEIF
解码器,而不使用安卓自带的解码器能否绕过这个问题?
阿里云的开源 HEIF 解码器: https://github.com/aliyun/heif-decoder-lib 阿里云的开源 HEIF 解码器文档: https://help.aliyun.com/document_detail/468071.html
然后就是 Bitmap.Config.HARDWARE
是否需要被设置成默认 (不仅限于 HEIF,根据 Coil 的那个进行判断是否可以使用, 不然就 fallback 到 Bitmap.Config.ARGB_888
或者 Bitmap.Config.RGB_565
)?
我查了一些资料,我想到了一种可能的绕过方式。Glide 提供了自定义解码器的能力,阿里云刚好也有一个开源的解码器。如果集成这个
HEIF
解码器,而不使用安卓自带的解码器能否绕过这个问题?阿里云的开源 HEIF 解码器: https://github.com/aliyun/heif-decoder-lib 阿里云的开源 HEIF 解码器文档: https://help.aliyun.com/document_detail/468071.html
尝试了一下没有效果,看了一下最后已缓存的图片图片是通过 subsampling-scale-image-view
加载的,这样就跟 Glide 没有关系了,是 SSIV 的问题。或许大佬可以看一下 tachiyomi 的这个 fork? 他们使用 c++ 写了一个 decoder。但是却少了一些东西像是EXIF_OREINTATION, image tiling
项目地址: https://github.com/tachiyomiorg/subsampling-scale-image-view 解码器地址: https://github.com/tachiyomiorg/image-decoder