fix: hold the sketch caps at design load and bound the solver per component
Nothing on the load path checked a sketch's size, and every sketch in the timeline is solved when a design opens. The solver sizes its dense matrices by the connected component, so a 30 MB file with 200,000 chained points asked the allocator for terabytes and the process aborted, which no panic guard can intercept. Reject an oversized sketch while the design is still raw JSON, so the typed arrays are never built, and refuse a connected component with more variables than fits in a bounded matrix: that component now reports a failed solve and leaves its geometry alone. 10,000 chained points went from 9.6 GB and 25 seconds to a failed solve in well under a second. Fixes #145 Co-Authored-By: Claude Opus 5 <[email protected]> (cherry picked from commit 04abbf95c26f68c7d0a126ed9e2827049f593361)
This commit is contained in:
1 parent
0b5e15e2b9
commit
78f80143d5
5 files changed
+115
-2
No files matched your search
@@ -161,9 +161,16 @@ fn generated() -> Vec<(String, Vec<u8>)> {
|
||||
let design = |name: &str, features: Value| {
|
||||
json!({"format": "solvecraft/11", "name": name, "units": "mm", "params": [], "next_id": 9, "features": features}).to_string().into_bytes()
|
||||
};
|
||||
// A sketch past the caps interactive editing enforces: solving it would size dense matrices
|
||||
// by the point count and abort on the allocation.
|
||||
let point = json!({"id": "p1", "pos": [0.0, 0.0], "fixed": false});
|
||||
let oversized = json!([{"id": 1, "name": "Sketch1", "suppressed": false, "type": "sketch",
|
||||
"plane": {"type": "origin", "name": "XY"},
|
||||
"sketch": {"points": vec![point; 200_000], "curves": [], "constraints": []}}]);
|
||||
vec![
|
||||
("construction plane is its own side".into(), design("selfplane", json!([plane(1, "P1", to("P1"))]))),
|
||||
("two construction planes refer to each other".into(), design("twoplanes", json!([plane(1, "P1", to("P2")), plane(2, "P2", to("P1"))]))),
|
||||
("sketch with 200,000 points".into(), design("bigsketch", oversized)),
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user