Explained: Why this photo crashes some Android phones

An interesting Android bug was discovered a week ago, where a certain image set as a wallpaper would trigger a bootloop, basically bricking Android devices and requiring users to do a factory reset via the recovery menu.

 

A bootloop is when a device tries to power on, but fails and starts the restart process. On the next iteration it also fails and triggers another restart and so on. The wallpaper causing the bug was the one in the title picture and you can see from the replies on the tweet embedded above this paragraph, a lot of Android users reported that setting that wallpaper crashed their device.

 

The affected phones were mainly Samsung devices and Google Pixels phone, with the reason being that they use the default Android color engine. The problem simplified is basically this. Android supports a limited color space, sRGB to be precise, while bigger color spaces like Adobe RGB or Pro Photo RGB. Photos that use the Adobe RGB or Pro Photo RGB color space get convered to sRGB so they can be displayed on Android devices.

The color (luminance) that each pixel displays is a sum of values of the red, blue and green color/luminance that has a max value of 255. The exact formula is  0.2126 * red + 0.7152 * green + 0.0722f * blue. On the photo, that use the Google Skia color profile not support natively in Android 10, the conversion happens and we have a pixel that gives these results when converted: red = 54.213, green = 182.376, blue = 18.411. When we sum up those values, we get a value less than 255, which shouldn’t break anything, but for some reason Google rounds the numbers to higher integer value: red = 55, green = 183, blue = 19, which in sum give 257, more than the 255 limit. The default Google color engine doesn’t gracefully handle that error and it has a wrong rounding logic.

Above you can see the code in question in the ImageProcessHelper.java file in SystemUI folder in Android. The value of histogram is exceeded when the erroneous conversion happens and the function breaks.

Nokia phones (and most other Android phones) don’t appear to be affected most likely because they don’t use the Google default color engine. According to an official statement from Google, the company is conducting internal testing but believes that the pixel with exceeding luminance is the reason things break, and not the color space the image is encoded in.

YouTube

Arun from Mr.Whosetheboss channel did a nice explanation of the issue followed by easy to understand graphics, while more details about this issue can be found on the Xda-developers portal as well.

Note: We don’t encourage you to use the wallpaper on your device and we are not responsible for any damages it can cause.