Whitepaper · October 2026 · coming soon

Margo Engine

A WebGPU engine for the web. Core plus stage is 24,837 bytes gzipped. The catalog lists 107 packages (none published to npm yet), with one install that holds them all. Every number we publish names its source.

24,837 Bcore + stage, min + gzip, Wasm kernel and WebGPU backend included; the build fails a change at 25,000entry-sizes.json · 0e71a9024
107packages in the catalog, all reachable from npm i margoengine (none published to npm yet)docs/catalog.json
6,498Node tests in every npm run verify: 6,496 pass, 2 skipped, 0 failresults/test-count.json · 01836c27
153 of 161feature rows with an equivalent Margo package; 4 partial, 4 missingdocs/three-parity-matrix.md · bec8b597

Where it stands today

  • Coming soon. The packages are not on npm yet, and the source repository stays private while we finish the launch checklist.
  • WebGPU only, for now. About 88% of browsers in use support WebGPU: 85.8% fully and 2.02% partly (caniuse.com/webgpu, StatCounter data for September 2026). A fuller WebGL2 compatibility package is in development as an optional download that WebGPU users never load. Today the basic WebGL2 package draws core meshes, and the React Canvas takes loadFallback and fallbackContent.
  • Few browsers verified. Real-GPU results come from Edge and Chrome on Windows 11 (NVIDIA, Intel and AMD GPUs) and from Chromium on one Linux machine with an Intel GPU, where three suites have not finished (section 10). Firefox, Safari, macOS and phones are not verified yet.
  • No speed claims against other engines. The same-scene comparison tool exists, but no quiet-machine run has been made. The numbers on this page are our own internal measurements, and each names its hardware.

0Abstract

Margo Engine is a 3D engine for web applications, written in TypeScript. It has a Rust kernel compiled to WebAssembly and a WebGPU renderer. Core plus the high-level stage (createStage) measures 61,048 bytes minified and 24,837 bytes gzipped. The build fails at 25,000.

Everything else lives in optional, side-effect-free packages: glTF PBR, shadows, post-processing, physics, voxel worlds with multiplayer, a path tracer, exporters and React. A bundle contains only the packages it imports, and large runtimes load only when a file needs them.

This paper covers the design, what we have measured, how the engine was built, and the limits we know about. Each figure names the file it came from. Where we have no committed measurement, we say so. A companion paper covers Margo Voxel.

import {createStage} from 'margoengine';
const app = await createStage('#scene');
const orb = app.sphere({color: '#84d6bd', roughness: 0.25});
app.onTick(delta => {orb.rotation.z += delta;});
window.addEventListener('pagehide', () => app.dispose(), {once: true});

1One install, kits and starters

npm i margoengine installs the whole engine. Its root is the stage, and every entry of every package is margoengine/<package>, one export * line each, so an app still bundles only what it imports. A test checks that the alias and the package bundle to the same bytes.

A kit is one import line with what an app of one kind usually needs:

KitForEvery name used, min + gzip
margoengine/gamemodels, animation, light and shadow, sky, physics, audio, input, effects307,012 B
margoengine/vizfigures and GPU compute, points, lines, splats, terrain, labels and text277,396 B
margoengine/weba glTF model, studio light, orbit, HTML on top155,058 B
docs/guides/kits.md · bd8e5a69 · tests/umbrella.test.js re-measures on every run and fails on a 3% move

An app that uses part of a kit pays only for that part. npm create margo has five starters: web, game, viz, react and next. Each opens to a lit, animated scene with three things to try. Time from create to first frame under vite dev in Edge, with the packages linked (no install), one run each on the RTX A6000 PC:

StarterWhat it showsFirst frame
weba studio scene with shadows and a turntable788 ms
reactshapes in sun with soft shadows and bloom835 ms
viza 300,000-point galaxy with bloom and labels968 ms
gamea character who walks and runs, physics crates, orbs to collect1,308 ms
examples/package-benchmarks/results/starters-first-frame.json · tools/create-margo/test/browser-check.mjs · 8cc9e939 · the next starter is type-checked, not timed

