Making my game upload and run faster

First my best new year wishes to all of you!

I made a very simple game and put it on itch.io as an html game using the one click option where you zip your file and upload it on itch.
Then I asked friends to test it on itch. As a browser game. No upload. On game PC it takes 10-20s to upload and then it runs fast. On normal new PC it takes 40s-60s to upload and then it run fine almost all the time. The key stroke didn’t work on one of the PC. On old PC it uploads for eternity or it uploads for a long time and then it is very slow.

So I want to know what I should do to make it playable and faster to upload. My purpose is to make a multiplayer browser game later. But right now this simple game is already to slow.

I have 1 big scene and that might be the problem. It is 20000 by 20000 pixels. The background is a 6MB picture that repeats itself 4 times.

I have 4 sound channels that plays constantly with the volume depending on the distance between the player and some objects. It is supposed to be a music festival where the player can wander. The sound files are 10 minutes long on loop and each have approximately a size of 8MB.

I have 4 objects that are fixed pictures.

I have 30-40 instances of NPC that start to move when the player get close to them.

So from all these what do you think is slowing down the game? How can I make it faster?


Hi yoloyolo, haha, you already know the answer:

That’s crazy and surely isn’t necessary. Which of your users is going to benefit from the scene being 20000 x 20000 and having a 6mb background pic? Reduce your scene size and resize your images in an image editor.

This is too much. Compress them with an online mp3 compressor or something similar. I’m sure less than 1mb each would be fine for them.

Why is it crazy? I don’t get it. If I click on a picture on a old PC it uploads instantly. I click on a music file it plays instantly. Why would it be so slow in a game? This picture already looks very blurry in the game.

As for reducing the scene I don’t see how. I am making a game where the player is at a festival and can go where ever he wants.

I had a uniform background color before and it was slow.

So the many instances running around are okay?

You could try a quick experiment and reduce the size of the image file or just compress it in Gimp. But especially if you scaled the file in the Editor, I think Gdevelop calculates the scaling of the image on every tick which would slow the game down. I noticed before that GD struggles with scaling very large image files like that. But so does Gimp on my old computer and that’s a dedicated paint program, not a game engine.

If I scale down a very large image on Gimp it can sometimes take up to 10 seconds to process the operation. And that’s just one image file. So imagine Gdevelop has to scale large images constantly, it will probably cause slow down. That’s what I’m guessing anyway… Since then, I always try to use images with a small file size, while retaining an acceptable quality. Even my background image right now in my current game is 1500 x 1000 px. It has been scaled it down from about double the size in Gimp and I saved the .png with compression level 9, so the file size is only 200k.

Going to note a few things:

  1. Scene size has no limits, and 20000x20000 for a scene size isn’t a huge deal, so long as the assets aren’t an issue.
  2. The maximum image resolution officially supported by the engine is ~2048x2048. Anything larger gives you a warning, ignoring that warning is up to you but doing so is to your own detriment.
  3. 6mb on your hard drive is the compressed image size (jpg, png, etc are image formats involving compression). When rendered via PixiJS, it is the uncompressed size when loaded into ram. For example, a 2000x2000 pixel image, with 32 bits color, is only ~1 to 2 mb on the hard drive, or when viewed scaled in an image editor. When loaded into GPU memory (which is full size and uncompressed) it is roughly 128mb.
    - Either way, a 6mb image is extremely unlikely to be necessary in any form.

Edit: Also, if you mean “upload” as in loading, loading time is always going to depend on your assets as well. Itch.io doesn’t give you bandwidth priority for HTML5 games, and all of your assets are preloaded at the start of the game, so it may depend on how long it takes for your game assets to load into the user’s cache from itch.io’s servers.

In the game the background is only translated. Would it take a lot of computing power? Once the picture is on the screen then it only needs to translate it vertically or horizontally as the player moves.

As a test I show the timedelta and I have 60 frame per sec, the maximum. I haven’t tested it on old computers yet… when I do I will test different sizes for the pictures and music files

So it means that whatever compression I use the size of the background picture used in the game will always be 20k x 20k x 32 bits ?

If you have a 20000x20000 image, yes. Although in 90% of cases it won’t load at all due to Chromium limits.

so the advice above telling me to compress the image is wrong?

I just tested with no background image and it doesn’t speed the process on my old computer. So it’s something else

No, I’m saying there’s multiple things.

  1. Compressed images will help with your overall project size in general, taking up less storage space.
  2. Compressed images will not impact game performance at all because they are rendered uncompressed.
  3. If you’re having issues with slow loading on an HTML5 game, there’s nothing you can do other than:
    1. be on a host that gives you faster bandwidth
      or
    2. Have smaller resources (resolution) and less resources in general.

Otherwise, the more large resources you have, or the more resources you have, will add to the initial loadtime. If you have thousands of files, or hundreds of megabytes of files, initial load time will be long for any online hosted HTML5 game. If you have thousands of files, or massive individual files, game performance may be impacted when running the game (unrelated to initial load).

understood. My main issue is to get the game run faster. The loading time isn’t a big deal for now.

Keep in mind that may be completely unrelated to your asset sizes altogether (although it could be).

You could have optimization issues in your events, or myriad of other things (testing on devices that don’t support WebGL would do it).

Make sure you use the profiler in the debugger to see what is impacting the performance. If the total processing time is under 16ms, then your game is running at 60fps and whatever issues you’re having aren’t game related, but with the systems you’re running it on.

If the profiler is showing a total running over 16ms, find the sections taking up the most time within the individual sections.

thanks. The TimeDelta() is 0.05 on my old computer. Even without the pictures and music.
But it is 0.016 on my new computer. I can’t figure this out so far

Unfortunately, timedelta doesn’t really tell you anything other than time between frames.

You need to use the profiler in the debugger and dig into your actual render time impact.

https://wiki.gdevelop.io/gdevelop5/interface/preview#launch_a_preview_with_the_debugger_and_the_profiler

https://wiki.gdevelop.io/gdevelop5/interface/debugger

If external image downscaling didnt help , check for any event which isnt on “trigger once” and could be potentially memory intensive.

Example: in my game i had an event which would continuously check against against a 100,000 word dictionary variable. It slowed the game down too much because it was always performing the check on every frame. But when i disable it, or just get it to trigger once with a key press or a boolean variable, the game runs fine. You might have events similar to that which are slowing the game down.

1 Like

The profiler runs on my good computer where I have the app. So I can see the time per frame is 4ms, much lower than 16ms. Half is objects pre-events. On a old computer those number might not be proportional. SO how can it help?

Did you also delete the image from the game resources?

I just did an experiment. I created an object and gave it an image. Then I deleted the object. But the image was still in the game resources. I then did a web build and the image was in the game folder. So if your background pic is still in resources, it would still affect loading time (which I realise is not your main priority).

image

yes I took care of that. Thank you.