Not long after multiple bugs has been patched by google. It seems as if another bug has surfaced. This is not a bug per-se. But something weird is happening with all the Android devices. On some Samsung and Pixel phones an image seems to make the device unusable.It doesn’t allow user to even use their phone anymore. But it only seems to be affecting some Pixel and some Samsung devices. Though mentions were made for Huawei devices. I was all over the internet to find more about the image that crashes android devices. Because it was really very mysterious.
CAUTION: Don’t use this image because it may be the original image. Taken from the original tweet check it out here.
Also Read: Bluetooth Bug: Leaves Multiple Vendors Vulnerable
TECHENUM
The cause for android crashes
While searching for the cause over the internet I came across @evowizz‘s tweet. This guy explained pretty neatly about the issue. The tweet provided the image below which is the stack trace of the crash. In layman’s terms stack trace is just the series of links that tells what went wrong and where.
From the image above and @evowizz‘s findings it is pretty clear that the crash was caused by the phone’s inability to handle different color formats. Or in other word handling only certain format while ignoring everything else. System UI was unable to handle sRGB which is different from RGB, more details below.
So from the situation it is pretty clear that not only the tweeted image but other image of same type will be causing same issue. This is not a serious bugs unlike others such as : Strandhogg 2.0: Android bug that can trick user and steal data. But still it will make you reset your device. Which means the loss of data if you don’t have the habit of backing things up on a routine basis.
Technical Details
If you’re not really interested in the in depth details of what was the cause you might want to skip this section. Here I am explaining what is exactly happening.
There is a class ImageProcessHelper
in the package com.android.systemui.glwallpaper
. If we scroll to line ~129 we will find a method private int[] getHistogram(Bitmap grayscale){ .. }
private int[] getHistogram(Bitmap grayscale) {
int width = grayscale.getWidth();
int height = grayscale.getHeight();
// TODO: Fine tune the performance here, tracking on b/123615079.
int[] histogram = new int[256];
for (int row = 0; row < height; row++) {
for (int col = 0; col < width; col++) {
int pixel = grayscale.getPixel(col, row);
int y = Color.red(pixel) + Color.green(pixel) + Color.blue(pixel);
histogram[y]++;
}
}
return histogram;
}
In the above code taken from Lineage OS’s source look at the below mentioned line carefully
histogram[y]++;
Code language: CSS (css)
If we inspect carefully we will see the definition of histogram
as an array
of length 256
. Where the index goes from 0 to 255. In our particular case, lets say the R.G.B
is (255, 255, 243)
. Then the resulting value for y
will be 256
. Which will cause an OOB
exception. Which then results in crash of the U.I.
So from the explanation above, I hope you’re clear about what went wrong and where. Though this has been fixed in core
Conclusion
Bugs are a part of continuous change in the development of tech world. Without bugs there would be no progress. Well, not really though. The key thing to take away from the image crashes seen on various android devices is to understand how fragile the technology is.
Keep exploring, keep learning and keep avoiding image crashes on android devices.
I really appreciate your blog post. It really covers most things about this subject. Keep it up! Don’t forget to check out my website also!
I do agree with all of the ideas you have presented in your post. They’re really convincing and will certainly work. Still, the posts are very short for newbies. Could you please extend them a little from next time? Thanks for the post.