My skybox is not rendering on mobile. It used to, but now it’s just black on my mobile phone. At first I thought it must be because I overloaded the track level with props. But in fact my title screen with just the robot, UFO, and the GUI menus is also missing the background textures of the skybox.
https://playcanvas.com/project/375628/overview/robo-racer
If I play the game on the desktop, the background renders just fine, and the game is fully playable at a good frame rate. But if I play on mobile (I have a Samsung Galaxy S4 as my phone), several things are different:
-
The skybox renders as a black background instead of the stars.
-
[fixed] The in game text is often garbled looking, this might be a result of scaling dropping off pixels. Is there a scaling setting that would preserve the text sprites? EDIT: Fixed this by checking device pixel ratio in the scene settings. Now text is clear again.
-
Sometimes the game loads up but a random object will have no texture. The object will just render black during the whole game, even on the track loading scene change.
-
Sometimes the screen width is not detected right, resulting in the game stretching about a third too far off screen on the device. This one is particularly frustrating but seems completely random as well.
The following are from what I assume to be lag, maybe related to the above, maybe from some leaking code somewhere:
-
The controls seem to lag a bit, especally the “hold to jump” charge up. Mobile controls take around twice as long to charge up a full jump. The turning is also nerfed on mobile.
-
The pause menu button ends up just endlessly toggling between “paused” and “resume”. On desktop this seems to work fine when clicked on. If I do some wonky things with multiple fingers, I can “trick” it into staying paused, or interact with the menu while holding the toggling button down.
-
I’m also getting very choppy “frame freezes” every few seconds on my mobile, like the game is constantly having to clean up or flush something in memory. This doesn’t happen on the desktop version. But I have not combed over all my code to optimize it, so there may just be a “new” command hiding somewhere that I have not replaced with the “create in initialize, reuse in update” method.
If I check the profiler, the amount of memory being used is around 330MB, not really that much more then the original starting file provided by PlayCanvas. I checked by using the editor on the original project and pressing control+alt+t on desktop to pull it up. The models provided use quite a bit of graphical memory for a mobile aimed target, but the spinning demo runs smoothly on my phone. I’ve also been careful to not use the meshes for collisions, opting for the built in shaped colliders instead.
My draw calls are hovering around 40 for the title screen and 210 for the track. The draw calls of 210 in game are pushing it maybe a tiny amount over the 200 recommended limit, but it shouldn’t be running this badly if 200 is the recommended limit. Should it? I don’t honestly know because the documentation is very loose/unclear about what can be done on mobile and where the limits lie. I’d assume when the track scene isn’t loaded the game doesn’t have the track in memory anyway, so it has little to do with the skybox problem in any case.
I’m going to try to narrow down the problem today and remove a few no longer used scripts/objects from the game, to see if that fixes anything.
But I would greatly appreciate any advice on what else to check. I doubt this is supposed to be running this awful, and since mobile is the contest target, the fact the game works fine on desktop is useless if my phone can’t play it.