All work

pixi-marrow

A faster Spine runtime for PixiJS v8

Plays Spine 4.1, 4.2 and 4.3 in the same scene on WebGL2, WebGPU and WebGL1. Batches small skeletons into one draw call, lets resting skeletons sleep, and stays bit-exact with the official runtimes.

Docs, Lab & Playground Source npm
  • Small skeletons stop costing a draw call each

    200 Spine coins render in one draw call instead of 400, so effect-heavy win sequences keep their frame rate.

  • Idle animation is free

    Skeletons that hold still skip posing and upload nothing. Fifteen resting reel symbols cost close to zero.

  • Animators lose nothing

    Poses match the official Spine runtimes bit for bit, so a faster game looks exactly like the approved animation.

30 Spine skeletons from one asset, rendered by pixi-marrow in this page. Spineboy is the Esoteric Software sample character.

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 runtimepixi-marrow
One Spine version per package4.1, 4.2 and 4.3 in one scene
A blend-mode change starts a new batchAdditive slots stay in the batch
Instructions rebuilt on most framesData rewritten in place
Resting skeletons still pose and uploadResting skeletons sleep: 0 bytes uploaded
Clipping always on the CPUClipping 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):

RigDraw callsFrame (WebGL2)Heap / instance
coin-pro1 vs 4001.03 ms vs 3.4616.5 vs 15.3 KB
raptor-pro1 vs 14.23 ms vs 7.0170 vs 105 KB
tank-pro401 vs ~4888.17 ms vs 20.66156 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.