Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PAGImageView 加载网络Pag资源在弱网或超时场景内部重试导致的ANR #2590

Open
cai123 opened this issue Nov 18, 2024 · 0 comments
Assignees

Comments

@cai123
Copy link

cai123 commented Nov 18, 2024

【版本信息】

4.3.33
master也是同样代码,应该也有此问题

【平台信息】

Android 原生

【预期的表现】

进入页面调用setPathAync 加载网络PAG资源,弱网环境下快速退出页面或者removePagView 无ANR问题出现

【实际的情况】

进入页面调用setPathAync 加载网络PAG资源,弱网环境下快速退出页面或者removePagView 有概率导致导致ANR,问题发生在
PagImageView->onDetachedFromWindow->decoderInfo.reset()
image

原因分析

  1. decoderInfo.reset() 为同步方法
image
  1. 调用setPathAync 如果弱网环境或请求失败的场景下会回调到 onAnimationUpdate->flush()
image
  1. flush方法此时会调用initDecoderInfo,initDecoderInfo使用了deocderInfo的对象锁,并且会重新从网络加载Pag资源导致deocderInfo对象锁长期持有
image image
  1. 如果此时退出Activity或者removeView等操作导致PAGImageView的onDetachFromWindow回调,调用到第1步的 decoderInfo.reset(),此时decoderInfo被作为对象锁被initDecoderInfo所在线程持有,主线程的decoderInfo.reset()等待子线程的decoderinfo对象锁释放,此时容易ANR

【Demo及附件】

@cai123 cai123 changed the title PAGImageView 加载网络Pag资源在弱网或超时场景导致ANR PAGImageView 加载网络Pag资源在弱网或超时场景内部重试导致的ANR Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants