Author Topic: Android Stuck Wake Lock  (Read 524 times)

Online MrPlow

  • Prof. Inline
  • *****
  • Posts: 1497
    • View Profile
Android Stuck Wake Lock
« on: 2019-Feb-12 »
Hi Guys

This might be usual info for some of you...
I was investigating the wakelocks for some of my busier apps - in the region of 2 - 3% of sessions have stuck wakelocks - Google bad behaviour allows for 0.10% so it's a problem and Google said it would affect store visibility if not addressed.

The main tag that seems to be the culprit is Audiomix (so sound and music) - possibly related to users switching jumping in and out of apps or due to adverts.

In order to try and fix this I modified some of the SDL Java file slightly...to perform a release of sound resources before native pause - and so far, it seems to be reducing my wakelocks!! Yay!!

My test app was 2.10% wakelock and is now down to 1.49% and that is with only a small portion of the total installs on the new version...If it gets down even further I will let you know.

Code: Text [Select]
 public void surfaceDestroyed(SurfaceHolder holder) {
        Log.i("glbasic", "surfaceDestroyed()");
                if (SDLActivity.usePauseCall==true)
                        SDLActivity.glbasicOnPause(1); // 1=pause
        if (!SDLActivity.mIsPaused) {
            SDLActivity.mIsPaused = true;
                         SDLActivity.androidAudio.pauseMusic(); // gp
                        SDLActivity.androidAudio.release(); // gp - releasing sound resources
                        SDLActivity.nativePause(); // SDL2 - moved down in sequence
           
                }
        enableSensor(Sensor.TYPE_ACCELEROMETER, false);
    }
« Last Edit: 2019-Feb-12 by MrPlow »
Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3632
    • View Profile
    • Space Fractal
Re: Android Stuck Wake Lock
« Reply #1 on: 2019-Feb-12 »
do you uses AUTOPAUSE FALSE or AUTOPAUSE TRUE?
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Online MrPlow

  • Prof. Inline
  • *****
  • Posts: 1497
    • View Profile
Re: Android Stuck Wake Lock
« Reply #2 on: 2019-Feb-12 »
Hi

ALLOWESCAPE FALSE
AUTOPAUSE TRUE

i think it was necessarily for Autopause True if ads are present?
Comp:
Speccy-48k, Speccy-128k, Amigas, PCs

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3632
    • View Profile
    • Space Fractal
Re: Android Stuck Wake Lock
« Reply #3 on: 2019-Feb-12 »
yes im see in the source code both subs is not called when AUTOPAUSE is set to FALSE and might is harder to control or checking if HIBERNATE is got stuck.

Could look like a similar issue, even in Windows 10, where a paused HIBERNATE() state dosent not allways resumed or killed correctly?

Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Online MrPlow

  • Prof. Inline
  • *****
  • Posts: 1497
    • View Profile
Re: Android Stuck Wake Lock
« Reply #4 on: 2019-Feb-14 »
Hi All

Just to let you know - so far I have managed to reduce wake locks from 2.10% to 1%
It's still above the threshold but much better.

Audiomix is still the tag that seems to be causing it so any other suggestions to try to decrease are most welcome :)
Comp:
Speccy-48k, Speccy-128k, Amigas, PCs