Keyboard shortcuts

Press ← or → to navigate between chapters

Press ? to show this help

Press Esc to hide this help

Model dev channel

Status: current contract (Pygmalion G §9, §10, §11.4; built in delivery step 8). Native and browser games, Blockbench (desktop and web) and the Blender add-on speak it. In singleplayer the in-process server follows each applied package too (see Singleplayer server).

The dev channel carries saves from a modelling tool into running games on either host within seconds, and the games’ diagnostics back to the tool. It is the browser’s only hot reload. Artists use it through the tools; this page is the protocol and security reference. The workflow is in the model assets guide.

Topology

A browser page cannot listen on a socket and web Blockbench cannot write files, so every party connects to a relay as a client:

 Blockbench (desktop or web) ─┐                     ┌─ native game
 Blender add-on ──────────────┼── ws://127.0.0.1 ───┼─ browser game tab
 Asset Lab (in a game) ───────┘        relay        └─ more games
                                         │
                            assets root on disk (atomic writes)
PartyHow it runs
Relaycargo mod dev [root] [--port 47801] [--open [url]] [--allow-origin <origin>], or embedded in a native game started with --dev-channel (or MANIFOLD_DEV_CHANNEL=1) when nothing listens on the port and MANIFOLD_ASSET_DEV_DIR names the root
Native game--dev-channel / MANIFOLD_DEV_CHANNEL=1; port from MANIFOLD_DEV_CHANNEL_PORT, else <dev root>/.manifold-dev/port, else 47801; token from MANIFOLD_DEV_CHANNEL_TOKEN, the embedded relay, or <dev root>/.manifold-dev/token
Browser gamecargo mod dev --open [url] opens the build with #dev_channel=ws://127.0.0.1:<port>/&dev_token=<token> in the URL fragment, which no server receives; web/dev-channel.js dials it (loopback ws:// only)
BlockbenchTools → Manifold Dev Channel…; desktop reads the token file under the assets root, web asks for the token
BlenderSidebar → Manifold → Dev Channel → Connect; a background thread owns the socket and a bpy.app.timers callback drains it on the main thread

The relay writes <root>/.manifold-dev/token (readable by the current user only) and <root>/.manifold-dev/port when it starts; the token is new on every start.

Wire format

Every message is one binary WebSocket frame: a little-endian u32 header length, a JSON header, then an optional raw payload (GLB bytes, or a packed pose). JSON keeps the JavaScript and Python clients trivial; the raw payload carries multi-megabyte GLBs without base64. Headers are capped at 4 MiB and payloads at 64 MiB. type names the message in snake case; optional fields may be omitted.

MessageFrom → toFields (payload)
helloany → relay, firstrole (tool, game, lab), name, protocol (1), token
welcomerelay → peersession, protocol, assets_root, peers (session, role, name)
put_packagetool → relayrequest_id, id, fragment (an exporter fragment, merged) or recipe (whole text), base_recipe_hash (GLB)
put_recipelab or tool → relayrequest_id, id, recipe, base_recipe_hash
resultrelay → putting peerrequest_id, id, written, glb_hash, recipe_hash, epoch, diagnostics (the cargo mod validate --json schema-1 document), refused (superseded, stale-base, missing, io), recipe (the recipe now on disk)
package_changedrelay → games and labsid, epoch, glb_hash, recipe_hash, recipe (GLB)
fetchgame or lab → relayid, or none for every model written in this relay session
packagerelay → fetching peeras package_changed; epoch 0 when not written this session (GLB)
appliedgame → relay → tools and labsid, epoch, ok, diagnostics (schema-1 entries), import_ms, visible_ms, local_preview, game (filled by the relay)
refusedgame → relay → tools and labsid, reason (permission, remote-session, stale-epoch), game
navigategame or lab → toolsid, source (a diagnostic’s {kind, name, clip})
focustool → games and labsid, object
posetool → games and labsid, layout, joints (names, when the layout changes) (40 bytes a joint)
timelinetool → games and labs, or game/lab → toolsid, clip, time, playing
ping / ponganyevery 5 s; a peer silent for 15 s is dropped
errorrelay → peermessage; before welcome the relay then closes

Hashes are 16 lowercase hex digits of FNV-1a 64 over the bytes (manifold_model::authoring::hash_hex): deduplication, not security.

Flow

  1. The tool exports on command, or on save (debounced 300 ms).
  2. While a put for a model is queued, a newer one replaces it; the replaced put is answered superseded, so a burst of saves costs one merge.
  3. The relay merges the fragment into the recipe on disk (manifold_model::authoring::merge_recipe; merging never loses authored work, so a stale base_recipe_hash is fine here), validates the package with the runtime importer, and always writes it, GLB then recipe, each through <file>.tmp and a rename. Disk holds the artist’s latest export; a recipe the merge cannot parse is never rewritten (MODEL015).
  4. The relay answers result and sends package_changed with the model’s next epoch, which counts up within the relay session. A game ignores an epoch older than the one it holds (refused: stale-epoch).
  5. Each game imports from the pushed bytes with the poller’s keep-last-good rule (manifold_model::apply_package): an import with errors keeps the last good model. It answers applied with its own diagnostics and timings.
  6. The tool shows “visible in 2 games (native game 0.6 s, browser game 1.1 s)”, or the games’ diagnostics.

