HTML5 Build Stripping

Given the recent updates I thought I would rebuild my HTML5 asteroids game to see if I could cut down the build size, load times, etc.

It’s been a year, and I may have messed with the project since then, but…

  • The last HTML5 build I have is 8.05 MB.
  • I rebuilt it as-is, and the build is now 7.63 MB.
  • I switched to a lossless Webp texture profile, the build is now 7.00 MB. (This basically halved the size of my game content!)
  • I used an .appmanifest (from Manifestation) with the settings below, build now 7.10 MB . . .
    • Settings: Record,Profiler,Facebook,Sound,Release,Clang

I thought at least that removing the Facebook module and Sound (I am using howler.js for sound) would reduce the engine size a bit. Am I doing something wrong? Why would it get a tiny bit bigger?


Obviously these sizes are the full game, engine and content. Uncompressed. Here are what the actual files are. I have the audio files bundled as plain resources (.wav) so howler.js can use them. In the version without the appmanifest, ‘Asteroid Blaster.js’ is 5,010 KB.

1 Like

That sure does sound strange. Not really sure to be honest. @sven and @Mathias_Westerdahl?

I tested this with a blank project (first template in launcher) and the same appmanifest settings (Record,Profiler,Facebook,Sound,Release,Clang).

Left is normal release, right is with appmanifest.

Original release zip compressed is 2,020,831 bytes, appmanifest is 1,969,456 bytes zip compressed so there is some difference although it’s weird the wasm file is larger in the version with stuff removed? Only one version of the JS is loaded based on if WASM is supported or not so total size should still be under 1MB for WASM version (880 KB (901,319 bytes)) only and 1.2MB for normal.

1 Like

Yes, weird. @sven might know more.

Looking at the WASM file there appears to be sections in the appmanifest version which are stripped from the normal release version. There are some raw lua files which should probably be obfuscated (which is using random without clearing bad data!). The appmanifest version has some embedded .html files the normal release doesn’t have or at least it is in plaintext in the appmanfiest version. And it looks like the appmanfest version has extra debug stuff the normal release doesn’t have.

2 Likes

Oh, whoops. I’m still running an older version. I should probably make sure that updates before comparing things… :blush: Slow internet…

Thanks for doing the testing. Yeah, I also noticed that “defold_sound.swf” is still there, assuming that has something to do with sound, it should have been stripped out.

[Upd] Yeah, same numbers here (no surprise). If some users only have to load the WebAssembly version, that’s about half the size though, which is pretty awesome!

[Edit2] I believe the facebook module also makes the game fail to load if people are blocking 3rd-party cookies, which is the other part of my motivation to exclude it.

4 Likes

Well, apart from the release issue (@sven has already fixed that, it’s in the next release), there are a few issues with the current manifest. Here’s how it should look for html5 (note the excludeJsLibs):

    js-web:
        context:
            excludeLibs: ["record","vpx","profilerext","sound","tremolo","engine","engine_service","facebookext"]
            excludeJsLibs: ["facebook","facebook_iap","sound"]
            excludeSymbols: ["ProfilerExt","FacebookExt","DefaultSoundDevice","AudioDecoderWav","AudioDecoderStbVorbis","AudioDecoderTremolo"]
            libs: ["engine_release","record_null","sound_null"]
            linkFlags: []

    wasm-web:
        context:
            excludeLibs: ["record","vpx","profilerext","sound","tremolo","engine","engine_service","facebookext"]
            excludeJsLibs: ["facebook","facebook_iap","sound"]
            excludeSymbols: ["ProfilerExt","FacebookExt","DefaultSoundDevice","AudioDecoderWav","AudioDecoderStbVorbis","AudioDecoderTremolo"]
            libs: ["engine_release","record_null","sound_null"]
            linkFlags: []

Now, these changes doesn’t give a huge change: 2044857 -> 1983158 bytes for the wasm file.
The facebook module is really small on web, it just does the graph calls over http.
The sound module is also very small.

A big bulk of the engine is physics, and unfortunately, we include both 2d and 3d physics. But we’ll work on making it possible to exclude either of them.

The lua file embedded in there, is the tracking.lua, which (if you have enabled it) will gather analytics for you to the dash board. We should move that file to the builtins folder, and also make it optional via a setting the game.project file.

I don’t see any other lua files embedded though? I see a ton of strings from potential error messages from the engine. These will be removed sometime in the future, to save even more space.

@britzl, let’s talk about the needed settings for the Manifestation tool tomorrow.

7 Likes

@Mathias_Westerdahl Awesome, thanks! Yeah, that cuts it down a little bit now, my project from 8.70 MB to 8.44 MB.

I tried adding support for specifying either 2d or 3d physics, and it was quite simple, so hopefully, it’ll pass the review, and you’ll get that option next release.
Here are some stats for the empty project, HTML5 bundle:

Before: no app manifest
2044857 Html5_strip.wasm
4511122 Html5_strip_asmjs.js
 357025 Html5_strip_wasm.js

After: No Profile, No Record, No Facebook, No Sound, Release, Physics_2d
1714254 Html5_strip.wasm
3617192 Html5_strip_asmjs.js
 330979 Html5_strip_wasm.js
6 Likes

Yep, let’s talk tomorrow and update the tool!

Yay!

3 Likes