openpencil/packages/pen-renderer/src
Fini dd231d4ef2 fix(renderer): per-node catch restores canvas save stack
Codex stop-hook on the prior per-node try/catch caught a leak: the
catch logged but didn't roll back canvas state. drawNode pushes
canvas.save() once per ancestor clipStack entry (node-renderer.ts:548)
plus more for rotation / flip (574, 583) and per-shape sub-paths
(701, 1094, 1102). If drawNode throws mid-loop, every save() between
its entry and the throw stays on the stack — the next node's draw
operates inside a leaked clip / leaked transform, and the canvas
either renders nothing or renders to the wrong region.

Snapshot canvas.getSaveCount() before each drawNode call; on catch,
canvas.restoreToCount(saveCount) pops everything back to the
baseline. Wrap the restoreToCount itself in a no-op catch since it
can throw if the snapshot count is somehow above the current depth
(shouldn't happen but guarded so the error reporter still runs).

Net effect: per-node failures are now genuinely isolated. The
canvas state at the start of each iteration is identical to where
the previous iteration left it; one bad node can't smear its leaked
state across the rest of the frame.
2026-05-10 22:54:02 +08:00
..
__tests__ Merge feat/rust-ification into v0.8.0 (Step 0 Rust workspace bootstrap) 2026-05-04 21:00:00 +08:00
document-flattener.ts Merge feat/rust-ification into v0.8.0 (Step 0 Rust workspace bootstrap) 2026-05-04 21:00:00 +08:00
font-manager.ts V0.7.3 (#111) 2026-04-15 22:19:12 +08:00
image-loader.ts V0.7.0 (#95) 2026-04-11 23:25:13 +08:00
index.ts V0.7.3 (#111) 2026-04-15 22:19:12 +08:00
init.ts V0.7.0 (#95) 2026-04-11 23:25:13 +08:00
node-renderer.ts fix(renderer): coerce missing shadow numeric fields + isolate per-node draw 2026-05-10 22:54:01 +08:00
paint-utils.ts V0.7.0 (#95) 2026-04-11 23:25:13 +08:00
path-utils.ts V0.7.0 (#95) 2026-04-11 23:25:13 +08:00
render-node-thumbnail.ts V0.7.0 (#95) 2026-04-11 23:25:13 +08:00
renderer.ts fix(renderer): per-node catch restores canvas save stack 2026-05-10 22:54:02 +08:00
spatial-index.ts V0.7.0 (#95) 2026-04-11 23:25:13 +08:00
text-renderer.ts V0.7.0 (#95) 2026-04-11 23:25:13 +08:00
types.ts Merge feat/rust-ification into v0.8.0 (Step 0 Rust workspace bootstrap) 2026-05-04 21:00:00 +08:00
viewport.ts V0.7.0 (#95) 2026-04-11 23:25:13 +08:00