我的一個測驗app,會進行:
-音樂播放,一直進行
-視頻播放/圖片顯示:間歇性進行
-CPU高負載運行:一直進行
總計運行4小時。
總計跑了100次,大約5次會出現被系統kill掉的情況。
看log是因為:系統要把廣播(android.intent.action.BATTERY_CHANGED)發送給應用時卻失敗了,從而導致應用被系統殺掉。
其它背景:
-這個應用通過shareUserId的方式與“android.uid.system”共享user ID;
-應用的安裝包即apk檔案在手機的system/app目錄下。
-應用的pid是8047。
不知道什么原因會引起系統發廣播給我的應用時,出現了拋出DeadObjectException的失敗的情況?
相關log片段如下:
09-27 22:21:58.240 1283 1418 W BroadcastQueue: Can't deliver broadcast to com.my.app (pid 8047). Crashing it.
09-27 22:21:58.242 1278 1402 I ActivityManager: Killing 8047:com.my.demo/1000 (adj 0): scheduleCrash for 'can't deliver broadcast' failed
09-27 22:21:58.259 1283 1418 W BroadcastQueue: Failure sending broadcast Intent { act=android.intent.action.BATTERY_CHANGED flg=0x60000010 (has extras) }
09-27 22:21:58.259 1283 1418 W BroadcastQueue: android.os.DeadObjectException: Transaction failed on small parcel; remote process probably died
09-27 22:21:58.259 1283 1418 W BroadcastQueue: at android.os.BinderProxy.transactNative(Native Method)
09-27 22:21:58.259 1283 1418 W BroadcastQueue: at android.os.BinderProxy.transact(Binder.java:764)
09-27 22:21:58.259 1283 1418 W BroadcastQueue: at android.app.IApplicationThread$Stub$Proxy.scheduleRegisteredReceiver(IApplicationThread.java:1560)
09-27 22:21:58.259 1283 1418 W BroadcastQueue: at com.android.server.am.BroadcastQueue.performReceiveLocked(BroadcastQueue.java:491)
09-27 22:21:58.259 1283 1418 W BroadcastQueue: at com.android.server.am.BroadcastQueue.deliverToRegisteredReceiverLocked(BroadcastQueue.java:703)
09-27 22:21:58.259 1283 1418 W BroadcastQueue: at com.android.server.am.BroadcastQueue.processNextBroadcast(BroadcastQueue.java:858)
09-27 22:21:58.259 1283 1418 W BroadcastQueue: at com.android.server.am.BroadcastQueue$BroadcastHandler.handleMessage(BroadcastQueue.java:171)
09-27 22:21:58.259 1283 1418 W BroadcastQueue: at android.os.Handler.dispatchMessage(Handler.java:106)
09-27 22:21:58.259 1283 1418 W BroadcastQueue: at android.os.Looper.loop(Looper.java:164)
09-27 22:21:58.259 1283 1418 W BroadcastQueue: at android.os.HandlerThread.run(HandlerThread.java:65)
09-27 22:21:58.259 1283 1418 W BroadcastQueue: at com.android.server.ServiceThread.run(ServiceThread.java:46)
09-27 22:21:58.328 1283 7817 I WindowManager: WIN DEATH: Window{5fdb8d6 u0 com.my.demo/com.my.demo.MyTestMain}
09-27 22:21:58.329 1283 2949 I PowerManagerService: Going to sleep due to screen timeout (uid 1000)...
09-27 22:21:58.334 1283 2960 I WindowManager: WIN DEATH: Window{202cf6 u0 com.my.demo/com.my.demo.DemoTestTestingActivity}
09-27 22:21:58.336 1283 1732 W ActivityManager: Scheduling restart of crashed service com.my.demo/.DemoTestService in 1000ms
09-27 22:21:58.337 1283 1732 W ActivityManager: Force removing ActivityRecord{73be0d2 u0 com.my.demo/.DemoTestTestingActivity t18}: app died, no saved state
09-27 22:21:58.401 1283 1732 W ActivityManager: Slow operation: 52ms so far, now at startProcess: returned from zygote!
09-27 22:21:58.401 1283 1732 W ActivityManager: Slow operation: 52ms so far, now at startProcess: done updating battery stats
09-27 22:21:58.401 1283 1732 W ActivityManager: Slow operation: 52ms so far, now at startProcess: building log message
09-27 22:21:58.401 1283 1732 I ActivityManager: Start proc 19855:com.my.demo/1000 for activity com.my.demo/.DemoTestMain
09-27 22:21:58.402 1283 1732 W ActivityManager: Slow operation: 53ms so far, now at startProcess: starting to update pids map
09-27 22:21:58.402 1283 1732 W ActivityManager: Slow operation: 53ms so far, now at startProcess: done updating pids map
uj5u.com熱心網友回復:
482 void performReceiveLocked(ProcessRecord app, IIntentReceiver receiver,483 Intent intent, int resultCode, String data, Bundle extras,
484 boolean ordered, boolean sticky, int sendingUser) throws RemoteException {
485 // Send the intent to the receiver asynchronously using one-way binder calls.
486 if (app != null) {
487 if (app.thread != null) {
488 // If we have an app thread, do the call through that so it is
489 // correctly ordered with other one-way calls.
490 try {
491 app.thread.scheduleRegisteredReceiver(receiver, intent, resultCode,
492 data, extras, ordered, sticky, sendingUser, app.repProcState);
493 // TODO: Uncomment this when (b/28322359) is fixed and we aren't getting
494 // DeadObjectException when the process isn't actually dead.
495 //} catch (DeadObjectException ex) {
496 // Failed to call into the process. It's dying so just let it die and move on.
497 // throw ex;
498 } catch (RemoteException ex) {
499 // Failed to call into the process. It's either dying or wedged. Kill it gently.
500 synchronized (mService) {
501 Slog.w(TAG, "Can't deliver broadcast to " + app.processName
502 + " (pid " + app.pid + "). Crashing it."); //here
503 app.scheduleCrash("can't deliver broadcast"); //crash app
504 }
505 throw ex;
506 }
507 } else {
508 // Application has died. Receiver doesn't exist.
509 throw new RemoteException("app.thread must not be null");
510 }
511 } else {
512 receiver.performReceive(intent, resultCode, data, extras, ordered,
513 sticky, sendingUser);
514 }
515 }
@binder.c
4067err_alloc_t_failed:
4068err_bad_call_stack:
4069err_empty_call_stack:
4070err_dead_binder:
4071err_invalid_target_handle:
...
4081 binder_debug(BINDER_DEBUG_FAILED_TRANSACTION,
4082 "%d:%d transaction failed %d/%d, size %lld-%lld line %d\n",
4083 proc->pid, thread->pid, return_error, return_error_param,
4084 (u64)tr->data_size, (u64)tr->offsets_size,
4085 return_error_line);
11-25 09:31:23.786059 1052 1052 I [128416.232769](6)[1052:ActivityManager]binder: 1025:1052 transaction failed 29201/-28, size 792-8 line 3781
return_error --> 29201 --> BR_FAILED_REPLY
return_error_param --> 28 --> ENOSPC /* No space left on device */
31#define ENOSPC 28 /* No space left on device */
uj5u.com熱心網友回復:
最近也遇到類似的問題,但是我們的sdk已經適配target26,專案內代碼絕大部分使用了本地廣播,部分使用隱式廣播intent也加上了packname,不知道為什么還會出現這個問題,請問你最終如何解決的uj5u.com熱心網友回復:
root cause應該在Slow operation...先查找到Slow operation的原因
uj5u.com熱心網友回復:
你應該沒有register android.intent.action.BATTERY_CHANGED這個廣播吧,這是個stick廣播,立即回傳,分析是你APP Slow operation導致廣播給android.uid.system組的這個廣播處理不過來,從面kill了你APP。
uj5u.com熱心網友回復:
這是個很好的問題,希望有更多貢獻想法轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/39081.html
標籤:Android
