Upload appears to hang: image compression blocks the main thread #5
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Follow-up to #3.
Symptom
After picking a large image the admin appears to "just keep loading" — the overlay sits on
Preparing…, the progress bar stays at 0%, and the page is unresponsive.Cause
Two defects in the compression added in #3:
canvas.toBlobon a 12 MP canvas blocks the main thread, so React never repainted and the bar was frozen at 0% — which reads as a hang rather than as work in progress.Fix
Estimate the next scale from how far the previous attempt overshot the budget (encoded size tracks pixel count closely at fixed quality) instead of walking a fixed ladder, capped at 4 attempts. Yield between attempts so the UI can paint. Show an indeterminate pulsing bar while preparing, since re-encoding reports no progress of its own.
Measured
Output quality is unaffected: the realistic photo still lands at full 2560×1920.