Content packing
How your game is packed into a few archives the player reads straight from memory.
From player v0.9.1, Packmaster, the
GitHub Action and roves bundle don't copy your
build into game/ as thousands of loose files. They pack it into a few archives that the
player opens once at launch and reads straight from memory. You don't change anything in your
game: the page sees exactly the same files, at the same URLs.
What goes where
game/
roves-content.json describes the archives below
code.pack every code file: index.html, JS chunks, CSS, JSON, WebAssembly
root.pack the other files at the root of your build (icons, ...)
assets-images.pack the files of assets/images/ (and its subfolders)
assets.pack the files directly in assets/
sounds.pack ... one archive per folder, by its first two levels
sounds-2.pack a folder bigger than the size limit is split- Code goes into one archive, because the page needs all of it to start.
- Assets are grouped by their first two folder levels (
assets/images/bg/a.pnggoes toassets-images.pack), in path order, so the files of one folder sit next to each other. Each archive is at most 300 MB by default. If one of your folders is calledrootorcode, its archive gets a~2suffix (root~2.pack), so it never mixes with the root files or the code.
Why it is faster
- No extraction, no copy. The player maps the archives into memory and hands your files to the page directly from there. Nothing is unpacked to disk, so the game takes no extra disk space and the first launch is as fast as the next ones.
- Fewer files. A handful of archives open faster than thousands of small files, and antivirus scanners have far less to check.
- Read-ahead. When the game asks for a file, the player loads the next files of the same folder in the background, so the next sprite, sound or background is usually ready before it is needed. After the game starts, the player keeps loading the archives in the background.
On a development PC, reading a file that was never read before took about 5 µs from an archive against 65-90 µs as a loose file; reading it again took under 1 µs.
Compression (optional)
Archives are not compressed by default, which is the fastest option in game. A compression level from 1 to 9 makes the download and the installed game smaller:
- the code archive is decompressed once at launch, behind the Roves startup screen, and kept in memory;
- every other file is decompressed the first time the game reads it and kept in a memory cache (up to 256 MB), so later reads are as fast as without compression;
- images, audio, video, fonts and archives are always stored as they are: they are already compressed, so compressing them again would only cost time.
Use compression when download size matters more than the first read of each file. A visual novel's text-heavy assets compress well; a game made mostly of images and audio gains little.
Settings
| Packmaster | GitHub Action | roves bundle | |
|---|---|---|---|
| Archives or loose files | Advanced → Game content → Layout | content-layout | --content-layout archive|files |
| Compression, 0-9 (default 0) | Advanced → Game content → Compression | compression-level | --compression-level |
| Largest archive (default 300 MB) | Advanced → Game content → Largest archive | max-archive-size | --max-archive-size (e.g. 300MB, 1GiB) |
Loose files (files) copy your build as it is, as before v0.9.1. Use them if you want
players to browse or edit the game's files, or if your build contains symbolic links. With a
player older than v0.9.1 the tools use loose files automatically.
Errors
If an archive is missing or damaged, or roves-content.json was written for a newer player,
the game doesn't start and the error names the file. Re-download or rebuild the package; the
player never falls back to some other copy of your game.
Previous Shell
The Servo-based Shell (releases before v0.9.0) had its own packing, with tar+zstd archives extracted to a cache folder at launch. The current player doesn't extract anything, so there is no content cache to clear.