ANR例子分析

1.

TraceBegin:
  at android.bluetooth.BluetoothDevice.getService(BluetoothDevice.java:765)
  - waiting to lock <0x0bd27d7c> (a java.lang.Class) held by thread 20
  at android.bluetooth.BluetoothDevice.(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类的广播接收调用Intent的getIntExtra方法,getIntExtra方法中又调用Bundle的getInt方法,Bundle继承了BaseBundle,而getInt方法调用initializeFromParcelLocked,initializeFromParcelLocked方法调用Parcel类的readArrayMapSafelyInternal->readValue->readParcelable
readParcelable调用BluetoothDevice的createFromParcel内部方法,最后调到BluetoothDevice的getService方法,getService方法中的同步锁被占用导致超时引起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,

系统资源紧张 CPU占用率较高,当前系统已经在kill前台应用

你可能感兴趣的:(ANR例子分析)