[Android Software Development] arter97:
/* Info */

There's a known issue on Android 5.0 Lollipop.

The bootanimation binary(/system/bin/bootanimation - Responsible for initial boot animations during bootup) causes a serious memory leak, too exhaustive that core system services or other processes can be killed during boot,

or on the worst case, endless boot loop due to core system services unable to initialize.

/* Why? */

My theory is, the current bootanimation implementation does not releases the resources held to play previous frames.

Testing this on a Galaxy S4 with a 1080p bootanimation.zip file resulted in 200MB of RAM usage in 3 seconds, and the kernel starts to kill processes in 10 seconds.

With a Nexus 7, luckily, it did pass on the bootanimation and showed up the lock-screen. However, some services got killed during boot and resulted in an overall unstable system.

I've been able to reproduce this bug on majority of devices including Galaxy Note 3, Galaxy S4, Nexus 7, Nexus 5, Nexus 4 and much more with CyanogenMod 12, Google's pure/stock AOSP and LG's Lollipop firmware.

I'm almost certain that other Android 5.0 Lollipop ROMs may have the same problem(except for Samsung's Touchwiz - Touchwiz uses qmg format and I was unable to reproduce this bug on Touchwiz).

You maybe asking yourself -

"But CM12 has this issue solved?"

Short answer is no, they've just put a band-aid on it - reducing framerate and clearing up caches more aggressively to "workaround", and this is not a permanent solution.

"What about other manufacturer's ROM?"

On my test, Samsung's Touchwiz was the only ROM that has this issue solved(probably thanks to the their proprietary qmg format). Other manufacturers - LG, hTC and more - may also suffer from the same bug.

"Can I expect this fix to be integrated with CyanogenMod 12 nightlies?"

Maybe. I've sent this fix to CyanogenMod Gerrit code review. If they approve it, it'll be integrated into future nightly builds.

/* Solution? */

Before I could have come up with a permanent solution, I suggested users to remove /system/bin/bootanimation from their devices for now, as this is a very serious issue.

Now, I've got a working, permanent fix.

V2 - Much cleaner code & misc fixes with some bootanimation.zip files

The attached "bootanimation.zip" contains 3 binaries.

cm12/bootanimation is for CyanogenMod 12(or its fork) users

aosp/<CPU architecture>/bootanimation is for pure/stock AOSP(or its fork) users & manufacturer's ROM users & Nexus users with stock ROM installed.

<You must install the right bootanimation binary for your device's CPU architecture; users will most likely install 32bit unless they use Nexus 9 or LG G flex 2>

Download the "bootanimation.zip", extract the right "bootanimation" binary and put it under /system/bin - replacing the old one.

The correct owner is root:root,

the correct permission is 755(rwxr-xr-x).

If those binaries do not work for you, I'm afraid your ROM developer/builder have to integrate the fix into the source code, or not use the bootanimation at all :(

/* Some more technical information */

If you're a ROM developer, who wants to integrate this fix, please read below and cherry-pick the correct fix.

Android Issue tracker - https://code.google.com/p/android/issues/detail?id=140061

CyanogenMod Gerrit code review - http://review.cyanogenmod.org/88968

CyanogenMod Gerrit GitHub - https://github.com/CyanogenMod/andr...mmit/de11ae6610f3c96b07b8e2e1d0dc1531c21ac82f

Android Gerrit code review - https://android-review.googlesource.com/132681