Skip to content

Photo Studio: review round 7 — data loss, correctness, memory and accessibility fixes - #238

Merged
jelveh merged 76 commits into
mainfrom
psadv-nov19/fixes
Nov 19, 2026
Merged

jelveh merged 76 commits into
mainfrom
psadv-nov19/fixes

Conversation

@jelveh

@jelveh jelveh commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

An adversarial review of Photo Studio: 75 verified fixes, one commit each, plus one spec brought up to date. Every bug was reproduced before it was fixed (a failing test, a reproduction script, or a code trace with concrete inputs). Almost every fix adds a regression test that fails without it.

Data loss and corruption

  • Brush strokes could lose their pixels. Tile cleanup run by another edit during a stroke deleted the stroke's working tiles, so it failed with "Missing pixel tile" and never reached history. On documents over 4096 tiles, cleanup runs after every edit. Strokes now hold their tiles until commit or cancel.
  • Save could overwrite a whole animated or multi-page file with one frame or page (GIF, APNG, animated WebP, multi-page TIFF), and silently dropped EXIF/XMP metadata and CMYK color when saving back to a Puter image. Save now says what would be lost and offers a .photo project instead.
  • Save a Copy could make a later Save flatten the original without asking.
  • Files picked in a Puter picker could be silently ignored if another task started while the picker was open. This affected Open, Import Layers and every save to a Puter folder.
  • One document that couldn't be kept for recovery stopped recovery for every other tab.
  • Imported action files and batch links could run commands that are never recorded, such as Delete Custom Brushes, wiping brushes or presets without asking.
  • The Assistant and Script Event actions edited the wrong document if another tab was chosen while they ran.

Wrong output

  • Threshold adjustment layers showed gray pixels near the cutoff; the GPU result now matches the applied result exactly.
  • Filters, Liquify, Apply Image and the Gradient tool changed alpha on a layer with locked transparency.
  • Styled groups of large layers didn't redraw after blend-mode or position changes.
  • The Develop white balance eyedropper sampled the uncorrected image. Quick Compare stretched a slightly cropped state. Rotate Object variations were stretched to the first one's box.
  • A 16-bit PNG ignored its EXIF orientation. Rulers in a flipped view counted the wrong way.
  • Painting: Blur/Sharpen ignored their Mode with Sample All Layers, the Pattern Stamp anchor point, the Shift-click start point after smoothing.

Layers, undo and locks

Ungroup, Align, Reverse, Delete All Empty Layers, the Properties background fill and new layers in locked groups now respect locks. Opacity and blend-mode keys on another layer no longer merge into the previous layer's undo step. Undoing a script run also undoes its first edit.

Memory and performance

  • Image Processor, Lens Correction batch and batch links: a 286 MB batch peaked at +1342 MB, now about +470 MB.
  • Flatten Frames Into Layers, 100 full-HD frames: about 1.82 GB → 1.06 GB.
  • Closing a document frees its video decoders, frames and decoded audio, which could reach 1 GB. Cancelled Export for Web previews no longer leak a full-size image.
  • GPU memory for effects that are turned off or hidden is capped at 256 MB. Opening a 61 MB PNG no longer checksums it four times (about 450 ms → under 2 ms of metadata reads).
  • Resizing the window with the AI layout dialogs open: about 135 ms → 80 ms per event on a 24 MP image.

Workflows

Recorded actions replay Tween, frame delay, onion skin, artboard, slice, Transitions, Interpret Footage and Slice Options with their settings instead of reopening the dialog. Export for Web exports right after a setting change. Batch link Run waits for a running task instead of dropping your photos. Fixes to round-6 features: AI Recompose, Remove Reflections, Liquify's Find with AI, relight handles and the Generate button.

Accessibility and UI

  • Link and accent text now meets 4.5:1 contrast in every theme and highlight color, through a new --link token. Focus rings on primary buttons are visible.
  • With no document open: the start screen has no keyboard traps or phantom "Untitled" tab, and commands that can't run are disabled.
  • Keyboard: tab focus survives redraws; shortcuts work again after clicking a checkbox; tools-panel arrow keys no longer nudge the layer; the screen mode button has a keyboard way to open its list.
  • Tooltips show the platform's keys and the user's own shortcuts instead of "Mod+Z" or fixed letters. The quick actions bar fits narrow windows.

