Android Framework开发系统问题分析

  Android系统启动篇

1,《android系统启动流程简介》

2,《android init进程启动流程》

3,《android zygote进程启动流程》

4,《Android SystemServer进程启动流程》

5,《android launcher启动流程》

6,《Android Activity启动过程详解》

Android系统开发准备篇

1,《Android 源码下载和编译》

2,《android 11源码编译和pixel3 刷机》

3,《Android Framework代码IDE加载和调试》

Android系统开发实践篇

1,《android设置默认输入法》

2,《android framework预制APK应用》

3,《Android系统层面限制应用开机自启动详解》

4,《android单独编译framework模块并push》

5,《Android Framework开发系统问题分析》

Android系统开发核心知识储备篇

1,《Android编译系统-envsetup和lunch代码篇》

2,《Android编译系统-概念篇》

3,《android日志系统详解》

4,《Android系统Handler详解》

5,《Android系统Binder详解》

6,《Android中Activity、View和Window关系详解》

7,《android view绘制流程详解》

8,《Android读取系统属性详解》

9,《android 窗口管理机制详解》

10,《初识Android系统》

11,《android中AMS进程通知Zygote进程fork新进程的通信方式》

Android核心功能详解篇

1,《android应用市场点击下载APK安装详解》

2,《Android 手势导航(从下往上滑动进入多任务页面)》

3,《android手势分析(应用界面左往右边滑动退出应用)》

4,《android应用安装流程详解》

5,《android11安装应用触发桌面图标刷新流程》

6,《Android系统多任务Recents详解》

7,《android系统导航栏视图分析》

———————————————————————————————————————————

目录

一、应用类问题相关日志

1.1 Android崩溃的日志

1.2 ANR 应用无响应

1.3 界面卡顿

1.4 启动activity日志

二、系统问题相关日志

2.1 内存泄漏,应用程序程序crash

2.2 线程死锁,导致ANR


一、应用类问题相关日志

1.1 Android崩溃的日志

        按Fatal > Crash > AndroidRuntime > Shutting down VM > Exception > Error 的顺序逐个搜索。

Crash:
关键log:
androidlog:
Shutting down VM|am_crash|FATAL EXCEPTION|FAILED BINDER TRANSACTION|system_app_crash|JavaBinder
主要看:system_app_crash文件堆栈调用

1.2 ANR 应用无响应

        ANR即(application not responding),即应用无响应,程序会弹出一个dialog提示用户程序无响应,而这对于用户体验无疑是很不好的
        至于程序为何会“无响应”,主要有以下几个原因
1:InputDispatching (5 seconds) --主要类型
按键或触摸等输入事件在特定时间内无响应
2:BroadcastTimeout(10 seconds)
BroadcastReceiver在特定时间内无法处理完成
3:ServiceTimeout(20 seconds) --小概率类型
Service在特定的时间内无法处理完成
4:ContentProviderTimeout(10 seconds) --小概率类型
内容提供者,在publish过超时10s;
关键日志:" ANR in "、"Reason: " 、“Dumping to ”、“anr_in”
如:Dumping to /data/anr/
Reason: Input dispatching timed out
 

ANR
关键log:
androidlog:
am_anr|anr in|Dumping to|Collecting stacks for pid
trace:
查看Dumping to后生成对应trace文件
需要看:anr之前xxms当前进程log

dropbox —— 系统服务dropbox以文件形式记录了系统各种异常信息,例如app crash、native crash、anr、kernel panic、event记录、wtf输出等等。可以使用如下命令手动导出:
adb shell dumpsys dropbox

1.3 界面卡顿

//跳帧时间
Choreographer: Frame time delta
//跳帧
Choreographer: Skipped 56 frames!  The application may be doing too much work on its main thread.
 

1.4 启动activity日志

//启一个Activity
start u0 
//查看相关进程id 
Already Exists in BG. So sending its PID
//显示一个Activity
ActivityTaskManager: Displayed

窗口焦点切换:
input_focus:Focus request|Focus leaving|Focus entering

二、系统问题相关日志

2.1 内存泄漏,应用程序程序crash

       应用内部存在内存泄漏,多处不必要的对象创建,未来得及释放。造成GC压力过大,Finalize对象累积太多,导致FinalizerDaemon线程来不及处理。FinalizerWatchdogDaemon线程会让VM退出,应用程序程序crash。

应用最小内存:8M
J606L:/ # getprop|grep heapstart
[dalvik.vm.heapstartsize]: [8m]
应用最大内存:128M
J606L:/ # getprop|grep heapgrowthlimit
[dalvik.vm.heapgrowthlimit]: [128m]
关键日志:
 allocation with 0 free bytes and 0B until OOM, target footprint 134217728, growth limit 134217728
相关日志:
应用中存在多次内存泄露
Line 61834: 10-26 10:19:26.157  3167  3199 I ogle.android.g: Clamp target GC heap from 135MB to 128MB
内存泄露
Line 11833: 10-26 10:20:52.926  3167  3199 I ogle.android.g: Clamp target GC heap from 135MB to 128MB
Line 11841: 10-26 10:20:52.958  3167  6401 I ogle.android.g: WaitForGcToComplete blocked Alloc on HeapTrim for 24.371ms
Line 11843: 10-26 10:20:52.959  3167  6401 I ogle.android.g: Starting a blocking GC Alloc
Line 11874: 10-26 10:20:53.215  3167  4541 I ogle.android.g: Waiting for a blocking GC Alloc

