mirror of
https://github.com/storytold/gridcraft.git
synced 2026-10-27 12:16:54 -06:00
Floating pictures were decoded at full size, with no limits, into one process-wide map of textures that never let go, not even when their workbook closed. Its key was the picture's id and byte length, and ids are per workbook, so a second open workbook could show the first one's picture. The new floating_pictures module, built like cell_pictures, keeps a cache per egui context keyed by workbook, picture id and size: - bounded at 128 MB, least recently drawn first, never evicting a picture drawn in the last frame, so none turns into a placeholder; - a workbook's textures go when it closes (checked every frame); - a picture's header is read first (16,384 px a side, 64 MP at most), it is decoded with limits, and to the next size step of what is drawn (a power of two or three quarters of one, up to 4,096 px or the GPU's limit); it is decoded again only when drawn larger; - a picture that can't be decoded is remembered, not retried each frame. Measured on macOS 27 (Apple M3 Max): 12 pictures of 2600 x 2600 opened from an .xlsx and scrolled through, textures held by egui 258 -> 40 MB, settled footprint 738 -> 509 MB; after closing the workbook, textures 258 -> 0 MB, footprint 504 -> 236 MB. 24 pictures: textures 490 -> 76 MB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>