An ignored release test that builds a 120k-layer file over 15 pages and
times the server's welcome, Client::join and the engine opening it
through live_poll, for the delta catch-up and the full snapshot:
cargo test --release -p figcraft-engine --lib join_timings -- --ignored --nocapture
It runs natively, where the web heap's page-by-page growth doesn't
happen, so it times decode and apply work only.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On wasm32-unknown-unknown, Rust's allocator (dlmalloc) grows the memory
one 64 KiB page at a time whenever it runs out, and the browser changes
the protection of the whole memory at each grow. The reporter's
121k-layer join made about 20,400 grows and spent 176 s of a 3-minute
freeze in them on Windows.
Memory dlmalloc got is reused once freed and never given back, so
allocating one large block and freeing it at once leaves that much free
room, for one grow. heap::keep_ahead does this whenever the memory grew
since its last call: half the heap again, at most 256 MiB at a time.
It acts only while a snapshot is read: a heap::reading() guard is held
by the delta snapshot decode, by unpacking a packed welcome and by
Replica::from_snapshot, and dropped on every exit path. Inside that
window it runs between delta records and vectors, between changes in
Replica::apply, and for each JSON value read from a full snapshot. The
same hooks run for live batches, where they return at once. Off wasm32
they always return at once. All of it is safe code: a fallible
reservation, then black_box so the optimizer keeps the allocation.
Measured with Client::join on an encoded 120k-layer welcome, in a
standalone wasm32 module under Node on macOS (three runs each, same
window). The shipped figcraft-web build, Chrome and Windows were not
measured:
- delta catch-up: 607-616 ms -> 433-449 ms; the memory grew twice
between hook calls, each followed by one reservation (the baseline
grew by 3,800 pages, at most one grow each); peak memory 241 -> 308 MiB
- full-snapshot catch-up (an older server): 3.6-3.9 s before the previous
commit, 1.27 s after it, 407-417 ms with this one; 4 reservations;
peak memory 455 -> 674 MiB against the previous commit (722 MiB
before both)
The extra peak memory is the room reserved ahead and not used.
This covers the allocations inside the decode and apply. Opening the tab,
the first layout and the first paint run outside every hook and were not
measured.
--initial-memory doesn't help: with the std that Rust 1.96 links, a probe
still grew page by page above a 256 MiB initial memory.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replica::from_snapshot borrowed the changes and cloned the whole
Vec<Change> before applying it, because the review-settings clamp
rewrites some of them in place. Every caller already owns the snapshot
(Client::join, the rejoin path, Server::restore), so it now takes the
Vec by value: a large file's snapshot is no longer copied and then
dropped twice on the way in. The server's publish path still borrows
and copies explicitly.
In a wasm32 build joining a 120k-layer file through the full-snapshot
catch-up (what an older server sends), this cut peak memory from 722 MiB
to 455 MiB.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Switching the input language on Windows (Alt+Shift or Win+Space to a
Russian layout) or typing in it hung the app. A Windows start offered
wgpu Direct3D 12 and OpenGL together, and wgpu's OpenGL backend makes a
hidden window on a thread that handles no window messages as soon as its
instance exists, even when Direct3D 12 draws. Windows hands the language
change to every thread with a window, so the main window waited on that
hidden one. The reporter confirmed WGPU_BACKEND=dx12 avoids it.
A Windows start now offers Direct3D 12 alone. Vulkan and OpenGL stay as
restarts after a failed start, each on its own, and OpenGL with lower
limits is added last so the old lowered Direct3D 12 + OpenGL attempt's
reach is kept. A GPU with no Direct3D 12 driver (Intel Haswell, which
wgpu leaves out of Direct3D 12, and older GPUs) now draws on Direct3D
12's software adapter instead of its OpenGL driver.
Not run on Windows; the attempt list is tested.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The design_review prompt came with the design review commands (#2194),
but the Prompts table in docs/mcp.md never listed it, so the table
showed six of the seven prompts. It now has a row, in prompts/list
order, with its one argument.
create_node and set_properties fetched their layers through node_at,
which also serializes each one to measure it for the read tools'
budgets. The mutation tools threw that size away, so they now fetch
through node_get, which only reads the layer.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KudydNWQDXESHDpVmpiqZh
A row in the Prompts table, a short "Building from a design" section
after visual verification saying which tools the prompt uses, and the
ROADMAP row.
The developer tools were all there, but nothing said how they fit
together: an agent had to find out from each description that
design_context reads the whole page when nothing is selected, that
export_assets needs a dir, that annotations come from annotation.list,
and that a variable's codeSyntax is under variables.
implement_design {destination?} gives the order: read the design (and
ask which frame when nothing was selected), reuse connected components
(asking before importing mappings, which changes the design), tokens
and shared styles before literal values, explicit values as the
specification and the platform's layout behind the derived ones, the
files export_assets writes (again for what it left out), unsupported
values approximated, missing and the tree's own annotations read, the
other sizes' frames read, and the result checked with compare_design,
one frame at a time, when a browser tool is available. Every step that
can come up short says to ask or to report it, never to present it as
done.
The server instructions name it beside fix_comments and design_review.
An image fill shown at half its pixels or fewer (a 0.5x export, the canvas zoomed out) was sampled straight at that size with bicubic filtering and nothing averaging the pixels between samples, so fine detail aliased into moiré bands. It now draws from a copy averaged down to under twice the size it shows at (the image halved, or the canvas's smaller copy halved), cached like the canvas's copies. Every copy averages the finished pixels (premultiplied, after the image's adjustments) and is placed where the image itself would be; the size shown is measured on the axis showing the most device pixels, so an image squeezed on one axis by its crop or its layer keeps the other's pixels. Images shown larger draw as before.
Fixes#2664.
The layers these two tools return can now be cut to the keys an agent
needs, with the same `fields` and `outline` options get_node and
inspect_document take. The options are checked before the edit runs, so
a bad one changes nothing, and without them the result is unchanged.
Closes#2535.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KudydNWQDXESHDpVmpiqZh
A prompt is a workflow an agent follows by name. The existing check
covers the command ids the instructions and prompts give, but not the
MCP tools or the result fields: a renamed tool or field would leave a
prompt pointing at nothing, with no test failing.
Every snake_case name in the server instructions and the prompt
templates must now be a tool, a prompt or that prompt's own argument,
and every backticked field must appear in some tool's or command's
documentation.