> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ochrebound.ibrahimsultan.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Booting behind the film

> How the wait after the opening film fell from 30.8 seconds to about 3: raw WebAssembly, edge compression, gzip parts the browser inflates itself, and a cache keyed by build.

## The idea

The opening teaser lasts sixty seconds. On a decent connection that is enough time to download and compile almost the whole game, so the loading happens there, while you watch, instead of after it.

```mermaid actions={false} theme={"system"}
%%{init: {'themeVariables': {'fontFamily': 'IBM Plex Sans', 'fontSize': '14px'}, 'flowchart': {'wrappingWidth': 240, 'nodeSpacing': 30, 'rankSpacing': 34}}}%%
flowchart TD
  C["You click Story or Wander"] --> F["The film and the title theme start"]
  F --> W["Meanwhile: the engine streams in and compiles, 14 data parts inflate, giant loops and home films load"]
  W --> B["The golden breath"]
  B --> S["The street, about 3 seconds later"]
```

Before you click, almost nothing is downloaded. Opening the title page is kept under 2 MB, so someone who only came to look pays almost nothing.

## Measured on the live site

Wait after the film ends, before and after this work, with the longest main-thread stall in brackets.

| Tier | Visit | Before | After |
| :- | :- | :- | :- |
| Eco | Cold | 15.3 s (6.1 s stall) | 2.97 s (0.12 s) |
| Eco | Warm | 11.1 s (6.5 s stall) | 3.04 s (0 s) |
| Laptop Cool | Cold | 11.1 s (4.5 s stall) | 2.92 s (0.32 s) |
| Laptop Cool | Warm | 11.1 s (4.7 s stall) | 2.97 s (0.33 s) |
| Painterly High | Cold | 30.8 s (4.9 s stall) | 3.08 s (0.26 s) |
| Painterly High | Warm | 11.1 s (5.4 s stall) | 3.00 s (0.30 s) |

## What changed

**1. Ship the engine raw and let the edge compress it**

The build writes its `.wasm` uncompressed. Cloudflare's edge encodes it on the way out, with zstd for Chrome and brotli for other browsers. Measured live: 22.4 MB raw, 8.0 MB with zstd, 7.9 MB with brotli. Pre-compressing it would have been worse: the edge was measured re-encoding files that were already compressed.

**2. Compile while downloading**

The page compiles the engine with `WebAssembly.compileStreaming`, so compilation starts with the first bytes rather than after the last, and hands the result to Unity's loader. Browsers that cannot stream fall back to compiling a buffered copy.

**3. Split the data and let the browser inflate it**

The game's packed content is about 370 MB raw. It ships as 14 gzip parts, each at most 24 MiB to stay under Cloudflare's 25 MiB per-file limit, named by content hash. The browser's own `DecompressionStream` inflates them, so no JavaScript decompressor ever blocks the main thread.

**4. Cache by build, not by luck**

Unity's own IndexedDB cache is switched off. The page keeps the parts in Cache Storage under the build's hash, and every file under `/Build/` is served as immutable for a year. A returning visitor downloads nothing that has not changed.

**5. Make the engine smaller**

Link-time optimisation for disk size, size-optimised IL2CPP code generation, high managed stripping (with the game's own assemblies kept whole, because the page calls them by name), engine code stripping and no debug symbols took the engine from 44.6 MB to 22.4 MB with no measured loss in frame time.

## The build settings, enforced in code

The release build sets every one of these itself, so a stray click in the editor cannot regress a release.

| Setting | Value | Why |
| :- | :- | :- |
| Compression format | Disabled | The edge and the gzip parts do it better |
| Decompression fallback | Off | Nothing decompresses on the main thread |
| Data caching | Off | The page caches parts itself, by build hash |
| Name files as hashes | On | Year-long immutable caching for `/Build/` |
| WebAssembly 2023 | On | Native exceptions; Chrome 91+, Firefox 89+, Safari 16.4+ |
| Code optimisation | Disk size with LTO | 44.6 MB to 22.4 MB |
| IL2CPP code generation | Optimise size | Smaller binary |
| Managed stripping | High | With a `link.xml` that keeps page-called assemblies |
| Debug symbols | Off | Not shipped |
| Memory | 256 MB initial, 4096 MB ceiling, geometric growth | A low floor with room to grow |

## The film itself

The opening film is remuxed into separate fragmented video and audio streams for Media Source Extensions, with packet counts checked at build time. Safari, or any browser without Media Source Extensions, falls back to playing the original MP4 directly.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.