ResZip: a ready-to-use Lua module and example project on how to use LiveUpdate

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:

16 Likes

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.
12 Likes

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

Yes, I agree that will be a good improvement!

8 Likes

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

6 Likes

Yes!

Also, these

:innocent:

5 Likes

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

New version 1.1.1 is released! Changes:

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

11 Likes

Yet another game where we used the incredible capabilities of Defold’s Live Update is Fish Eat Fish :tropical_fish:, an HTML5 game. @notbadgun mainly developed the game, whereas my task was to optimize the framerate and reduce its size.

Thanks to the Live Update + ResZip, the game’s total size is only 4 MB! After the start, the game downloads the HD version of the graphics (10 MB, look at the “pie” progress bar in the corner) and applies it depending on hardware capabilities:

I’ll share more information about that later, i.e. I need to prepare an example project on how to do that.

13 Likes

up! :slight_smile:

much needed feature!

3 Likes

Version 1.4.0.

In this version, resource saving is done through a new API liveupdate.add_mount. Therefore miniz and other code has been removed.

Current users of the extension only need to update the extension version!

And, still, ResZip includes a custom http downloader with progress unlike the official http.request function (when already?).

9 Likes