PAGImageView 加载网络Pag资源在弱网或超时场景内部重试导致的ANR
Open
@kevingpqi123 is already working on this.
Since Nov 18, 2024.
- Dominant language
- HTML
- Stars
- 5.8k
- Forks
- 531
- Avg merge
- 8d 55m
- Merged PRs (30d)
- 17
Description
【版本信息】
4.3.33
master也是同样代码,应该也有此问题
【平台信息】
Android 原生
【预期的表现】
进入页面调用setPathAync 加载网络PAG资源,弱网环境下快速退出页面或者removePagView 无ANR问题出现
【实际的情况】
进入页面调用setPathAync 加载网络PAG资源,弱网环境下快速退出页面或者removePagView 有概率导致导致ANR,问题发生在
PagImageView->onDetachedFromWindow->decoderInfo.reset()
原因分析
- decoderInfo.reset() 为同步方法
- 调用setPathAync 如果弱网环境或请求失败的场景下会回调到 onAnimationUpdate->flush()
- flush方法此时会调用initDecoderInfo,initDecoderInfo使用了deocderInfo的对象锁,并且会重新从网络加载Pag资源导致deocderInfo对象锁长期持有
- 如果此时退出Activity或者removeView等操作导致PAGImageView的onDetachFromWindow回调,调用到第1步的 decoderInfo.reset(),此时decoderInfo被作为对象锁被initDecoderInfo所在线程持有,主线程的decoderInfo.reset()等待子线程的decoderinfo对象锁释放,此时容易ANR
【Demo及附件】
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.