2Design decisions

  1. A small core that stays small. New capability goes into optional packages through the extension hooks in section 4. CI rejects any change that pushes core + stage to 25,000 bytes gzip. Multiple views and scenes were the one approved exception: 867 bytes gzip with the kernel changes that came with them (section 4).
  2. Data-oriented transforms in Wasm. Positions, rotations, hierarchy, world matrices, bounds and culling live in flat typed arrays in Wasm memory, computed by one Rust function per frame.
  3. WebGPU first, guaranteed limits only. The device asks for no limit above WebGPU's guaranteed minimums, so a scene asks nothing of the GPU that a phone is allowed to refuse.
  4. Errors that name the fix. Packages throw a MargoError with a code, a TypeError or a RangeError, and the message says how to get past it: RangeError: Too many glTF nodes (100001 > 100000; raise the maxNodes option).
  5. No number without a source. Every published figure has a row in a claims inventory with its evidence and status (section 9).

3The kernel

packages/kernel/src/lib.rs is no_std Rust compiled to Wasm. Each entity is a slot in a structure of arrays: position, rotation and scale, parent, local and world bounding spheres, world matrix, joint limits, last frame's inputs and scratch space. JavaScript writes transforms into views of that memory; nothing crosses the boundary per entity.

The tick follows three rules:

Node, the same Wasm the browser loads, a fake renderer, and an assembly grown from 1,024 slots. Quiet-gated (CPU at 8%), AC power:

EntitiesKernel memoryTick, staticTick, 1% movingFull recompute
100,00644.9 MB3.3 ms4.5 ms14.4 ms
499,992176.6 MB20.2 ms26.2 ms74.9 ms
1,000,012352.1 MB41.5 ms43.4 ms138 ms
examples/package-benchmarks/parts/results-scale-node.json · scale-node.mjs · Intel Core Ultra 7 258V

The cost is linear. A test checks that dirty propagation produces the same world matrices and visibility, bit for bit, as a fresh full recompute, through growth to 1,048,576 slots, 63-deep chains, moves, removals and slot reuse.

4The renderer, views and hooks

One frame. The shaded steps are the two that do the heavy lifting.

Core groups visible meshes by geometry and draws each group with one instanced call, with per-instance material values. When nothing changed, it reuses last frame's instance lists and uploads only the matrices that moved. A group of single-sided, unmirrored instances draws with hardware back-face culling and no discard, which keeps early depth testing on. The renderer uses reversed float depth and GPU picking with integer ids, and it recovers from device loss.

Multiple views and scenes

One engine draws several views of one scene in a frame: split screen, the four-view layout, picture-in-picture, a minimap. It also draws separate scenes: a HUD with its own objects and lighting, an item preview in a menu, a portal rendered to a texture. Effects with history keep it per view, and every package is view-aware. This is in core, as an approved exception to the size freeze. It added 867 bytes gzip to core + stage, because a smaller kernel paid for most of the 2.7 KB of new code. npm run check:views draws views on a real GPU and checks pixels, picks and validation errors in every merge.

docs/multi-view-roadmap.md · 0ca52f2a · entry-sizes.json · 51d8786a

Extension points

Passes
EnginePlugin frame-graph passes. Shadows, post effects, TAA and GPU culling attach with X.attach(engine, options).
Shader hooks
Packages patch core's WGSL at named points; shader-contract tests fail when a patch no longer matches the text it expects.
Batch redirect
A pass may set batch.redirect = {instances, args}; core then draws that batch from the package's records with drawIndexedIndirect. This lets GPU culling run on ordinary core meshes.
Raw state
Wasm memory and GPU objects are reachable only through @margoengine/core/extension, so the public API stays portable.

5Size

