Use Live Update to improve load speed of HTML5 game

#1

Our publisher asked us to improve the loading time of our game. Their dev has a good talk about its importance for players who run your game for the first time.

Defold packs all the game resources into a large package for the HTML5 platform, and all these files have to be downloaded before startup.

Defold has the Live Update feature, which we can use to split resources into two parts: all resources required for the first level of your game plus the rest of resources. The game can load these resources in the background (and from the same folder) while players are playing the first level.

I made an example project that loads resources from a .zip file using Live Update, and you can use it as a Defold library dependency:

In this project, the demo game loads the level 2 plus required resources from an external .zip file when you tap anywhere on it. I recommend you start loading these extra resources right after your game’s initialisation.

How it looks when implemented in a game:

13 Likes

#2

Now, about the issues that I faced while implementing this feature.

I didn’t manage to use the resource.store_archive() function as is. It loads the whole ZIP archive at once, but it also requires a manifest, and the new manifest requires a full restart of the game.

That’s why the demo project calls resource.store_resource() just to load resources without a manifest. Moreover, it extracts these resources from a single large ZIP file to avoid slow downloading hundreds of files one by one (I had to use the Miniz library for that).

Another issue is Live Update’s temporary storage of resources in .arcd/.arci files (in IndexedDB). The demo project deletes these files before the start of the game to handle the upgrade of the game. Otherwise, new resources can have the same filenames but different content. The collectionproxy.missing_resources doesn’t know about that, and it loads only new missing resources. The result of this total mess: returning players will not be able to play the game, i.e. it will crash.

To sum up, I would like:

  1. To use resource.store_archive() to load missing resources from a .zip file and without the new manifest plus without the restart of the game.
  2. To be able to disable Live Update’s temporary storage. This case doesn’t need it because a browser already caches all games files, and the game doesn’t use Live Update to upgrade itself.
  3. To easily test an HTML5 debug build from IDE without pre-publishing Live Update content (https://github.com/defold/defold/issues/5593)
  4. To set the output name of Live Update’s .zip file. Also, bob.jar could put it in the bundle output folder.
10 Likes

#3

Thanks a lot @aglitchman for sharing this very amazing and useful extenstion / project!

Finally we can use the functional of Live Update more often.

@Mathias_Westerdahl this is what I meant when I said download files locally in my recent thread (“downloading from local directory of HTML5 build”). :slight_smile:

7 Likes

#4

Yes, I agree that will be a good improvement!

8 Likes

#5

This right? https://github.com/defold/defold/issues/5593

6 Likes

#6

Yes!

Also, these

:innocent:

5 Likes

#7

Also, I didn’t find it by searching the forum, I don’t know if this feature was discussed earlier, but will be nice to have the opportunity to see the progress of the downloading resources via Live Update.

5 Likes

#8

New version 1.1.1 is released! Changes:

Also, I updated the demo to show how to handle downloading progress of the .zip file.

8 Likes