# Platform Rules and Budgets

The sandbox Glint games run in, how a build ZIP must be laid out, the size and file budgets, automatic Brotli repackaging, and everything the validator and Glint check.

Glint runs every game in a strict, offline sandbox and checks each build before it goes live. This page lists the rules a build has to follow, the budgets the `glint validate` command and Glint enforce, and what Glint does to a build when you upload it.

## Where Games Run

| Host | What it serves |
| --- | --- |
| `https://glint.joinfoundry.xyz` | The Glint store, game pages, Glint Studio and the player that frames your game. |
| `https://games.joinfoundry.xyz` | Your game's files, inside that frame. |

A build is served from a path like `/<slug>/b/<hash>/index.html`, or `/<slug>/x/<hash>/index.html` for games in [advanced mode](#advanced-mode-for-threads). Glint talks to your game through the SDK over a private message channel, so your game never needs its own network access.

## Zero-Network Sandbox

### Content Security Policy

Every file Glint serves for a game carries this policy, plus a `frame-ancestors` rule naming the Glint page that launched it:

```text
default-src 'self' data: blob:; script-src 'self' 'unsafe-inline' 'unsafe-eval' blob:; worker-src blob:; connect-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; media-src 'self' data: blob:; object-src 'none'; base-uri 'self'; form-action 'none'
```

What that means for your game:

- Scripts, styles, fonts, images, audio, video and data load only from your own build (or `data:` and `blob:` URLs). Bundle every library, font, texture, shader and sound into the ZIP.
- `fetch`, XHR and WebSocket connections reach only your own build's files. CDNs, Google Fonts, analytics, ad scripts and external APIs are all blocked.
- Online play goes through `sdk.multiplayer`. Don't open `new WebSocket()`, `new RTCPeerConnection()` or `new EventSource()` yourself.
- Forms can't submit anywhere.

The Local Emulator (`glint preview`) serves your build with the same policy, so you see these failures before you upload.

### Frame Permissions

The game's frame is sandboxed with `allow-scripts allow-same-origin allow-pointer-lock` and may use `fullscreen`, `gamepad` and `autoplay`. Games in advanced mode also get `cross-origin-isolated`. Because modals and popups aren't allowed, `alert()`, `confirm()`, `prompt()` and `window.open()` don't work. Show your own in-game UI instead.

### Shared Origin and Browser Storage

All games share the `games.joinfoundry.xyz` origin, so `localStorage` and IndexedDB are readable by every other game. Keep progress in `sdk.saves`, which stores up to 4 slots per player per game on Glint's servers and follows the player across devices. See [Saves](https://joinfoundry.xyz/help/developers/glint-sdk-api#saves).

## ZIP Layout

- `index.html` sits at the top level of the ZIP, not inside a folder. It is the only entry page Glint accepts.
- `glint.json` sits next to it. Glint accepts a build without one, but the validator warns and Glint then has no manifest for the game. See the [Manifest Reference](https://joinfoundry.xyz/help/developers/glint-sdk-manifest).
- Every file name is unique ignoring capital letters. `Logo.png` and `logo.png` can't both be in a build.
- Entries use standard ZIP compression (stored or deflate). Encrypted entries and symbolic links are rejected.
- Leave out OS junk (`.DS_Store`, `__MACOSX/`, `Thumbs.db`, `._` files) and source maps (`.map`). Glint ignores the junk, but the validator warns about both.
- Every file has a [supported file type](#supported-file-types).

## Relative Paths

Because the build lives under `/<slug>/b/<hash>/`, a root-absolute path like `src="/assets/hero.png"` points outside your game and fails. Use relative paths everywhere:

```html
<script src="./glint.js"></script>
<img src="./assets/hero.png" alt="" />
```

With Vite, set `base: "./"` in `vite.config.ts`. Other bundlers have an equivalent setting (often `publicPath`).

## Supported File Types

A build may contain only these extensions:

| Kind | Extensions |
| --- | --- |
| Pages, code and data | `html`, `htm`, `js`, `mjs`, `css`, `json`, `wasm`, `txt`, `md`, `xml`, `csv`, `yaml`, `yml`, `ini`, `cfg`, `map` |
| Images and textures | `png`, `jpg`, `jpeg`, `webp`, `avif`, `gif`, `svg`, `ico`, `ktx2`, `ktx`, `basis`, `hdr` |
| Audio and video | `mp3`, `ogg`, `wav`, `m4a`, `flac`, `mp4`, `webm` |
| Fonts | `woff`, `woff2`, `ttf`, `otf`, `fnt` |
| 3D and shaders | `glb`, `gltf`, `obj`, `mtl`, `drc`, `glsl`, `vert`, `frag`, `wgsl` |
| Engine and level data | `data`, `bin`, `pck`, `unityweb`, `atlas`, `plist`, `tmx`, `tsx`, `tmj` |

Any of these can also be pre-compressed with a `.br` or `.gz` suffix, like Unity's `game.wasm.br`. Glint serves those as stored, with the matching `Content-Encoding`. Files without an extension, and anything else (`.ts`, `.psd`, `.blend`, `.exe`), are rejected.

## Budgets

### Build Budgets

| Budget | Limit | Checked by |
| --- | --- | --- |
| Initial boot payload for the Loads Fast badge | 2 MB compressed | The validator's estimate. Glint decides the badge itself on upload; see [Loads Fast and Performance Score](#loads-fast-and-performance-score). |
| Initial boot payload, recommended | 1.6 MB compressed | The validator warns above this ([GL006](https://joinfoundry.xyz/help/developers/glint-sdk-cli#gl006)). |
| Initial boot payload, hard cap | 30 MB compressed | The validator fails the build above this ([GL006](https://joinfoundry.xyz/help/developers/glint-sdk-cli#gl006)). |
| Total build | 500 MB compressed | Validator ([GL007](https://joinfoundry.xyz/help/developers/glint-sdk-cli#gl007)) |
| Any single file | 30 MB | Validator ([GL008](https://joinfoundry.xyz/help/developers/glint-sdk-cli#gl008)) |
| Number of files | 10,000 | Validator ([GL009](https://joinfoundry.xyz/help/developers/glint-sdk-cli#gl009)) |
| Uploaded ZIP | 500 MB | Glint |
| Unzipped build | 500 MB and 10,000 files | Glint |
| `glint.json` | 64 KB | Glint |
| Call `sdk.lifecycle.ready()` | Within 15 seconds | Glint reveals the game after 15 seconds even if `ready()` never comes. |

The initial boot payload is what a player downloads before the first screen: `index.html`, every `.wasm`, `.pck` and `.unityweb` file, and the `.js`, `.mjs`, `.css`, `.json` and `.data` files at the top level or one folder down. For a ZIP, the validator uses each file's compressed size. For a folder, it estimates the Brotli size of files up to 2 MB and assumes larger WASM files shrink to 35% and other large files to 65%. Already-compressed media (PNG, JPEG, WebP, AVIF, GIF, MP3, OGG, M4A, MP4, WebM, WOFF2) count at full size.

### Runtime Budgets

| Feature | Limit |
| --- | --- |
| Cloud saves | 4 slots per player per game, 1 MB in total across slots |
| Save slot names | 1 to 32 letters, digits, hyphens or underscores |
| Achievements | Up to 100 per game, defined in Glint Studio |
| Leaderboards | Up to 20 per game, defined in Glint Studio |
| Room players | 2 to 16 active players |
| Room spectators | Up to 32 |
| Room messages | 20 per second per player, 4 KB each |
| Room state | 64 KB shared, 8 KB per player |
| Reconnect grace | 30 seconds before a dropped player leaves the room |
| Host away | 10 seconds with the host's tab hidden before the host moves |

The details of each are in the [JavaScript API Reference](https://joinfoundry.xyz/help/developers/glint-sdk-api).

## Uncompressed Export and Brotli Repackaging

Export your game uncompressed: no Brotli or Gzip build options in your engine, no `.br` or `.gz` files. Zip the export with standard ZIP compression. After the build passes inspection, Glint repackages it once:

- It strips OS junk files.
- It pre-compresses code, data and text files of at least 1 KB with Brotli: `js`, `mjs`, `css`, `json`, `wasm`, `svg`, `data`, `bin`, `pck`, `unityweb`, `map`, `xml`, `csv`, `glb`, `gltf`, `txt`, `ttf`, `otf` and the shader, level and config formats above. Text and code files up to 2 MB use quality 11 and larger ones quality 6. Binary files up to 256 KB use quality 9 and larger ones, such as big `.glb` or `.wasm` files, quality 5.
- It keeps a compressed copy only when it saves at least 5% and at least 256 bytes.
- It leaves your entry `index.html` uncompressed, so Glint can add its small bridge script to the page.
- It skips media that is already compressed (PNG, JPEG, WebP, AVIF, GIF, MP3, OGG, M4A, MP4, WebM, WOFF2) and any `.br` or `.gz` file, so nothing is compressed twice.
- ZIPs over 128 MB keep their original packaging.

Glint Studio shows how many files were compressed and how much space that saved. Files under the build path are cached by browsers for a year, so a returning player downloads nothing again.

## Loads Fast and Performance Score

The CLI validator and Glint's upload server both evaluate **Loads Fast** and **Performance Score** using your build's [initial boot payload](#build-budgets). Lazy-loaded assets in deeper folders do not count against it.

| | `glint validate` | Glint, on upload |
| --- | --- | --- |
| Loads Fast | No errors, and an estimated initial boot payload of 2 MB or less. | Initial boot payload of 2 MB or less compressed, and no `.wav` or `.bmp` files over 256 KB. |
| Performance Score starts at 100 | Minus 20 per error and 5 per warning; minus 15 if initial boot is over 1.6 MB; minus 5 for more than 500 files. | Minus 15 if initial boot is over 1.6 MB, or 25 if over 30 MB; minus 5 for more than 500 files; minus 5 per `.wav` or `.bmp` file over 256 KB, up to 20. |

Glint's result is the one players see: a game with the badge shows **Loads Fast** on its page, and Glint Studio shows the badge and score for the live build. Use standard ZIP compression rather than storing files uncompressed in the ZIP.

## Built-In Room Text and Voice Chat

When `multiplayer.online.enabled` is `true` in `glint.json`, Glint shows a sidebar beside the game frame with the room, text chat and voice chat. Players can collapse it. You don't need to build chat or voice into your game. Make sure your canvas and UI resize to fill the frame whenever players open or collapse the sidebar.

## Advanced Mode for Threads

Games that need `SharedArrayBuffer` or multithreaded WebAssembly set `"capabilities": { "threads": true }` in `glint.json`. Glint then serves the game with `Cross-Origin-Opener-Policy: same-origin` and `Cross-Origin-Embedder-Policy: require-corp`, and the game always opens full screen. Many browsers and devices handle single-threaded builds better, so leave `threads` off unless the game needs it. The validator fails a build that uses `SharedArrayBuffer` or `Atomics.wait` without the flag, and warns when the flag is on but nothing uses it ([GL012](https://joinfoundry.xyz/help/developers/glint-sdk-cli#gl012)).

For a game that hasn't been published yet, Glint takes the advanced setting from the manifest of each uploaded build. After publishing, change it in Glint Studio.

## Runtime Behavior Glint Expects

- **Start the SDK and call `ready()`.** Call `Glint.init()` once at startup, report `sdk.lifecycle.loadingProgress(0..1)` while you load, and call `sdk.lifecycle.ready()` when the first screen is interactive, without waiting for input. Glint shows its loading bar with your progress until then.
- **Stop on pause.** When `sdk.lifecycle.onPause` fires, stop `requestAnimationFrame`, physics and audio at once. Start again on `onResume`. When a demo or a player's free hours run out, Glint pauses the game and removes it about 1.2 seconds later, so pending saves have time to flush.
- **Follow master mute.** Read `sdk.system.isMuted()` at startup and subscribe to `sdk.system.onMuteChange()`. Glint's player bar has the mute button.
- **Fill the frame.** Size the game to 100% of the frame with `overflow: hidden`, handle resizes without reloading (a `ResizeObserver` works well), and clamp canvas resolution to `Math.min(2, sdk.system.getHints().maxDpr)`.
- **Keep focus in the frame.** Glint counts play time only while the tab is visible, the game's frame has focus and the player gave input in the last 60 seconds.
- **No popups or modals.** Use in-game UI instead of `alert()`, `confirm()`, `prompt()` or `window.open()`.

## What the Validator Checks

`glint validate` reads a folder or ZIP without running it. It checks the layout, file types and budgets above, and scans HTML, JS, MJS and CSS files up to 4 MB for external URLs, direct sockets, root-absolute paths, `SharedArrayBuffer`, SDK use, host migration, `localStorage` and uncapped `devicePixelRatio`. Each finding has a code. The full list, with fixes, is in [Error and Warning Codes](https://joinfoundry.xyz/help/developers/glint-sdk-cli#error-and-warning-codes).

## What Glint Checks on Upload

When you upload a build from the CLI or Glint Studio, Glint inspects the files and runs Package X-Ray, then checks the ZIP itself: `index.html` at the top level, supported file types only, standard compression, no encrypted files or links, no names that clash ignoring capitals, and the 500 MB and 10,000 file limits. It also rejects any file over 1 MB that expands to more than 1,000 times its compressed size. Package X-Ray treats minified production bundles from Vite, Rollup, esbuild, Three.js, Unity, Godot and `glint.js` as normal packaging and doesn't flag them as obfuscated. It ignores URLs in code comments and Foundry's `$schema` URLs. If `glint.json` is present, it must be valid; Glint is stricter than the validator and rejects unknown fields at every level. A build that fails shows the reason in Glint Studio, and the current build keeps playing. See [Upload a Build](https://joinfoundry.xyz/help/glint/upload-a-build).