Sizes are minified and gzipped at zlib defaults, per exports entry, with peers and other Margo packages external. Core + stage includes the embedded Wasm kernel and the WebGPU backend, and gives you a mesh, one directional light, orbit controls and the loader shell.

EntryRawGzipNotes
@margoengine/core53,18522,220Wasm kernel, WebGPU renderer, views and scenes
core + stage61,04824,837the build-gated figure
examples/package-benchmarks/results/entry-sizes.json · record 0e71a9024 · dirty: false · npm run measure:size on main at 38ce7fbaa, 2026-11-12

Every other entry and worker, and every lazily loaded file, is in the same record and on margoengine.com/sizes. A release test builds a page that calls createStage and loads a small glTF, records every request in headless Edge, and fails if the page fetches anything beyond the HTML, its chunks and the model (examples/package-benchmarks/results/basic-scene-network.json).

We do not call Margo the smallest engine. We publish our method and our numbers. A size comparison with other engines will be run with the same build settings from the folder where those engines live (npm run bench -- size --engines=all), and published with its method when it has been run.

6What is in the box

AreaWhat exists todaySource
RenderingglTF 2.0 metallic-roughness PBR, image-based lighting, cascaded shadows, clustered point, spot and area lights, order-independent transparency, LOD, GPU culling, textpackage READMEs
Postbloom, SSAO, GTAO, SSGI, SSR, motion blur, tone mapping, depth of field, TAApackages/post, dof, tonemap, taa
Voxelschunked worlds, meshing, lighting, streaming; multiplayer: one server process keeps 20 ticks per second for 900 players spread over a map or 350 crowded in one spot (AMD Ryzen 9 9950X)docs/voxel-net-capacity-2026-10-21.md · voxel-net/bench/results.json
Path tracinga progressive WebGPU path tracer for voxel models, through the engine camerapackages/voxel-pathtracer · voxel whitepaper
ExportglTF 2.0 / GLB, STL, OBJ with MTL, PLY, static USDZ and COLLADA 1.4.1packages/exporters/README.md
FrameworksReact 18 and 19 components, and a Next.js starterpackages/react · tools/create-margo
SimulationRapier physics, navigation meshes, ECS, state machines, networkingpackage READMEs

Of the feature list this page counts, 153 of 161 rows have a Margo package, 4 are partial and 4 are missing. The API is Margo's own.

docs/three-parity-matrix.md · bec8b597

7Internal measurements

These are measurements of Margo against earlier Margo, on named hardware. They are not comparisons with other engines. The method: headless Edge with vsync and the frame cap off, WebGPU timestamp queries on every pass, a GPU lock so only one GPU job runs at a time, and a quiet-machine gate. Our benchmark tool, npm run bench, now runs every such measurement this way.

Large scenes

FloatingOrigin keeps a 10 mm part at 0.019 px of jitter up to 6,000 km from the origin, where float32 alone stops drawing it (results/large-coordinates-gpu.json).

8How it was built

Margo is built by one person directing several AI coding systems through an external Agent Factory. Scott Campbell sets the goals and product rules. Factory owns routing, work isolation, review, commits, integration, publication, machine scheduling and durable history outside this repository. Nobody should trust the engine because of who or what wrote it. The checks below are what make it trustworthy, and section 10 shows what they caught in three days, including our own mistakes.

We describe the method because it is how the engine was made. AI does not make the engine better by itself. The evidence for the engine is the same as for any engine: the tests, the measurements and the code.

9Keeping the numbers honest

Tests and checks

A claims inventory

docs/whitepaper/claims.md lists every claim the public docs make or imply, with its evidence and a status. A claim is PROVEN only when a committed script and a committed result support its exact wording. The audit that built it corrected or removed every claim that overstated its evidence.

The words we do not use, and why:

10What our checks caught, and what we got wrong

