ANR例子分析

1.

TraceBegin:
  at android.bluetooth.BluetoothDevice.getService(BluetoothDevice.java:765)
  - waiting to lock <0x0bd27d7c> (a java.lang.Class<android.bluetooth.BluetoothDevice>) held by thread 20
  at android.bluetooth.BluetoothDevice.<init>(BluetoothDevice.java:808)
  at android.bluetooth.BluetoothDevice$2.createFromParcel(BluetoothDevice.java:851)
  at android.bluetooth.BluetoothDevice$2.createFromParcel(BluetoothDevice.java:849)
  at android.os.Parcel.readParcelable(Parcel.java:2774)
  at android.os.Parcel.readValue(Parcel.java:2668)
  at android.os.Parcel.readArrayMapInternal(Parcel.java:3037)
  at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:288)
  at android.os.BaseBundle.unparcel(BaseBundle.java:232)
  - locked <0x04c36605> (a android.os.Bundle)
  at android.os.BaseBundle.getInt(BaseBundle.java:1030)
  at android.content.Intent.getIntExtra(Intent.java:7404)
  at com.android.systemui.statusbar.phone.PhoneStatusBarPolicy$6.onReceive(PhoneStatusBarPolicy.java:1104)
  at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0(LoadedApk.java:1391)
  at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(lambda:-1)
  at android.os.Handler.handleCallback(Handler.java:873)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:193)
  at android.app.ActivityThread.main(ActivityThread.java:6739)
  at java.lang.reflect.Method.invoke(Native method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:911)
TraceEnd:

PhoneStatusBarPolicy類的廣播接收調(diào)用Intent的getIntExtra方法,getIntExtra方法中又調(diào)用Bundle的getInt方法,Bundle繼承了BaseBundle,而getInt方法調(diào)用initializeFromParcelLocked,initializeFromParcelLocked方法調(diào)用Parcel類的readArrayMapSafelyInternal->readValue->readParcelable
readParcelable調(diào)用BluetoothDevice的createFromParcel內(nèi)部方法,最后調(diào)到BluetoothDevice的getService方法,getService方法中的同步鎖被占用導(dǎo)致超時引起anr

2.

CPU usage from 8806ms to 1574ms ago (2020-06-19 10:31:11.723 to 2020-06-19 10:31:18.955):

66% 202/kswapd0: 0% user + 66% kernel
84% TOTAL: 1.9% user + 31% kernel + 48% iowait + 0.8% irq + 1.1% softirq

2973 06-19 10:29:56.836 0 0 W Kernel-Dmesg: <6>[ 905.391973] lowmemorykiller: Killing '360.vehiclesafe' (11128), adj 800,
2992 06-19 10:30:05.583 0 0 W Kernel-Dmesg: <6>[ 914.136148] lowmemorykiller: Killing 'droid.launcher3' (2813), adj 600,
3203 06-19 10:30:20.428 0 0 W Kernel-Dmesg: <6>[ 928.983072] lowmemorykiller: Killing 'droid.ugc.aweme' (11952), adj 800,
3224 06-19 10:30:24.038 0 0 W Kernel-Dmesg: <6>[ 932.590529] lowmemorykiller: Killing 'eme:pushservice' (11200), adj 800,
3235 06-19 10:30:24.175 0 0 W Kernel-Dmesg: <6>[ 932.731340] lowmemorykiller: Killing 'dex2oat' (12166), adj 800,
3260 06-19 10:30:28.600 0 0 W Kernel-Dmesg: <6>[ 937.153983] lowmemorykiller: Killing '.bydauto:widget' (11621), adj 800,
3273 06-19 10:30:31.749 0 0 W Kernel-Dmesg: <6>[ 940.302453] lowmemorykiller: Killing 'droid.ugc.aweme' (12116), adj 700,
3284 06-19 10:30:33.007 0 0 W Kernel-Dmesg: <6>[ 941.563009] lowmemorykiller: Killing 'd.process.media' (11642), adj 700,
3294 06-19 10:30:33.038 0 0 W Kernel-Dmesg: <6>[ 941.592324] lowmemorykiller: Killing '360.vehiclesafe' (11599), adj 500,
3307 06-19 10:30:34.891 0 0 W Kernel-Dmesg: <6>[ 943.444464] lowmemorykiller: Killing 'com.baidu.input' (3320), adj 200,
3327 06-19 10:31:18.236 0 0 W Kernel-Dmesg: <6>[ 986.792079] lowmemorykiller: Killing 'm.baidu.mapauto' (3437), adj 100,

系統(tǒng)資源緊張 CPU占用率較高,當(dāng)前系統(tǒng)已經(jīng)在kill前臺應(yīng)用

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容