Recently I reached an important milestone for my game: I asked two friends to play it with me. As usual in this case I tried to fix as many of the remaining bugs I knew so that the app would run reasonably stable. And as it always happens when time is running out, I ran into a problem that totally puzzled me. All of a sudden my app showed a bluescreen (!) on two out of three Android devices – sometimes. Wasn’t that a Windows thing?
Starting a search on the internet I quickly found out that this is a very old problem. Some Unity forum entries dating as far back as 2013 report similar problems in Unity 4.2, while I was running Unity 5.5.
A real bluescreen?
We all know bluescreens from Windows, but I am talking about Android here. Also, I was still able to close the app and return to the home screen, so this was, obviously, no system crash. Fiddling around with the camera settings in my project I found out that the blue color was just the background color of the camera component. Changing this I actually got a red or green screen.
So why was nothing else happening? I am using a “LobbyLoader” scene as startup scene. It contains a camera and one script which proceeds by loading the lobby scene. It looked like this:
public class LobbyLoader : MonoBehaviour { // Load the lobby via Start void Start() { SceneManager.LoadScene("Lobby"); } }
However, the next scene was never loaded. In order to find out what was happening I added an error log output to the Start() method and debugged it with ADB. While the debugger does not catch the error message itself, you can still see that an error message was logged. And that’s what did not happen when the screen stayed blue. Obviously the Start() callback was not called reliably.
This is, of course, a quite annoying problem and something you cannot really do anything about except for some workaround. My solution was to add an OnEnable() callback which does exactly the same as Start(), i.e., loading the Lobby scene.
After struggling through this issue I remembered why I had added the LobbyLoader in the first place. Exactly because I got some weird behavior with my game not starting properly. At least I know now what was the culprit then.