I’ve made a 2D game for android but I’m finding that sometimes when I run the app and some of my sprites will be black. I’m testing on 3 different android phones and one tablet and the issue is sporadic but has been seen on all of them. I’m also running google Admobs within the game for advertising and even they show up as black.
I use a total of 6 sprite sheets, all set to exactly 1024x1024 and the total file size of my sprites folder is 1.77MB. I have texture compression set to ETC1 or RGBA16 on my build settings and building for android 2.3.1 and the issue really is sporadic. I am using no custom shaders, purely Unity’s defaults and have also tried disabling the 32 bit display buffer but still no luck.
Sometimes the game will load absolutely fine and other times it loads with the majority of my sprites black and I’m really lost for why this is happening. I’ve added a screenshot with this too in the hopes that somebody can shed some light on this issue.
Unfortunately I am yet to find a fix for this, however, as you say we may find a solution together and so I’ll give you as much information as I can. So the most important information I’ve found is from the logcat from Adb. I ran the game multiple times and tried to repeat the issue, I found that when the issue is missing the following line is present in the logcat which looks rather ominous.
E/Unity (23092): GLSL compilation failed, no infolog provided
So here’s also what I’ve tried without fixing it:
Disable Anti Aliasing
Using ETC1 / RGBA16 Compression
Making Textures smaller than 1024x1024
Recreating the project from scratch
Upgrading to the latest version of Unity
Set quality settings to fastest
Disabled 32 bit buffer
Disabled Mipmaps for sprites
None of these have solved the issue and it has got to the point now where I had to submit a bug report through Unity as I just don’t know the answer.
Tonight I will work on it, I will try to change everything that could be affecting it. It is interesting though that a friend of mine could run the project on another device, different from mine without the black sprites.
Be aware this may not be quite as you think. The issue for me is very random and will appear fine most of the time and then just one or two times it isn’t. I’m testing on 3 different devices myself and have seen it on all of them at some point with varying levels of how common it is.
In SOME cases this can be due to certain phones not being able to process NPOT (not power of two) textures. In other words, textures that have certain odd pixel dimensions. Specifically the safest (but not practical) thing to do is to make sure that all of your sprites are a POT (power of two), such as 8px by 8px, 32px by 128px, etc. It’s ok to increase transparent space around a PNG in order to achieve the nearest POT value. For example if you have a sprite that is 100px by 400px, just add extra transparent space around it so that the final PNG is 128px by 512px.