Behavior changes to be aware of

  • The first Save of a typical camera JPEG opened from Puter asks before dropping its EXIF data. Keeping EXIF on JPEG save would remove the question, but that's a feature change.
  • New layers, pastes and fills made inside a locked group go above the outermost locked group.
  • While an action started by a Script Event plays, the editor stays busy, so a tab click takes effect after it finishes, as with scripts.
  • Effects whose GPU memory was freed by the 256 MB cap render again when turned back on, so the layer briefly shows without them.

Verification

  • tsc --noEmit is clean.
  • Unit tests: all 290 files pass under Node 22 (the CI version) with TZ=UTC: 2,809 passed, 27 skipped, all skips pre-existing. No .skip/.only or timing assertions were added.
  • Full browser suite on a frozen snapshot with a fresh server: 1,434 passed, 6 failed. Of those 6:
    • 4 also fail on main (stale close-with-Save specs); fixed in this PR.
    • 1 was a regression from this branch (Toggle Last State while the first edit commits); fixed and folded into the commit that caused it, verified with the undo-pending-transform and start-screen specs (15/15).
    • 1 is a timing flake under load (Layers panel ID escaping). It passes repeatedly in isolation, and this branch doesn't change Layers panel code.
  • Clean main baseline for comparison: 1,369 passed, 6 failed (stale specs, fixed in this PR).

Performance (main vs this branch)

Real-GPU headless Chrome (ANGLE Metal), scripts/perf-large-image.mjs on a 24 MP document. Main and branch were run alternately; 5 repetitions per round, medians shown per round.

Scenario main (3 rounds) branch (2 rounds)
Open 24 MP, longest main-thread task 251 / 240 / 246 ms 238 / 234 ms
Visibility, opacity, blend mode no task over 50 ms; 31–47 ms wall no task over 50 ms; 31–34 ms wall
Undo + redo 118 / 115 / 115 ms 117 / 115 ms
Paste 24 MP 84 / 95 / 83 ms 89 / 84 ms
Duplicate layer, main-thread time (CDP, 3×25 reps) 7.26 / 7.07 / 7.41 ms 6.86 / 7.01 / 7.21 ms
  • Brush strokes on a 4000×3000 layer, and the opacity key and Undo with 300 layers, were identical (1,366 ms per stroke; 33 ms each). These timings are locked to the frame rate, so they rule out regressions of a frame or more.
  • Duplicate layer's wall time rounds to 2 or 3 frames. Across all runs the branch landed on 3 frames somewhat more often (65% vs 38%), but its main-thread cost is unchanged and the per-round medians flip. No commit in this branch touches the GPU work a plain duplicate does, so this is reported as unexplained frame alignment rather than a measured cost.

