Decipher - Excessive wake lock

578 views Asked by At

I am getting message in log as below and then app is dying:

 Excessive wake lock in domain.mobile.app.MusicPlayer pid zzz held xxxx during yyyy

My application is a music player. I didn't obtain any wake lock in initial version and player kept playing for hours without any stop. Then I decide to make things clever and added the wake lock. So far so good, player didn't change playing pattern if I play big music fragment for example CD image with duration of 74 minutes. However if I split the images on tracks and release and obtain lock for every separate track, I am getting a message as in subject approximately after 30 minutes playiback and my application gets ejected. As work around I can simply return to my original idea to do not use the lock. However I obtained a curiosity why it behaves in this way and what numbers in error message mean, perhaps it will give me some clue. more details : I am obtaining PARTIAL_WAKE_LOCK once and then play with acquire and release during track changing.

Interesting that some gentleman was complaining about stopping app doing network communication here Application running in background getting closed due to Excessive Wake lock error I have a solution for him, since in my cases phone can keep connection in active state for hours, but unfortunately I am black out from answering questions.

Attention experts moderators of the system, I highly respect your experience and unbelievable brain power but be even smarter and do not try to point me to some other questions and tell it is duplicate, ok?

1

There are 1 answers

0
SomeDude On

So i came across the same problem. After some search i found this and the after some more i found dat. so IF you are using a service for playback (which u prolly do) then in the service's

public int onStartCommand(Intent intent, int flags, int startId)  {
    // write at the end 
    return START_STICKY; } 

    //instead of the default 
    return super.onStartCommand(intent, flags, START_STICKY);
}

I am testing that as i type this and so far all seems to be ok (successfully played 7 songs without interrupt).

EDIT :

It appears that stuff may get killed if OS decides to do so. Accidents happen...