fix(format): read a native document within an object budget (#3587)

Opening a native document now reads at most MAX_READ_NODES objects (4M,
512K on wasm32) and refuses the file past that with a message naming the
budget. Paths already read within MAX_READ_ANCHORS and the web build's JSON
cap is 256 MB, but the number of objects had no bound: a gzip'd document of
empty groups costs about 270 bytes per object once read against some 50 in
its JSON, so 10M groups in a 24 MB file took 2.7 GB to open.

NodeWire's id is read through counted_id, so each object counts once as it
is read. load_file reads through a private load_file_within so a test can
exercise the budget without a 4M-object document.
This commit is contained in:
Don Omondi
2026-10-29 11:07:37 +07:00
committed by bflatastic
parent 2b36d641c1
commit eeae8c9136
4 changed files with 84 additions and 3 deletions
+1
View File
@@ -32,6 +32,7 @@ pub use kind::{ImageObject, NodeKind};
pub use live_shape::{LiveShape, Scaling};
pub use opacity::{Knockout, OpacityMask, whiten};
use wire::NodeWire;
pub use wire::{MAX_READ_NODES, with_node_budget};
fn yes() -> bool {
true