Skip to content

Removing a frame drops the conversion for every image set that shares that path #255

Description

@adulbrich

Found while implementing #248, and deliberately parked rather than fixed there. Real, uncommon, and non-corrupting, so it was not treated as a merge blocker for that PR.

What happens

dropRawConversions(paths) in src/lib/raw-preview.ts matches cache entries by path prefix:

if (key !== path && !key.startsWith(`${path}|`)) {
  continue;
}

The session cache is shared across the whole page, and it is keyed by the source path. But an image set is not the only thing that can reference a path. If the same file has been added to two different image sets, both sets resolve to the same cache entry.

Remove that frame from one set, and the entry is aborted and forgotten for both. The set the user did not touch is still rendering a thumbnail from that entry, so its preview settles into Error loading TIFF image: Aborted and stays there until the component remounts.

Why it was parked rather than fixed

The design spec for #248 rejected reference counting, but the reasoning there was about the three consumer types (thumbnail, metadata reader, pipeline) and whether one losing interest should cancel the others. It did not reason about one path appearing in two form rows. That is a genuine gap in the analysis rather than a case that was considered and dismissed.

It only bites when a user adds the same file to two sets, which is unusual but not nonsensical. Nothing is corrupted and no data is lost: the conversion is simply thrown away and the survivor shows an error instead of a thumbnail.

Options

  1. Reference count the cache entries. Correct, and the most invasive. Drop only when the last referent goes away. Worth weighing against the spec's original reasons for rejecting it, which still apply to the consumer-type case.
  2. Ask the form for the live path set before dropping. Only abort a path that no remaining image set references. Cheaper than full reference counting, and it puts the decision where the truth already lives.
  3. Make the thumbnail recover from an abort. Treat AbortError as "not converted" rather than as a display error, so the survivor re-requests instead of showing a dead tile. Narrowest fix, and it leaves the wasted conversion in place.

Option 2 is probably the best value: image-matrix-input.tsx already has the full form state at the point where it calls dropRawConversions.

Reproducing

Add the same RAW file to two image sets, wait for neither to start converting (it has to still be queued, since a started or finished entry is deliberately kept), then remove it from one set. The other set's thumbnail shows the abort error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions