What is Spurious Death in Android?

前端 未结 1 1086
情书的邮戳
情书的邮戳 2021-02-04 06:37

I know it sounds a lazy question.. but I really have no much clue about how this scenario happened, neither can I find much information about it on Google.

Backg

相关标签:
1条回答
  • 2021-02-04 06:58

    The offending line can be found here: http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.0.0_r1/com/android/server/am/ActivityManagerService.java/#4858 (Different line for different versions of Android L)

    I assume you are using some form of Android L, since that particular error message wasn't added until then.

    If you are running a ContentProvider in your process, these two comments in the ActivityManagerService might be of help:

    9303                     // NOTE: there is still a race here where a signal could be
    9304                     // pending on the process even though we managed to update its
    9305                     // adj level.  Not sure what to do about this, but at least
    9306                     // the race is now smaller.
    9307                     if (!success) {
    9308                         // Uh oh...  it looks like the provider's process
    9309                         // has been killed on us.  We need to wait for a new
    9310                         // process to be started, and make sure its death
    9311                         // doesn't kill our process.
    

    and then ...

    9317                         appDiedLocked(cpr.proc);
    

    appDiedLocked can be called from some other source files too: ActiveServices.java and ActivityStackSupervisor.java, one depends on DeadObjectException being thrown, the other on RemoteException.

    appDiedLocked looks like this

    4853     final void appDiedLocked(ProcessRecord app, int pid, IApplicationThread thread) {
    4854         // First check if this ProcessRecord is actually active for the pid.
    4855         synchronized (mPidsSelfLocked) {
    4856             ProcessRecord curProc = mPidsSelfLocked.get(pid);
    4857             if (curProc != app) {
    4858                 Slog.w(TAG, "Spurious death for " + app + ", curProc for " + pid + ": " + curProc);
    4859                 return;
    4860             }
    4861         }
    

    For some reason, the curProc isn't the same as the app ProcessRecord, and the appDiedLocked method is cut short. In your case curProc is null, again for some reason.

    Long story short: Your process died, or was killed, and some state or condition is preventing appDiedLocked from continuing down to run the killProcess commands. You have some more investigation / logging to do to find out why that happened.

    If you have a service that you want to keep alive, unless you are doing it already, I would recommend that you attach a status bar notification to it, that way the likeliness of it being killed is lowered.

    0 讨论(0)
提交回复
热议问题