我有一个IntentService,用于将日志发送到我们的日志记录服务器。
我收到的报告显示这个应用程序在现场退出,没有任何理由,没有ANR,没有“不幸......”,只是一个沉默的“崩溃到桌面”(这不是“崩溃” - 碰撞不会抓住它。应用程序只是消失,没有过渡动画或任何东西)这似乎是导致它的问题。 偶尔我会得到一个ANR对话框,除了打断用户之外,它似乎不会影响应用程序。
我已经研究过如何调试ANR,但似乎没有任何东西可以指出为什么会出现这些问题,而不是在执行此服务时发生这种情况。
首先我尝试转储anr跟踪。唯一看起来有问题的线程是这个,但它不知道GCDaemon试图锁定什么(full anr trace here):
"GCDaemon" daemon prio=5 tid=11 Blocked
| group="system" sCount=1 dsCount=0 obj=0x12c9c200 self=0xaf211400
| sysTid=12503 nice=0 cgrp=apps sched=0/0 handle=0xaf225a80
| state=S schedstat=( 2357890680 895472914 1619 ) utm=195 stm=40 core=0 HZ=100
| stack=0xb3c46000-0xb3c48000 stackSize=1036KB
| held mutexes=
native: #00 pc 00010110 /system/lib/libc.so (syscall+28)
native: #01 pc 000aad07 /system/lib/libart.so (art::ConditionVariable::Wait(art::Thread*)+82)
native: #02 pc 0012f793 /system/lib/libart.so (art::gc::Heap::WaitForConcurrentGCRequest(art::Thread*)+90)
native: #03 pc 000003db /system/framework/arm/boot.oat (Java_dalvik_system_VMRuntime_waitForConcurrentGCRequest__+82)
at dalvik.system.VMRuntime.waitForConcurrentGCRequest(Native method)
- waiting to lock an unknown object
at java.lang.Daemons$GCDaemon.run(Daemons.java:334)
at java.lang.Thread.run(Thread.java:818)
我尝试过严格的模式,但是当对话框显示时,我没有遇到任何严格的模式违规,只有以下转储:
02-14 15:16:54.434 821-1014/? E/ActivityManager: ANR in com.myApp
PID: 26032
Reason: Executing service com.myApp/.services.LoggerService
Load: 11.8 / 12.09 / 12.38
CPU usage from 1377ms to -6213ms ago:
55% 821/system_server: 19% user + 36% kernel / faults: 9743 minor
5.9% 1758/com.google.android.gms: 3.1% user + 2.7% kernel / faults: 1739 minor
5.5% 1188/com.android.systemui: 2.9% user + 2.6% kernel / faults: 2141 minor
0% 287/debuggerd: 0% user + 0% kernel / faults: 2917 minor
3.9% 1461/com.android.phone: 1.5% user + 2.3% kernel / faults: 2380 minor
3.8% 26032/com.myApp: 2.2% user + 1.5% kernel / faults: 6809 minor
3% 4767/com.twotechnologies.n5service: 0.9% user + 2.1% kernel / faults: 860 minor
2.2% 212/dhd_dpc: 0% user + 2.2% kernel
1.7% 1542/com.sec.imsservice: 0.5% user + 1.1% kernel / faults: 1529 minor
0% 1455/com.android.nfc: 0% user + 0% kernel / faults: 701 minor
0.7% 19190/adbd: 0.1% user + 0.6% kernel / faults: 129 minor
0% 1447/com.android.server.telecom: 0% user + 0% kernel / faults: 803 minor
0% 2030/com.android.incallui: 0% user + 0% kernel / faults: 656 minor
0.6% 2246/mpdecision: 0.6% user + 0% kernel
0.6% 3069/mdnsd: 0.1% user + 0.5% kernel
0.5% 213/dhd_rxf: 0% user + 0.5% kernel
0% 2001/com.samsung.vmmhux: 0% user + 0% kernel / faults: 591 minor
0.3% 20989/kworker/u:3: 0% user + 0.3% kernel
0.2% 211/dhd_watchdog_th: 0% user + 0.2% kernel
0.2% 9206/kworker/0:0H: 0% user + 0.2% kernel
0.2% 22900/logcat: 0% user + 0.2% kernel
0.2% 25851/kworker/0:0: 0% user + 0.2% kernel
0.2% 26330/logcat: 0.1% user + 0.1% kernel
0.2% 26361/kworker/u:2: 0% user + 0.2% kernel
0% 1//init: 0% user + 0% kernel / faults: 20 minor
0.1% 2/kthreadd: 0% user + 0.1% kernel
0.1% 3/ksoftirqd/0: 0% user + 0.1% kernel
0.1% 7/kworker/u:0H: 0% user + 0.1% kernel
0.1% 33/kworker/u:1H: 0% user + 0.1% kernel
0.1% 171/cfinteractive: 0% user + 0.1% kernel
0.1% 205/mmcqd/1: 0% user + 0.1% kernel
0% 223/jbd2/mmcblk0p25: 0% user + 0% kernel
0.1% 256/surfaceflinger: 0.1% user + 0% kernel
0.1% 281/edmaudit: 0% user + 0.1% kernel
0.1% 1984/com.google.android.gms.persistent: 0.1% user + 0% kernel
0.1% 2583/com.vcast.mediamanager: 0% user + 0.1% kernel
0.1% 2874/tv.peel.samsung.app: 0% user + 0.1% kernel
0.1% 22944/perfd: 0% user + 0.1% kernel
+0% 28214/diag_uart_log: 0% user + 0% kernel
+0% 28215/migration/3: 0% user + 0% kernel
+0% 28216/kworker/3:0: 0% user + 0% kernel
+0% 28217/kworker/3:0H: 0% user + 0% kernel
+0% 28218/ksoftirqd/3: 0% user + 0% kernel
+0% 28219/kworker/3:1: 0% user + 0% kernel
+0% 28220/kworker/3:1H: 0% user + 0% kernel
58% TOTAL: 19% user + 35% kernel + 0% iowait + 3.5% softirq
CPU usage from 5173ms to 5712ms later:
16% 821/system_server: 3.3% user + 13% kernel / faults: 6 minor
13% 1014/ActivityManager: 3.3% user + 10% kernel
1.6% 835/FinalizerDaemon: 0% user + 1.6% kernel
2.1% 1758/com.google.android.gms: 2.1% user + 0% kernel / faults: 7 minor
1% 27483/mdns-receive: 1% user + 0% kernel
0.9% 1//init: 0% user + 0.9% kernel / faults: 9 minor
1.7% 212/dhd_dpc: 0% user + 1.7% kernel
1.1% 4767/com.twotechnologies.n5service: 1.1% user + 0% kernel / faults: 3 minor
1.1% 4789/b: 1.1% user + 0% kernel
1.1% 4790/h: 0% user + 1.1% kernel
+0% 28214/diag_uart_log: 0% user + 0% kernel
24% TOTAL: 5.4% user + 17% kernel + 1.3% softirq
我尝试过ANRWatchDog:https://github.com/SalomonBrys/ANR-WatchDog,当ANR对话框显示时,它不会抛出异常。
最后,我尝试从服务的onHandleIntent中删除所有LOGIC,我仍然定期得到ANR对话框。就像在,这是服务的onHandleIntent:
@Override
protected void onHandleIntent(Intent intent) {
}
我很难过。
答案 0 :(得分:2)
我通过不使用IntentService并切换到一组激活AsyncTasks的静态方法解决了我的问题。我仍然不知道我最初问题的根本原因是什么。