mirror of
https://github.com/storytold/photocraft.git
synced 2026-10-28 18:22:06 +01:00
Saves store each distinct tile once (a solid fill shares one Arc<Tile>), but the loader fetched, decompressed and charged max_total_bytes once per tile reference and gave every coordinate its own copy. A solid canvas above ~65536² (8-bit) failed to reopen with "bundle expands beyond 17179869184 bytes", and smaller ones lost their sharing (a solid 30000² 32-bit document went from about 1 MB to about 14 GB in memory). The loader now keeps the decoded tiles of the current load by sample type and content hash: each distinct tile is decoded, hash-checked and charged against the budget once, and every further reference gets the same copy-on-write Arc. The budget still bounds distinct decoded bytes; extra references cost a map lookup and an Arc clone each, bounded by max_manifest_bytes. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>