mirror of
https://github.com/storytold/cadcraft.git
synced 2026-12-01 18:25:32 -06:00
On wasm32 a DPrim is 40 bytes and one allocation can take at most isize::MAX (2 GiB - 1): a list of more than 2^25 primitives panicked with "capacity overflow" when its vector grew. The 64M-point budget (#3306) charged a point primitive one point, so it allowed 64M of them; a 4.5 MB DXF of dotted lines reached 33.56M. - MAX_DISPLAY_PRIMS, charged once per primitive beside the points and shared like them: 2^24 on 32-bit targets, equal to MAX_DISPLAY_POINTS (and not counted) on 64-bit ones, where it can't bind. - Clipped copies (viewport contents, XCLIP) are appended only while the list has room within both limits; the append stops at the first piece that doesn't fit and the build is spent, as when a budget runs out. Builder::charge checks the same room in its own list. - Compile-time asserts: the primitive, point, pen, plotted-text and image vectors stay under isize::MAX bytes at these limits (checked for wasm32 by the wasm step). - gpu::build_mesh counts its lines and quads first and allocates each array once: the quads grew by doubling and passed 1 GiB on large lists with lineweights shown. Part of #1603. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>