A game catches up with fetch when it connects. The native poller still watches MANIFOLD_ASSET_DEV_DIR for edits made without the channel; it skips the relay’s write of a package the channel already applied (the shared content hash). The Asset Lab’s Reload fetches the model from the relay.

put_recipe (the Asset Lab’s save) is refused stale-base when the recipe on disk changed since the lab opened it; result.recipe then carries the current text, and the lab re-applies its unsaved edits on it and lists the ones that no longer apply (G §11.4).

Pose streaming and the timeline

While a tool streams (opt-in, at most 30 Hz), pose carries the local translation, rotation (x y z w) and scale of every joint, 40 bytes each, little-endian f32, in the order of the joints names sent with the current layout. Games map joints by node name, because the importer folds static nodes and orders joints parent-first; a joint whose compiled rest also holds folded parents gets the tool’s change relative to the node’s own rest (manifold_client_state::push_model_preview_pose). The pose overrides the Asset Lab preview and releases 2 s after the last frame, or at once on an empty payload. Streamed poses are never saved. timeline moves the other side’s clip and time when the model is the one selected; the Asset Lab sends it when scrubbed.

Security

  • Loopback only. The relay binds 127.0.0.1 and ::1 and drops any other peer address.
  • Origin allowlist, checked at the handshake: no Origin (native clients: Blender, the native game), https://web.blockbench.net, file:// (Blockbench desktop), loopback pages (http(s)://127.0.0.1|localhost|[::1] with an optional port and nothing after it) and origins given with --allow-origin. Anything else, including a DNS-rebound page, gets 403.
  • Token. Every hello carries the relay’s 128-bit token, compared without an early exit. Loopback is shared by every account on a machine and native clients send no Origin, so the token is what stops another local user or process.
  • Roles. Only tools put packages, focus or stream poses; only games and labs fetch, report or navigate.
  • Confinement. Ids must parse as ModelId (no .., no absolute paths), so every write lands under the root; the relay executes nothing it receives.
  • Games decide. A game applies a package only in singleplayer (as the local host) or, as a client of a remote server, with operator rights there, the default of H’s animation.dev node, which stands in for it until H; any other client answers refused: permission. A remote client’s changes are its own presentation only (local_preview, shown in the Asset Lab as “local preview, not shared”); the server keeps the agreed content.

Singleplayer server

A package a game applies (keep-last-good, manifold_model::apply_package) also reaches its singleplayer server’s ServerModelCatalog, so the authoritative hit volumes, sockets, gameplay events and root motion follow it (G §9.7, issue 33):

  • Native. The shared apply path (the poller under MANIFOLD_ASSET_DEV_DIR and the channel) hands the imported model to the embedded server: ServerRunHandle::dev_apply_model sends TickControl::DevApplyModel, applied between two ticks, and the frame waits up to 500 ms for the answer.
  • Browser. The page forwards each package it applied to its server worker ({ type: 'devModelApply' } on the worker’s control port); the worker imports it with the server profile against the built-in graphs (dev_model_apply_server_worker) and posts devModelApplied back.
  • The rule (manifold_server_state::anim::apply_dev_model). Only an in-process host reaches it; no network message carries a model. It is refused while any remote peer is connected (the session’s content is shared), and the game’s applied then says local_preview. Every awake character running the model drops its graph state and history and restarts at the new model’s entry state, as waking from dormancy does, so clients in scope get an AnimSync; held-item caches naming it re-resolve. Nothing is saved (the catalog and graph state never are), and a live replay recording stops, since the swap is not a journaled input.

Limits

  • A model deleted from the dev root leaves the server’s copy in place until a restart; only applied packages are forwarded.
  • Browser packages resolve graph assets against the built-in library; native packages against the relay’s assets root, then the dev root.
  • welcome lists the peers at connect time only.
  • Web Blockbench reaching a loopback relay may meet a browser local-network permission prompt (G issue 11).

Source and tests

PartSourceTests
Protocol, relay core, pose packing, Origin and tokencrates/manifold-dev-channel/src/{protocol,relay,pose,security}.rsunit tests in each module
Relay server and client (native)crates/manifold-dev-channel/src/{server,client}.rsserver.rs tests: a put reaching a game and disk; wrong token, Origin and protocol refused
cargo mod devtools/cargo-mod/src/dev.rsURL fragment test
Native gamecrates/manifold-host/src/dev_channel.rs, model_platform.rs (server forward)
Singleplayer server updatecrates/manifold-server-state/src/anim/reload.rs, crates/manifold-server/src/tick.rs (DevApplyModel), crates/manifold-host-web/src/worker_entry.rsarchetypes.rs test a_live_model_update_restarts_the_characters_running_it
Browser gamecrates/manifold-host-web/src/driver/dev_channel.rs, web/dev-channel.jscrates/manifold-host-web/e2e/dev-channel.test.mjs
Blockbenchtools/blockbench-manifold/manifold_model.jstools/blockbench-manifold/test/channel.test.mjs
Blendertools/blender-manifold/{ws_client,channel}.pytools/blender-manifold/tests/test_channel.py