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

$AppEnd事件优化建议 #85

Open
William353 opened this issue Jun 28, 2021 · 3 comments
Open

$AppEnd事件优化建议 #85

William353 opened this issue Jun 28, 2021 · 3 comments

Comments

@William353
Copy link

William353 commented Jun 28, 2021

现在开启自动埋点$AppEnd后,每2s会往SharedPrefence里面更新一下数据,调用比较频繁,SharedPrefence的ANR较多,能否优化一下,不使用SharedPrefence,使用其他的数据存储方式,比如数据库?

@dengshiwei
Copy link
Contributor

@William353 感谢你的反馈,你这边使用的是哪个版本的 SDK?目前我们从 4.4.4 版本,已经将这部分操作放到异步线程处理了。

@William353
Copy link
Author

4.4.9

其实不管是否在子线程,只要用SharedPrefence,就会有ANR风险。
Android 8.0以上系统,会把写任务先放到QueuedWork的任务队列再取出执行,QueuedWork.waitToFinsih 时,如果任务队里有尚未处理的写任务,主线程会主动执行,这就是anr的原因。
所以只要用SharedPrefence,就一定会有anr出现的概率。是否考虑其他存储方式?

@dengshiwei
Copy link
Contributor

@William353 谢谢反馈,这块我们内部调研一下

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