You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Avoid decoding imported images several times before they load #131
With #124, handleFiles in src/App.tsx checks each import before committing it, one step after another:
decodeImage loads the file into an <img>.
isCompleteRasterImage reads the whole file into memory for isTruncatedImageData, then fully decodes it again with createImageBitmap and discards the bitmap.
After the commit, useSwatches and CanvasPreview decode the image again.
For the 3888×2916 JPEG fixture, the createImageBitmap step alone allocates about 45 MB. Nothing shows that a check is in progress, so large imports feel unresponsive, and the longer wait widens the window in which an edit cancels the pending import.
Proposal: run the <img> decode and the createImageBitmap check together with Promise.all, or use createImageBitmap alone for raster files and keep <img> for SVG and engines without it. In testing for #124, WebKit's createImageBitmap accepted the same formats as its <img> (including HEIC and TIFF), and in Chromium both rejected HEIC and TIFF, so the second option should not change which files load. Re-check this on both engines. Keep the structural truncation check, which is cheap next to a decode. If a large file still takes noticeably long, show a short busy state while it is checked.
Partly done in #140 (merged 2026-11-10). The check before an import is committed now decodes each file once. The two decodes after the commit are still there, and they take most of the import time.
validateImageFile (src/lib/imageFile.ts) decodes raster files once, with createImageBitmap alone. SVGs, and engines without createImageBitmap, still use an <img>. The truncation check still runs first, so a truncated file is refused before any decode.
The browsers accept the same files as before. This was checked in Chromium and WebKit, with and without a MIME type.
On the 3888×2916 JPEG fixture, the pre-commit check went from ~94–112 ms to ~67–69 ms in Chromium, and from ~103–109 ms to ~90–92 ms in WebKit.
Still open
Decodes after the commit.CanvasPreview loads the committed URL into a new <img>, and useSwatches decodes it again with decodeImage. So the time from choosing a file to seeing its size didn't change (~700 ms Chromium, ~577 ms WebKit on the fixture). The next step is to pass the decode that validateImageFile already returns to these two, or let useSwatches read pixels from the preview's canvas. Both also decode again on every imageSrc change, such as edits, undo and redo, so the fix should not cover the import path only.
Busy state. Nothing shows yet that an import is being checked. This matters less now that the check itself is short, but it's still worth adding if the decodes after the commit stay slow.
Untested engines. Firefox and the Windows WebView2 haven't been checked against the new decode rule.
Fixed by #153 (merged into develop). Imports now reuse their validation decode, edits and Undo/Redo share one pixel snapshot, and a checking indicator appears for checks over 150 ms. On the 3888×2916 fixture, file-to-size-shown went from 1,052 to 305 ms in Chromium and from 1,427 to 501 ms in WebKit. Firefox and WebView2 still haven't been tested with the new decode rule.
Activity
test: hold only imported files in the decode-once check
perf: decode imported images once and reuse the result
fix: keep Stack Matrix photo colors as accurate as before
vycdev commentedon Nov 10, 2026
Note
🤖 Claude Opus 5.5 responding on behalf of vycdev
Partly done in #140 (merged 2026-11-10). The check before an import is committed now decodes each file once. The two decodes after the commit are still there, and they take most of the import time.
Done in #140
validateImageFile(src/lib/imageFile.ts) decodes raster files once, withcreateImageBitmapalone. SVGs, and engines withoutcreateImageBitmap, still use an<img>. The truncation check still runs first, so a truncated file is refused before any decode.Still open
CanvasPreviewloads the committed URL into a new<img>, anduseSwatchesdecodes it again withdecodeImage. So the time from choosing a file to seeing its size didn't change (~700 ms Chromium, ~577 ms WebKit on the fixture). The next step is to pass the decode thatvalidateImageFilealready returns to these two, or letuseSwatchesread pixels from the preview's canvas. Both also decode again on everyimageSrcchange, such as edits, undo and redo, so the fix should not cover the import path only.fix: avoid exporting stale pixels during image loads
fix: preserve image state through loading and failed touch-up saves
fix: restore batched touch-up history entries on undo
perf: reuse committed image pixels across 2D consumers
fix: avoid exporting stale pixels during image loads
fix: preserve image state through loading and failed touch-up saves
fix: restore batched touch-up history entries on undo
perf: reuse committed image pixels across 2D consumers
fix: avoid exporting stale pixels during image loads
fix: preserve image state through loading and failed touch-up saves
fix: restore batched touch-up history entries on undo
vycdev commentedon Nov 19, 2026
Note
🤖 Claude Opus 5.5 responding on behalf of vycdev
Fixed by #153 (merged into
develop). Imports now reuse their validation decode, edits and Undo/Redo share one pixel snapshot, and a checking indicator appears for checks over 150 ms. On the 3888×2916 fixture, file-to-size-shown went from 1,052 to 305 ms in Chromium and from 1,427 to 501 ms in WebKit. Firefox and WebView2 still haven't been tested with the new decode rule.