Skybox missing, text garbled, and lag on mobile, but works fine on desktop?

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. :frowning:

Ok, If I swap the skybox to the Milky Way one, it shows up fine on mobile. I swapped it live during my mobile device running the application, and the new skybox shows up. But swapping back to the space one will make it black again. So something is different or broken with the space one, or something is preventing it from loading correctly. This is making little sense now. :confounded:

EDIT: In the editor, the Space Skybox is somehow 0KB in file size, despite having all the images in the editor. I strongly suspect something got corrupted, though I have no idea how.

The other one that still works is the proper 524KB. I’m going to try recreating a new skybox with the space images to see if a new one will work.

Skybox size is not size of faces.
It is size of prefiltered data file. If size is 0, then you don’t have prefiltered file.

Try re-prefiltering skybox.

How do you prefilter the skybox? The only right click option I get is to delete skyboxes, there isn’t a “reload” option for them. There does not seem to be a button in the editor GUI for it either.

I made a new one from scratch using the same images, and it’s also 0k and has the same problem as the original space one. I’ve tried checking and unchecking the preload option, and also tried changing the filtering settings. Doesn’t seem to make any difference or make the editor do anything.

Select skybox, and at the bottom of your inspector there is a big button “Prefilter”.
It wont allow prefiltering if your skybox is invalid: each face has to be power of two resolution and same sizes.

Once it is prefiltered, it will have size:

Ah, I needed to scroll down. Silly me.

That didn’t seem to fix the problem though. The skybox is still loading as a black skybox on my phone. I can swap between the milky way and the other one, and see the lighting on the models change as appropriate. But the sky itself is still black with the space one.

What is the resolution of faces for skybox that appearing black on mobile?

It’s the default box given to us by branching the starting project. The editor says they are 2048 by 2048 for each panel.

It does seem a little extreme now that I look at it, but that was the resolution given in the original contest file, and it was loading fine a few days ago.

The other skybox is only 512 by 512 for each one.

Both are untouched from the original playcanvas project, besides my mucking around above trying to fix it, of course.

Yes, there is a problem here.
If you go on mobile to here: http://webglreport.com/
You’ll see that Max Cube Map Texture Size will be below that. That what leads to the problem. Your faces for skybox are too large. You can download, resize, upload back.

But really we should think of engine-level solution to resize texture on runtime, to make it working, just will look a bit lower resolution.

There is old ticket for that actually: https://github.com/playcanvas/engine/issues/427

Err, my mobile device says:

Max texture size: 4096
max cube map texture size: 4096

according to the website you linked. That’s well over the 2048 images, I think?

I guess I can try reducing it anyway(there really is no need for such high resolution when 512 or even 1024 looks just fine). But I don’t understand why it’s not loading. It’s the same resolution as the original playcanvas contest project, which shows up on my phone just fine.

Ok, resizing all the images of the skybox to 512 by 512 seems to have fixed the display issue. Now the skybox is showing up again.

I’m going to guess the other lag/control issues mentioned above will clear themselves up once I rewrite the movement to handle dropped frames. Right now the player charging up a jump, boosting, or turning is all framerate dependent. I’ll need to multiply the numbers by the amount of frames passed since last update to correct for it. That should, in theory, result in the same “thrust” and “rotation” being applied even if frames are dropped/skipped by the mobile device.