From 2026-10-26 to 10-28 the engine ran on more machines than before: an AMD Radeon 680M mini PC (Windows, Edge and Chrome), a small Ubuntu server with an Intel UHD GPU (Chromium on Mesa's Vulkan driver), a second laptop for an outside audit, and Node 22 beside Node 24 and 26. Most of what broke was in our maths, our tests or our machines, and several first explanations were wrong. Each item names its fix commit and regression test; the full entries, with every number's source and the rerun commands, are entries 37 to 44 of docs/whitepaper/perf-history.md.

GPU compilers rewrote our precise maths

On the Radeon 680M, preciseLog1p(5.963922e-8) was 8,383,741 units in the last place (ulp) off, against a bound of 2; on the Intel UHD with Mesa, 14 of the 17 precise functions were out of bound. WGSL allows a compiler to reassociate floating-point operations, and the compilers folded the error-free steps the functions depend on, for example (1 + x) - 1 into x. A bitcast round trip does not stop that. The fix, pmHide in packages/shared/precise-math.js, rebuilds a value from its bits with integer operations, which no compiler can fold (b6bea3e9). All 17 are within bound on the three vendors. What we got wrong: our first stand-in for such a compiler only folded self-cancelling sums, so it missed Mesa factoring a sum by one of its own terms; the stand-in now does both, and the old code fails it on any GPU (baa66526). A dense sweep (573,720 inputs for sin, cos and tan, 298,646 for pow) is 0 over bound on Intel and NVIDIA; the pre-fix code on Intel had 1,791 sin results over bound. Guards: tests/precise-math.test.js, packages/compute/tests/maths.test.js, compute test:browser:reassociate and test:browser:sweep. Not measured yet: what the extra work costs.

A proof failed on two machines, and the engine was fine

The math-consolidation proof passed on Node 26 and failed on two machines with Node 22: 21 of 24 digests differed. ECMAScript leaves the rounding of ** and the approximated Math functions to the engine; V8 in Node 26 uses the C library's pow and V8 in Node 22 its own, so 10 ** -5 differs. The proof now builds inputs from exact operations and fails if a taped call uses an approximated function (ab27353f, guard tests/proofs-golden.test.js, run in CI on Node 22.12 and 26).

Flaky tests had one shared cause

Four tests passed alone and failed under load, each because its timing depended on how busy the machine was: a heap probe that measured the shared test runner's heap (5.9 MB once; in its own process the same loop grows by at most 30 KB), a catalog test that read the system clipboard every process shares (both 6d08b0af), a 300 ms server timeout whose clock started before the child process ran (3a59aa55), and a walk check that bounded the eye's movement per frame while the engine clamps a slow frame at 0.1 s (7714e84e; the guard 109ec352 walks at 1/60, 25, 40 and 100 ms frames and still fails a 0.4 m jump). The same class gave two more: browser suites sharing one Vite cache (7ab8cd13) and a suite waiting silently for a fixed port (6ddd733b). What we got wrong: we first blamed time spent queueing for the GPU lock; measurement ruled that out.

Headless Edge picked the wrong GPU

After a reboot, headless Edge on the main PC used the integrated AMD GPU instead of the RTX A6000 whenever the Remote Desktop session was disconnected, and every visual check failed for lack of references for that GPU. Chromium uses DXGI adapter 0, and Windows lists first the adapter that carries the session's display. Power-preference flags and the Windows per-app setting had no measured effect. The launcher now looks up the hardware adapter with the most video memory at launch and passes its LUID (85c96a55, scripts/lib/gpu-adapter.mjs, guard tests/gpu-adapter.test.js). Still unexplained: before that reboot, checks got the A6000 with the session disconnected.

NVIDIA driver resets: cause not found

Nine nvlddmkm event 153 resets on 10-27 and 28 each took one page's WebGPU device during busy check runs, and the next page asking for a device was refused. We measured that event 153 is not the Windows watchdog: a deliberate 3 s dispatch gives a watchdog report (event 141) and no 153. The 141 reset is worse for correctness: WebGPU kept the device, and the cut-short work returned wrong results with no error. Our first theory, long path tracer dispatches, was wrong. We bounded them anyway (49dca9dd, at most 220 paths per dispatch, same pixels), but controlled runs gave no reset, and kills, GPU process crashes, device churn and contention did not reproduce one. Eight of the nine came while the Remote Desktop session was connected. The cause is not found. What changed is the checks (51d8786a): a lost device fails at once, the message names the reset from the Windows event log, and a step that fails while a reset is logged runs once more, with the reset and the rerun kept as a receipt, and a run that passed only that way is marked as one (6a8f7658); a second failure fails the check. A watchdog reset that cuts work short while a check still passes is not caught this way.

Node 22 for end users

The packages must run on Node 22.12 or newer. On Node 22.12.0 the packed packages build, install into a clean project, type-check their README examples and pass the bundler matrix (a4fca9be); a scan of every shipped source file for 33 APIs that Node 22.12 lacks found no unguarded use. The unit tests of the 47 packages that run in Node pass on 22.12.0 and 22.22.1: 355 files, 5 of 5 runs, 2,866 tests on 22.12.0 (86ed9107). This found two real bugs: netcode's openWebSocket hung forever on a refused connection, because Node 22's WebSocket fires only error (7f0dd465), and data after the end of a compressed stream was accepted on Node 22 in the FBX, ZIP, SOG and voxel chunk readers (0687e6ec, guard tests/trailing-data.test.js). These runs were on Windows; the new CI jobs have not run on GitHub yet.

Linux on a real Intel GPU

On the Ubuntu server, 42 of 43 package GPU suites were started, one at a time, and 38 passed (main b92998d6). The text suite failed because the server has no colour emoji font and the test relies on one from the system; that is open. The voxel, voxel path tracer and root browser suites were stopped by the heat watchdog at 82 C before they finished, so they have no Linux result. An earlier run there found a real engine bug: after an effect was removed, the voxel renderer drew nothing for a frame or two while pipelines recompiled (fixed in baa66526; removing an effect out of order still does it, and is open).

An outside audit

An outside audit of revision 74a01810 combined a source review, canary tests on a second laptop (temporary files, mock fetches, fake sockets and loopback servers only), a full verify, a short fuzz run over 36 targets and GPU checks. Verify passed 6,344 of 6,346 tests, with 2 skipped. It reported 20 findings, each marked reproduced, code confirmed or project documented, and it reproduced our known 4x MSAA blending variance on a second GPU (Intel Arc 140V: 4 frames of 450 differ at one pixel by up to 9 of 255). It states its own limits: a short fuzz run, local canaries only, no production test, and a passing verify does not show there are no bugs. Our own security review and fuzzers had not found these. Status on main: 16 are fixed, each with a regression test that fails without the fix; 1 is being fixed, and we describe it once its fix lands; 3 are limits the netcode room server does not have yet (netcode leaves authentication to the application), and proposals for them are pending. The fixed ones, by class:

docs/whitepaper/perf-history.md entries 37 to 44 · docs/known-bugs.md · commit messages named above

11Honest limits

12Coming soon

13Reproduce

From a checkout (Node 24.18 or newer for the repository; the published packages run on Node 22.12 or newer). Each command writes or prints the figure it backs; GPU commands take the shared GPU lock.

npm ci
npm run build:packages
npm run measure:size          # core + stage gzip, fails at 25,000
npm run verify                # the 6,498 tests, quality gates, API reports, current proofs
npm run bench                 # every benchmark suite (docs/benchmarking.md)
npm run proofs                # all 49 pinned GPU-call proofs
npm run fuzz -- --short       # every parser fuzzer, 4 s each
npm run check:merge           # verify + site, visual, views, WGSL and packed-package checks (GPU)

Per-claim commands are in docs/whitepaper/reproduce.md.