不必要的对象创建造成GC压力过大,Finalize对象累积太多,导致FinalizerDaemon线程来不及处理
10-26 10:21:17.903  3167  3203 E AndroidRuntime: FATAL EXCEPTION: FinalizerWatchdogDaemon
10-26 10:21:17.903  3167  3203 E AndroidRuntime: Process: com.android.example, PID: 3169
10-26 10:21:17.903  3167  3203 E AndroidRuntime: java.util.concurrent.TimeoutException: com.android.internal.os.BinderInternal$GcWatcher.finalize() timed out after 10 seconds
10-26 10:21:17.903  3167  3203 E AndroidRuntime:     at com.android.internal.os.BinderInternal$GcWatcher.finalize(BinderInternal.java:63)
10-26 10:21:17.903  3167  3203 E AndroidRuntime:     at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:289)
10-26 10:21:17.903  3167  3203 E AndroidRuntime:     at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:276)
10-26 10:21:17.903  3167  3203 E AndroidRuntime:     at java.lang.Daemons$Daemon.run(Daemons.java:137)
10-26 10:21:17.903  3167  3203 E AndroidRuntime:     at java.lang.Thread.run(Thread.java:919)
应用中存在内存溢出,即将OOM
Line 3073: 10-26 10:24:38.657  3167  3202 W ogle.android.g: Throwing OutOfMemoryError "Failed to allocate a 40 byte allocation with 0 free bytes and 0B until OOM, target footprint 134217728, growth limit 134217728" (VmSize 5614796 kB)
Line 3211: 10-26 10:24:57.678  3167  3202 W ogle.android.g: Throwing OutOfMemoryError "Failed to allocate a 112 byte allocation

with 0 free bytes and 0B until OOM, target footprint 134217728, growth limit 134217728" (VmSize 5614796 kB, recursive case)

2.2 线程死锁,导致ANR

问题分析:应用内部存在死锁,导致主线程超时引起Anr。
关键日志信息:
//存储anr的dump信息
12-04 14:06:12.541  1000  1374  1488 I ActivityManager: Dumping to /data/anr/anr_2020-12-04-14-06-12-540
//应用弹出无响应
12-04 14:06:23.518  1000  1374  1488 E ActivityManager: ANR in com.android.vending
12-04 14:06:23.518  1000  1374  1488 E ActivityManager: PID: 677
12-04 14:06:23.518  1000  1374  1488 E ActivityManager: Reason: executing service com.android.vending/com.google.android.finsky.scheduler.process.mainimpl.PhoneskyJobServiceMain

------ VM TRACES AT LAST ANR (/data/anr/anr_2020-12-04-14-06-12-540: 2020-12-04 14:06:23) ------
----- pid 677 at 2020-12-04 14:06:12 -----
Cmd line: com.android.vending
//等待<0x05ee37cf>锁,被线程83持有
"main" prio=5 tid=1 Blocked
  | group="main" sCount=1 dsCount=0 flags=1 obj=0x72877a78 self=0xea05ce00
  | sysTid=677 nice=0 cgrp=default sched=0/0 handle=0xea560dc0
  | state=S schedstat=( 14831821629 2738463385 17496 ) utm=1151 stm=331 core=0 HZ=100
  | stack=0xff7bb000-0xff7bd000 stackSize=8192KB
  | held mutexes=
  at aciw.n(PG:1)
  - waiting to lock <0x05ee37cf> (a com.google.android.finsky.installqueue.impl.InstallQueuePhoneskyJob) held by thread 83
  at aciw.m(PG:-1)
  at rdv.E(PG:1)
  at rdv.r(PG:1)
  at com.google.android.finsky.installqueue.impl.InstallQueuePhoneskyJob.t(PG:-1)
  at aciw.q(PG:8)
  at aciv.a(unavailable:7)
  at acha.e(PG:7)
  - locked <0x0ba1fdff> (a acha)
 

//等待<0x0ba1fdff>锁,被主线程持有
"InstallQueueUsingScheduler" prio=5 tid=83 Blocked
  | group="main" sCount=1 dsCount=0 flags=1 obj=0x14544230 self=0xd4081800
  | sysTid=6628 nice=10 cgrp=default sched=0/0 handle=0xa5d0b230
  | state=S schedstat=( 367180002 388557770 934 ) utm=28 stm=8 core=1 HZ=100
  | stack=0xa5c08000-0xa5c0a000 stackSize=1040KB
  | held mutexes=
  at acha.b(PG:-1)
  - waiting to lock <0x0ba1fdff> (a acha) held by thread 1
  at aciw.n(PG:5)
  - locked <0x05ee37cf> (a com.google.android.finsky.installqueue.impl.InstallQueuePhoneskyJob)
  at aciw.m(PG:-1)
————————————————
参考文章:热爱学习的吉吉
原文链接:https://blog.csdn.net/u010871962/article/details/109857386

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

佳哥的技术分享

创作不易,谢谢鼓励

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值