Why another Spine runtime
Slot games are full of small skeletons: fifteen symbols on the reels, coins, sparkles, a character in the corner. The official spine-pixi-v8 runtime is correct and complete, but it treats each skeleton as its own island. I kept seeing the same costs in profiles, so I wrote them down (DESIGN.md §3) and then built a runtime that doesn't pay them:
| Official runtime | pixi-marrow |
|---|---|
| One Spine version per package | 4.1, 4.2 and 4.3 in one scene |
| A blend-mode change starts a new batch | Additive slots stay in the batch |
| Instructions rebuilt on most frames | Data rewritten in place |
| Resting skeletons still pose and upload | Resting skeletons sleep: 0 bytes uploaded |
| Clipping always on the CPU | Clipping avoided where possible |
import { MarrowSpine } from 'pixi-marrow';
const hero = await MarrowSpine.load({ skeleton: 'hero.skel', atlas: 'hero.atlas' });
app.stage.addChild(hero);
hero.play('run', { loop: true });
const reason = await hero.play('win').finished;
if (reason === 'complete') hero.play('idle', { loop: true });
Numbers
Headless Chrome on an Apple M4, pixi.js 8.23, 200 instances, marrow vs official (pnpm bench:ab, DESIGN.md §16):
| Rig | Draw calls | Frame (WebGL2) | Heap / instance |
|---|---|---|---|
| coin-pro | 1 vs 400 | 1.03 ms vs 3.46 | 16.5 vs 15.3 KB |
| raptor-pro | 1 vs 1 | 4.23 ms vs 7.01 | 70 vs 105 KB |
| tank-pro | 401 vs ~488 | 8.17 ms vs 20.66 | 156 vs 283 KB |
Across the suite, marrow's frame takes 30–89% of the official time on WebGL2 and 42–86% on WebGPU. At rest, 200 instances update in 0.02–0.04 ms and upload nothing; the official runtime uploads 0.2–3.4 MB per frame. Instancing takes 200 draws to 1.
What these numbers don't say: anything about phones. That's written in the doc next to the table, and GPU skinning stays off by default until I've measured it on real devices.
Bit-exact or it doesn't ship
A faster runtime that poses skeletons slightly differently is useless to an animator. The pose core is a port of the official cores with the arithmetic in the same order and 64-bit pose values. Parity runs 2,970 seeded cases over 135 skeleton files; on divergence it prints the seed. Worst pixel difference against spine-pixi-v8: 4/255. Along the way I found that the official binary readers ignore a typed array's byte offset; marrow honours it.
How batching works
Small rigs (≤1024 vertices) go through two custom batchers that feed Pixi's batch pipe. Each element reserves a constant size (room for its largest attachment, unused indices padded as degenerate triangles), so draw-order, visibility and attachment changes rewrite data in place and Pixi never rebuilds instructions. The 1024 limit isn't arbitrary: batching saves ~2.7 µs per instance and costs ~5 ns per vertex, so the curves cross near 570 vertices.
Big rigs use mesh mode: one draw for up to 8 atlas pages, optional GPU skinning, a slot-palette texture, and instanced draws.
Shipping it
- WebGL2, WebGPU, and WebGL1 since 0.3.0 (the GLSL 1.00 programs are generated from the same sources).
- A WebGPU fix for Pixi's 2,047-slot uniform buffer, which used to throw at 1,200 clipped instances.
pixi-marrow/diagnose: 25 perf rules (MARROW001–025) that tell you what a skeleton will cost and why.- Presets (
exact,balanced,fast), baking, an idle cache, LOD and tight meshes.