Ive recently hit a bug that causes a black screen of death on android builds (Any and all scenes except the intro). PC versions are fine. Since the mobile version isnt working, Ive built 2 linux versions. One of the old fully working working version and one of the newer version to profile. Both come out almost exactly the same.
Im new to profiling, but this tells me Im not necessarily facing a CPU/memory issue. Unless the two builds might be completely different built to android? Would an android build use more/less RAM then a PC version? In the older android build theres a pause when the main menu first loads, but only the first time. When returning from a level or another menu, all is good. Could be to do with loading assets/garbage collection?
Should also mention my test device has 1gb RAM, so Im also wondering why my game ever worked at all?
The only difference between the PC and android builds is the android version has android-specific directives to make use of the touch buttons and a setting in the options screen to change their position on screen.
Building for android Ive tried making a ‘transition’ screen mentioned here about halfway down, as well as using Resources.UnloadUnusedAssets from the same post. Ive re-arranged my starting scenes, Ive disabled music and my games loading system, compressed all my textures. Last thing I tried was using the old versions scripts in the newer version (So the only difference is the option to change touch-button position and scrolling the menu doesnt work).
Ive added images of snapshots from both versions, the pre-touch being the older version. At the moment Im trying to figure out what caused the pause, as I think that might be the problem thats simply gotten worse, although the profiler shows pretty much the same details on entering any scene from both versions. Is unity loading ALL assets at once when entering main menu? Not sure.
Any ideas/opinions more then welcome. My projects pretty well dead in the water until I can figure this out.
This might be a stupid question but why are you not profiling the Android build? If you do a Build&Run with auto connection profiler on, the console would also show any error logs from your device. Have you checked the Player logs from the device?
If the system buttons is the key difference, maybe there is something wrong with that code and it causes an exception or endless loop, maybe due to double subscriptions to events or something? The CPU Profiler, Console window and Player logs could at least give some indication of what happens as it flips over to the black screen. Does the profiler stop showing new data, do no new logs appear that you’d expect (and does the music stop if you have some running)? If yes it’s likely an endless loop, if no, maybe an exception, and then you should have captured it in the console or Player log and also in the Profiler, where you could search for where the exception got logged and in Timeline view could maybe even see the chronological events leading up to it and what else happened after it.
Since the app doesn’t crash and close, it does not seem like you are running/crashing out of memory.
If you’re saying that because your committed memory amounts on Linux are above 1GB:
You can have more memory committed than RAM on the device. You can’t have more resident memory than RAM (+ if present VRAM, also depending on how much of the resident memory is graphics memory obvs.) And your resident memory amount is absolutely on the clear of that 1GB.
Texture compression, platform dependent quality settings and a whole bunch of other factors mean that the memory usage can be quite different between platforms.
Hey thanks for the reply!
I spent the morning playing with logcat and the profiler on both versions, linux and android. What I discovered is I actually had 2 issues. Ones now solved, one isnt.
My game is using less then 1/2 the memory on the phone, so no worry there. An overlooked import setting on a music track caused the initial pausing on both OS, solved.
The black screen though, only happens when the game is installed on the phone via APK or google play. When I install via ‘build and run’ everythings fine. What could the difference be there?
So Ive been playing with profiling a dev build on the phone. The build and run build shows the expected spike when loading the next scene, whereas the APK build has a smaller spike. The profiler also shows different information for both builds. Either way, the profiler tells me we’re way under max RAM. Seems like something is stopping the menu being loaded unless built directly from unity.
Yep. When installed from APK or google play, assets are not being loaded. Feel silly it took me this long to look here. Anyway, Ive added images of file access and asset loading from the APK and build and run.
Hmm is the Menu scene added to the scenes to be build?
You could also check the Build Report for both builds if there is a difference, e.g. with this package. Since it’s a preview package you’ll likely have to install it via “add by name” in the package manager or by modifying the Packages/manifest.json file
Yes all scenes are in build settings. Ive just been playing around with the build reporter (Neat asset, thanks) but there doesnt seem to be any difference. All my assets are in the builds :-/
Ok no worries.
Ive been re-arranging my scenes and it happens when loading the second scene, no matter what the 1st is. In case you think of something
Thank you for your time
Well, after a day of slowly updating a copy of the old version, bit by bit, paste by paste… No problems whatsoever. Unsolved mystery of the big bad bug.