Preparing a 48MP photo without blocking the editor
Uploading a photo has work to do before an AI request starts: decode the source, resize it, and encode a smaller image. On the Image to Image editor, a synthetic 8000 × 6000 JPEG exposed a 91ms main-thread long task during that preparation. Moving the image work to a dedicated Web Worker removed long tasks of 50ms or more in the same upload check.
Disclosure: MinshengLiu operates the linked editor. This is an operator-produced engineering case, written with AI assistance from recorded implementation and browser checks. It is not an independent benchmark, a claim about all devices, or a promise of search rankings.
Pixels and file size tell different stories
The fixture was a locally generated two-colour checkerboard, encoded as JPEG at quality 0.85. It had 48 million pixels but occupied only 759,754 bytes because its pattern compressed well. A small file can still expand into a large bitmap; an RGBA representation of that size alone is about 192MB, before other buffers. This fixture exercises large dimensions, not the variety or encoding complexity of ordinary camera photographs.
The editor prepared a 1536 × 1152 JPEG at quality 0.86. The original pixel limit, prepared-image dimensions and encoding quality were retained in this change. The prepared upload size is separate from the AI output limit: the linked service currently produces an output up to 1024 pixels on the longest side.
What moved off the main thread
- The UI immediately enters a “Preparing image…” state and prevents conflicting remove, preset or generation actions while preparation is running.
- A worker decodes the image using
createImageBitmap, checks the existing source-pixel limit, and computes a scale that does not enlarge a small input. - The worker draws onto an
OffscreenCanvas, with a white background for this JPEG workflow, and callsconvertToBlob. Transparency is deliberately flattened; this is not a transparent-PNG export. - The bitmap is closed and the worker is terminated after it returns. The UI receives the prepared Blob and displays the source preview.
- If workers or the required decoder/canvas path are unavailable, the editor uses its existing browser image/canvas fallback and asynchronous encoding path. A worker moves work; it does not eliminate decoding cost or guarantee faster results on every device.
MDN documents OffscreenCanvas.convertToBlob in workers, including its format support and failure cases. Feature detection and a fallback still matter.
What the browser check measured
| Measurement | Observed result |
|---|---|
| Source fixture | 8000 × 6000 synthetic JPEG, 759,754 bytes |
| Main-thread upload task before | 91ms long task |
| Main-thread upload tasks after | No observed task of 50ms or more during the checked preparation interval |
| Prepared image after | 1536 × 1152; displayed after about 430ms |
| Largest observed interaction entry | 64ms across the checked preset, details and comparison interactions |
| Fresh page LCP | 1008ms; recorded separately from the upload |
The 390px-wide browser check loaded a public sample and preset without horizontal overflow. Disabling the Worker API for a separate compatibility check still prepared a 1400 × 788 room sample through the fallback. No paid generation or payment was made for these checks.
The application’s 78 tests, lint, production build and type checks passed. Those checks support this release; they do not establish the performance of every browser, network or photograph.
How to repeat a useful upload check
- Record the input’s dimensions and bytes separately. Keep an unchanged source for before/after runs, and include realistic photos as well as a controlled fixture.
- Observe
longtaskentries on the main page and start a timestamp immediately before the file-change event. Record when the prepared preview is actually ready. - Confirm the worker returned the prepared Blob. Check that the busy state appeared and that errors remain visible when decoding fails.
- Try the editor’s ordinary controls after preparation, then test an unsupported-worker path. Avoid quietly removing safety limits to make a benchmark pass.
- Collect new real-user performance data across supported devices. Do not replace a field measurement with one local interaction duration.
What this does not prove
An older Clarity report contained a very large interaction duration inconsistent with the reported length of that session. Its collection cause remains unconfirmed. This upload change does not repair or erase historical analytics. Google’s INP guide explains the page-level responsiveness metric and why real-user evaluation matters.
Local image preparation also does not mean generation is local. Selecting a file prepares its bytes in the browser; submitting an edit sends the prepared image to the linked service for prompt, source-image, generation and output review. Read the editor’s privacy policy before uploading a photo.
For the creative side of the workflow, the free prompt builder helps state one requested change and the details to preserve. The actual product-background example shows why the generated output still needs review: even a clear instruction changed chair details.