В моем приложении отображается следующее значение ANR (примерно через 30 или более часов работы), более подробная информация о приложении:
- воспроизведение видео с повторением
- Сохранить экран включенным все время
- в фоновом режиме есть служба загрузки файлов (ниже ее использования 0,1%)
- фоновая служба для проверки связи с нашим сервером каждые 5 минут
- некоторые рабочие задания, которые нужно сделать некоторые вещи
ANR подробности:
01-27 03:56:21.505 2318-2429/system_process E/ActivityManager: ANR in net.test.testapp
PID: 5197
Reason: executing service net.test.testapp/androidx.work.impl.background.systemjob.SystemJobService
Load: 3.87 / 4.29 / 4.69
CPU usage from 0ms to 5357ms later:
61% 2318/system_server: 16% user + 44% kernel / faults: 6827 minor
0% 1647/debuggerd: 0% user + 0% kernel / faults: 13383 minor 1 major
24% 5197/net.test.testapp: 8% user + 16% kernel / faults: 3154 minor 7 major
9.1% 3003/com.android.systemui: 4.3% user + 4.8% kernel / faults: 2309 minor
8.2% 3479/com.android.phone: 3.7% user + 4.4% kernel / faults: 2768 minor
0% 1648/debuggerd64: 0% user + 0% kernel / faults: 3899 minor
0% 3468/com.android.server.apnserver: 0% user + 0% kernel / faults: 1852 minor
1.6% 1512/vsync proc 0: 0% user + 1.6% kernel
1.4% 1073/ueventd: 0.7% user + 0.7% kernel
1.3% 1651/mediaserver: 0.5% user + 0.7% kernel / faults: 5 minor
1.1% 1633/surfaceflinger: 0.3% user + 0.7% kernel / faults: 33 minor
0.7% 6311/ksdioirqd/mmc2: 0% user + 0.7% kernel
0.7% 10171/com.android.vending: 0.7% user + 0% kernel / faults: 120 minor
0.7% 23906/kworker/u8:4: 0% user + 0.7% kernel
0.5% 847/autohotplug: 0% user + 0.5% kernel
0.5% 1603/logd: 0.3% user + 0.1% kernel
0.5% 1646/netd: 0.1% user + 0.3% kernel
0.5% 29146/kworker/u8:3: 0% user + 0.5% kernel
0.3% 3/ksoftirqd/0: 0% user + 0.3% kernel
0.3% 846/cfinteractive: 0% user + 0.3% kernel
0.3% 1610/vold: 0% user + 0.3% kernel
0.3% 1629/healthd: 0.1% user + 0.1% kernel
0.3% 8088/kworker/0:0: 0% user + 0.3% kernel
0.1% 8/rcu_preempt: 0% user + 0.1% kernel
0% 10/rcu_sched: 0% user + 0% kernel
0% 788/kworker/1:2: 0% user + 0% kernel
0.1% 849/irq/94-sunxi-mm: 0% user + 0.1% kernel
0.1% 1649/rild: 0.1% user + 0% kernel
0.1% 2650/net.test.testapp:filedownloader: 0.1% user + 0% kernel / faults: 32 minor
0% TOTAL: 0% user + 0% kernel + 0% softirq
CPU usage from 4757ms to 5294ms later:
10% 2318/system_server: 0% user + 10% kernel
10% 2429/ActivityManager: 0% user + 10% kernel
1.8% 3044/Binder_4: 1.8% user + 0% kernel
2.6% 1073/ueventd: 0% user + 2.6% kernel
1.3% 1512/vsync proc 0: 0% user + 1.3% kernel
1.3% 1633/surfaceflinger: 1.3% user + 0% kernel
1.3% 1820/surfaceflinger: 1.3% user + 0% kernel
1.6% 23906/kworker/u8:4: 0% user + 1.6% kernel
11% TOTAL: 1.8% user + 9.2% kernel
Трассировка стека ANR:
suspend all histogram: Sum: 1.679s 99% C.I. 5.278us-3572.682us Avg: 168.904us Max: 58924us
DALVIK THREADS (79):
"Signal Catcher" daemon prio=5 tid=3 Runnable
| group="system" sCount=0 dsCount=0 obj=0x12fc80a0 self=0x7f9fa3f600
| sysTid=5205 nice=0 cgrp=default sched=0/0 handle=0x7f8e0b1440
| state=R schedstat=( 22801441 11087961 6 ) utm=2 stm=0 core=1 HZ=100
| stack=0x7f8dfb5000-0x7f8dfb7000 stackSize=1013KB
| held mutexes= "mutator lock"(shared held)
native: #00 pc 000000000048b108 /system/lib64/libart.so (art::DumpNativeStack(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, int, char const*, art::ArtMethod*, void*)+236)
native: #01 pc 000000000045a2c8 /system/lib64/libart.so (art::Thread::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&) const+220)
native: #02 pc 0000000000466ea8 /system/lib64/libart.so (art::DumpCheckpoint::Run(art::Thread*)+688)
native: #03 pc 0000000000467dc0 /system/lib64/libart.so (art::ThreadList::RunCheckpoint(art::Closure*)+276)
native: #04 pc 000000000046847c /system/lib64/libart.so (art::ThreadList::Dump(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)+188)
native: #05 pc 0000000000468d64 /system/lib64/libart.so (art::ThreadList::DumpForSigQuit(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)+492)
native: #06 pc 0000000000432474 /system/lib64/libart.so (art::Runtime::DumpForSigQuit(std::__1::basic_ostream<char, std::__1::char_traits<char> >&)+96)
native: #07 pc 000000000043f8e4 /system/lib64/libart.so (art::SignalCatcher::HandleSigQuit()+1256)
native: #08 pc 00000000004404f4 /system/lib64/libart.so (art::SignalCatcher::Run(void*)+452)
native: #09 pc 0000000000066d24 /system/lib64/libc.so (__pthread_start(void*)+52)
native: #10 pc 000000000001eb84 /system/lib64/libc.so (__start_thread+16)
(no managed stack frames)
"main" prio=5 tid=1 Waiting
| group="main" sCount=1 dsCount=0 obj=0x753dd000 self=0x7f9fa3ba00
| sysTid=5197 nice=0 cgrp=default sched=0/0 handle=0x7fa2fb8fe8
| state=S schedstat=( 1799523904082 2013529109095 3968264 ) utm=150392 stm=29560 core=0 HZ=100
| stack=0x7fe3998000-0x7fe399a000 stackSize=8MB
| held mutexes=
at java.lang.Object.wait!(Native method)
- waiting on <0x01c2ad1e> (a com.google.android.exoplayer2.ExoPlayerImplInternal)
at com.google.android.exoplayer2.ExoPlayerImplInternal.release(ExoPlayerImplInternal.java:257)
- locked <0x01c2ad1e> (a com.google.android.exoplayer2.ExoPlayerImplInternal)
at com.google.android.exoplayer2.ExoPlayerImpl.release(ExoPlayerImpl.java:440)
at com.google.android.exoplayer2.SimpleExoPlayer.release(SimpleExoPlayer.java:1297)
at net.test.testapp.controllers.idleAdsController.IdleAdsActivity.setUpVideoPlayer(IdleAdsActivity.kt:75)
at net.test.testapp.controllers.idleAdsController.IdleAdsActivity.access$setUpVideoPlayer(IdleAdsActivity.kt:54)
at net.test.testapp.controllers.idleAdsController.IdleAdsActivity$onCompleted$2$1.invoke(IdleAdsActivity.kt:564)
at net.test.testapp.controllers.idleAdsController.IdleAdsActivity$onCompleted$2$1.invoke(IdleAdsActivity.kt:54)
at org.jetbrains.anko.AsyncKt$uiThread$1.run(Async.kt:70)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke!(Native method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:742)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:632)
Вот причина:
public synchronized void release() {
if (released || !internalPlaybackThread.isAlive()) {
return;
}
handler.sendEmptyMessage(MSG_RELEASE);
boolean wasInterrupted = false;
while (!released) {
try {
wait(); // here....
} catch (InterruptedException e) {
wasInterrupted = true;
}
}
if (wasInterrupted) {
// Restore the interrupted status.
Thread.currentThread().interrupt();
}
}
- Как с этим справиться?
- Использование моего приложения составляет 24%, это хорошо, или эти цифры не могут измерить загрузку процессора из моего приложения
Совет