android核心技术之ANR分析(MTK)
2017-03-04 12:10
330 查看
What is ANR
ANR = Application Not RespondingANR type:
Key Dispatch TimeoutNot response to an input event(eg: key press,screen touch) within (15 seconds or 8 seconds,default 5 seconds)
Broadcast Timeout
a broadcastReceiver hasn’t finished within 10 seconds
Service Timeout
Request service failed within 20 seconds
Reminder
if you choose “force to close ”,AMS will kill the process.Keep the scene for get important info is very import.
ANR Essential:
Java process has main thread and main message queue(main thread = activity thread)The Main Thread ,that is responsible for handling the ui events like Draw,Listen and receive the UI events.
Main thread will pick up message from main message queue and dispatch it as soon as possible.
Before main thread finish processing current message ,it can not pick up next one.
If main thread stuck with one message and fail to dispatch is in time, ANR will occur.
ANR key info
We need to know why main thread can not process the message in time?Can not get CPU time to run
wait for some event but it donot happen in time?
Message handle flow is too complicated?
So need the follow files for analyze.
MTKLog saved in T card,include:
Aee_exp->db files(data/aee_exp)
MoblieLog->APLog_xxx_xxx->APLog
MdLog->MDLog_xxx_xxx->Modem Log
Netlog-> MDLog_xxx_xxx->Network Log
data/anr saved on the phone,include:
Trace.txt
Mobile Log:
you can get more info about anr from event log and main log:
The ANR time stamp
which process happens anr
which type of anr
more inof about the process before anr
LOG中搜索关键字:
anr
application is not responding
system_app_anr
Trace.txt
you can get callstack from the Trace.txt
Analyze ANR
在APLOG中搜索关键字:anr
application is not responding
Example
Description:IDLE界面进入图库,打开大量的图片,选择条目,点击几张图片,按HOME键,再从IDLE界面进入图库,点击图片,弹出图库没有响应。
Analyze:
(1)find anr time,process ID,ANT type
在APLOG中搜索关键字:
anr
application is not responding
system_app_anr
(2)Check CPU usage
(3)check Trace.txt,mapping process id and time stamp.
最后发现是在主线程中执行了耗时操作query数据库,导致ANR
(4)find more info from main and event log to check main thread.
最后确认是:
main thread are busy query db database all the time.
Need MTK help
提供有效的LOG:-MTKLog saved in T card,include:
Aee_exp->db files
MoblieLog->APLog_xxx_xxx->APLog
MdLog->MDLog_xxx_xxx->Modem Log
Netlog-> MDLog_xxx_xxx->Network Log
-data/anr saved on the phone,include:
Trace.txt
最好是提供ENG的LOG,ENG会提供了更多的信息。
常见导致ANR的原因:
数据库操作I/O被阻塞iowait、ContentResolver.query、onPostExecute
在UI线程进行网络数据的读写
内存不足导致block在创建bitmap上
atdalvik.system.VMRuntime.trackExternalAllocation(NativeMethod)
atandroid.graphics.Bitmap.createBitmap(Bitmap.java:468)
程序异常退出,uncausedexception (Fatal)
程序强制关闭,ForceClosed (简称FC) (Fatal)
通过搜索ANR定位问题
解决ANR的方法:
不要让主线程干耗时的工作不要让其他线程阻塞主线程的执行
参考资料
1.如何分析解决Android ANRhttp://blog.csdn.net/dadoneo/article/details/8270107
2.Android ANR分析与总结
http://blog.csdn.net/androiddevelop/article/details/49515903
3.Android ANR分析
http://blog.csdn.net/yxz329130952/article/details/50087731
4.Application Not Responding(ANR) Analyze
MediaTek On-Line > eCourse Home > SW > ALPS > Common Framework
相关文章推荐
- Android——Lrucache内存缓存技术核心代码分析
- android核心技术之性能分析工具Systrace
- android 核心技术分析-全篇
- android核心技术之性能分析工具TraceView
- android核心技术之性能分析工具Memory Monitor
- Android核心分析 之二 -------方法论探讨之概念空间篇
- Android核心分析之四 ---手机的软件形态
- 智能手机软件平台 Android VS iPhone OS: 技术先进性分析 (3/4)
- 分析ARM ANDROID市场及技术结合点
- 视频编码标准H.264的核心技术分析
- Android核心分析 之十-------Android GWES之基本原理篇
- Android核心分析 之一--------分析方法论探讨之设计意图
- Android核心模块及相关技术
- Android 核心分析(12) -----Android GEWS窗口管理之基本架构原理
- Android核心分析 之九-------Zygote Service
- 分析ARM ANDROID市场及技术结合点 转载
- Android 核心分析 之五 -----基本空间划分
- 校内相册发展过程及核心技术分析爆料
- Android核心模块及相关技术
- Java开发核心技术面试心得分析