Known issues, not fixed

  • Flattening or exporting a relight layer over semi-transparent content makes it more opaque (up to 64 levels); a plain pixel layer can't represent it in general, so this needs a design decision.
  • Vertical Type on a path creates horizontal type: type on a path only supports horizontal text, so this is a missing feature.
  • Denoise and Sharpen Details depend on how much of the image they're given; Surface Blur's preview differs from its applied result by a few levels.
  • Live Filters ignore locked transparency (deliberately: they re-render from the layer's stored source).
  • In the medium theme with a custom highlight, some accent-colored on/off icons fall below 3:1.
  • Rulers ignore view rotation; only flipping is fixed.

…s blend mode or position changes

The layer style cache keyed layers whose JSON exceeded 200,000 characters by
the length alone, so same-length edits (Normal to Screen, moving a child from
x 100 to 200) kept showing the old group content and effects. Such layers are
now keyed by a 53-bit digest of their JSON.
…hanges partly transparent pixels by its coverage alone

It composited source-over and then put the old alpha back, so the color change
was weighted by the pixel's own alpha too: a 50% black gradient over a
half-transparent gray pixel made it 67 instead of 100, and soft edges took
more of the gradient than the interior. It now mixes like brushes and
Edit > Fill do on a locked layer.
…en is released beyond 256 MB

The style cache kept each layer's rendered effects for as long as the layer
existed, so removing styles from several large layers kept hundreds of
megabytes of textures. Results not drawn in the last frame are now kept up to
a 256 MB budget (quick off/on toggles still reuse them) and the least recently
drawn are released past it.
…eview show only black and white, exactly as OK applies

The GPU applied Threshold's step through a 1024-entry table, which blurs the
edge across one entry: pixels whose luma lay within a quarter level of it came
out gray (102, 102, 206 at level 110 gave 83 instead of 255). The compiled
adjustment now carries the exact edge and the LUT pass compares against it on
both WebGPU and WebGL2.
…nsparency is locked

Brushes, fills and the Gradient tool already left a locked layer's coverage
alone, but filters did not: a Gaussian Blur softened the edge of a locked
shape and Liquify pushed pixels into its transparent areas. Destructive
filters (the dialog's canvas and pane previews, OK, Last Filter) and Liquify
(its workspace preview and OK) now keep each pixel's alpha and change only its
color. Live Filters are unchanged.
The sampled path painted the blurred or sharpened color as in Normal mode.
The Mode now compares the result with the image as shown, since the layer
painted onto is often empty.
…red at once

With Sample All Layers the tool read the layers below before the stroke
began; a release (or moves) arriving during that read were lost, so the dab
stayed unstored until the next stroke or tool change. The read now happens
while the stroke queues its samples, and the brush is cleaned and reloaded
only after the stroke has ended.
Like the other brushes, Escape during the drag now discards the stroke
instead of healing or removing it on release.
…ated or multi-page image

A GIF or APNG opened as its first frame, a multi-page TIFF opened as its
first page, an animated WebP (which only ever opened as its first frame) and
a TIFF whose other editor's layers were ignored all saved back to their own
file without a question, replacing the whole file with the one image that
was opened. Save now names what of the file was not opened and offers a
.photo project instead, as it does for other losses.
… or CMYK colors

Saving a document back over the Puter image it came from replaced a camera
JPEG's EXIF data (capture time, camera, location) and XMP metadata, which
Photo Studio does not read or write, without a word, and wrote a CMYK TIFF or
JPEG back as RGB. Save now names these with the other losses, once per
document, and says a .photo project leaves the file as it is.

Questions about what of the file was not opened are now asked only when Save
writes over that Puter file: a file opened from this device saves to a new
one, so there is nothing to ask.
…ther task started meanwhile

The editor is released while a Puter picker is open, and what follows the
picker ran through Editor.run, which does nothing while another task runs. A
command started while the picker was open made Open from Puter and Import
Layers from Puter ignore the chosen files, and Export Layers, the Image
Processor and page export write nothing to the chosen folder, all without a
word. They now wait for that task to finish.

Saving to a Puter folder also names the file that could not be written and
how many were, and the Image Processor's closing message there names the
images that failed, as its download does.
…latten the file itself unasked

Save a Copy as the image format a document came from remembered the losses
agreed to for that copy, so the next Save wrote the flattened image over the
document's own file without asking. As with a PSD copy, the answer now holds
only for the copy.
… stops the others

The recovery pass stopped at the first document whose copy could not be
written (a project over the 512 MB or metadata limit, browser storage full),
so no later tab got a recovery copy, and the failure only reached the
console. Each document is now written on its own, and a failure is reported
once per document and cause, saying to save it. Autosaved versions likewise
go on past a document that cannot be stored.
…four times

Reading one PNG chunk (the color profile, the resolution, the bit depth,
whether it is animated) computed the CRC of every chunk in the file, so
opening an 8-bit PNG checksummed all its image data four times before the
browser decoded it. The checksum is now computed only when asked for. On a
61 MB PNG the metadata reads at open went from about 450 ms to under 2 ms
(Node, M-series).
…e files it processes

Projects and PSDs processed by the Image Processor (and images run through
document steps) open in temporary tabs, and each was noted as a recent
file: a batch pushed the user's own files off Open Recent and, past eight
local files, deleted the copies that let them reopen after a reload. Those
tabs are no longer noted.
…ts file held

A document restored after a crash saved back over its Puter image without
the question about the frames, pages or metadata of that file that were
never opened. The recovery copy now carries them.
…on, as an 8-bit one does

The browser applies a PNG's eXIf orientation to the 8-bit PNGs it decodes,
but 16-bit PNGs are decoded by Photo Studio, which ignored it: the same
photo opened sideways at 16 bits and upright at 8. The orientation is now
applied to 16-bit samples too.
…ion skin, timeline, artboard, frame and Divide Slice settings without asking again

These dialogs used a plain form dialog, so recording stored the bare command:
playback opened the dialog for every step (and every file in a batch), and
cancelling it did not stop the action. They now use the settings dialog that
records confirmed settings and applies them on playback.
…o decoders, decoded sound and frame thumbnails

Nothing dropped them on close: decoders (holding the whole footage file)
stayed open until six newer ones replaced them, decoded audio stayed in its
1 GB cache, and frames and thumbnails kept counting against their budgets.
A close hook now drops what only the closed document used, and decodes
still running for it are not cached.
…n commands that are never recorded, such as Delete Custom Brushes

Recording and Insert Menu Item never add these commands, but playback ran
any command a file or link named, so a shared action could delete the
opener's custom brushes or reset presets without asking.
…nother tab is chosen while it runs

Each step edited whichever document was active, so choosing another tab
mid-run applied the remaining steps (and their undo step) to that one. Steps
now return to the plan's document first, and stop if it was closed.
…er changing a setting

The preview refresh that a setting change schedules started encoding the
same pane while Export was encoding it, which made Export give up with
missing images: nothing was saved and the error was overwritten at once.
Previews now wait while Export encodes.
…cument and holds the editor until it finishes

Event actions played on whichever document was active without holding the
editor, so choosing another tab while one played sent its remaining steps
to that document. They now play on the event's document while it is open,
and a tab chosen meanwhile is shown when the action ends, as for scripts.
… it saves to a Puter folder

The Puter folder save ended with its own message, which replaced the note
about images that could not be corrected; the note is now passed along, as
the Image Processor does.
… no longer keeps a full-size copy of the image in memory

The preview finished after the dialog closed and created an image URL that
nothing revoked (13 MB for a 2400 × 1600 photo, on every early cancel).
…its own size instead of stretching it out of line

A stored state whose proportions were within 1% of the current canvas was
treated as an image resize and stretched over it, so a crop of a few dozen
pixels misaligned the comparison by up to the cropped amount (and tiny
resizes rounded to whole pixels were not recognized). Now a resize is a
change where either side's scale predicts the other side within a pixel.
…no longer reports faces found for the closed window

The late answer was added to the closed workspace and its status message
("Found 1 face. Check each guide…") appeared after Cancel; errors from the
abandoned search were shown too. Both are now dropped once the window is gone.
…blend was generating

When blends arrived, the newest was selected automatically and, since a blend
restores the arrangement it was made for, any move, scale or flip made while
waiting was silently undone. Now a blend made for an older arrangement waits
to be picked, and the status says that picking it goes back to that
arrangement.
…election and Direct Selection tools nudge the selected path again

The relight handles took every arrow key while a relight layer was the
selected layer, so a selected work path, saved path or vector mask could not
be nudged from the keyboard and the light moved instead. The path selection
tools now keep their arrow keys.
…es slider is moved and put back

A slider dragged away and back to its value previews without a final change
event, so the previewed settings stayed behind and the canvas handles kept
drawing them: arrow-key nudges and undo moved the light in the image but not
its handle. The preview now only counts while the document is still the one
it started from.
…screen instead of canvas size fields that ignored what was typed
…e are disabled and Window › Documents no longer lists the start screen as Untitled
…ocus when the tabs redraw after a zoom or an edit

The tab bars were rebuilt on every update, which dropped the focus to the
page. They now redraw only when their markup changes and put the focus back
on the same tab.
…, tool keys and shortcuts such as Select All work again

A focused checkbox or radio button counted as typing, so every bare key and
Mod+A/C/V/X was ignored until the canvas was clicked. Such controls now keep
only the keys they use (Space, Enter, Tab and the arrows).
…ons as icons instead of running off the canvas under the panels
…d of the hidden canvas, a phantom Untitled tab and the dimmed tool options

With no document open, the document tabs, the canvas area and the tool
options (which the start screen covers or dims) are inert, so neither the
keyboard nor screen readers reach them.
…e image's left edge (now on the right) instead of labelling the mirrored image as if unflipped
…of leaving its thumbnail and an enabled zoom slider on the start screen
…lder Untitled document and its New Snapshot button is disabled
…on tooltips name the keys set in the Keyboard Shortcuts editor instead of the default ones
…cus ring outside the button, where it stays visible, instead of blending into the blue fill
… and closing a PNG is covered through the question about what it leaves out

Since Save writes an opened PNG back as a PNG, the two specs that close a
document with Save stopped at the "Save as PNG" question about the guide
they add, so the document never closed. The product behaves as intended;
the specs now name their documents as projects, as the transform and close
specs already do, and a new spec closes a PNG through that question.
… the stroke is pressed, also on touch

The unaligned pattern was anchored at the last hovered position, which a
touch never sets (the pattern then sat at the document origin, as if
Aligned were on) and which can trail the press point after a mouse moved
elsewhere. It now uses the point the stroke started at.
…ws its line from where the stroke ended

With smoothing, releasing the button catches the stroke up to the pointer,
but Shift-click continued from the smoothed point before that catch-up, so
the straight line started inside the previous stroke. It now starts at the
point the stroke actually ended.
…and Slice Options with their settings without asking again

These dialogs used the free-form modal, so recording stored the bare command:
playback (and every file in a batch) opened the dialog again, and cancelling
it did not stop the action. A settings modal now records the confirmed values
of the dialog's controls; playback applies them (checked against the controls)
without a dialog, and a step with its dialog on opens it showing them.
… keeps the dropped photos

Run went through the editor's busy guard, which skips a task while another
one runs, and then cleared the list: nothing ran and the photos were gone.
Run now waits for the other task (the status says so), runs the photos that
were listed, and keeps photos dropped during a run for the next one.
…as it renders instead of holding every frame image at once

Every frame's full composite was kept until all frames had rendered, then
converted to tiles, so memory peaked at the images plus their tiles. Each
frame now becomes tiles right away (held against tile cleanup until the
layers join the document). 100 frames at 1920x1080: peak array-buffer memory
1.82 GB before, about 1.06 GB after (the new layers' tiles).
…keep each result once and build the ZIP without copying the results

Each output was kept as bytes and as a Blob, and the ZIP copied the bytes into
one buffer that was copied again into a Blob for the download. Results are now
kept as Blobs with their checksums, and the ZIP is a Blob made of the headers
and those Blobs. 16 outputs of 286 MB in all: peak memory of the browser's
processes rose 1342 MB before and about 470 MB after (renderer array buffers
620 MB before, 112 MB after).
…lect and Mask show shortcuts as this platform types them (⌘Z, Ctrl+Z) instead of "Mod+Z"
…and the batch link's Open Link keep 4.5:1 contrast in every theme and highlight color

They used the raw accent color (3.0:1 on the hovered step's gray box in the
dark theme). They now use the --link token, and the step name no longer takes
the button hover background, like other link buttons.
… a slot's tools no longer nudge the layer when the Move tool is active

The toolbar handled the keys but let them reach the workspace, which nudged
the selected layer by a pixel for each press.
… right arrow key or Alt+Enter, and no longer tells screen readers it opens a menu when Enter changes the mode

Like a tool slot's flyout, the list of a tools-panel button (screen modes,
Quick Mask) opens from the keyboard; its tooltip says so.
… no light handles on the canvas, so its lights can no longer be dragged or nudged unseen
… its own settings instead of the built-in Defaults or Last Used
…urns comparing off again when released, also when the comparison view takes longer than the hold to load

The release only ended a comparison that was already showing; one that
started after the view finished loading stayed on.
…Stop or a failed run leaves the button saying Generate until a run has delivered results, and picking a new object resets it
…ns or Rotate Object open redraws the preview from its small copy and rebuilds it from the full image once resizing pauses

Every resize event copied and redrew the whole image (96 MB at 6000 x 4000).
With a 6000 x 4000 image, a resize event and its frame took 134-138 ms
(median) in Recompose and Rotate Object, now 78-82 ms; the final preview is
unchanged.
…s a project

Since Save writes an opened PNG back as a PNG, this spec's layered document
stopped at the "Save as PNG" question about the layers a PNG flattens, so it
waited for the editor until it timed out, on main as well. The product behaves
as intended; the spec now names its document as a project, as the other
transform and close specs were changed to do with that commit.
@jelveh
jelveh merged commit 15b374a into main Nov 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant