Speed up photo processing without noticeable quality loss #130

Merged
raucao merged 1 commits from photo-upload-perf into master 2026-11-27 22:56:14 +00:00
Owner

Photo processing was slow on most devices: blurhash was encoded from the full-resolution image, the original file was decoded up to five times, and the Android fallback path skipped native resizing. This reworks the pipeline to do a single worker pass per photo while keeping output quality effectively unchanged.

  • Blurhash is now encoded from a <=64px canvas instead of the full-resolution image (measured ~1.3s -> <3ms on desktop).
  • Main image, thumbnail and blurhash are produced in one worker pass: the original is decoded once and the thumbnail is derived from the resized main image.
  • The Android fallback retries createImageBitmap via an in-memory Blob before stepped software scaling, and validates that the browser actually honored the requested resize.
  • The redundant full-resolution canvas is gone, and intermediate canvases are released during stepped scaling.
  • The upload preview swaps to the processed thumbnail and decodes asynchronously.
  • Main image JPEG quality lowered to 0.85 (thumbnail unchanged at 0.9).

Adds unit tests for the image-processor service and documents the analysis and design in doc/dev/photo-upload-performance.md.

Photo processing was slow on most devices: blurhash was encoded from the full-resolution image, the original file was decoded up to five times, and the Android fallback path skipped native resizing. This reworks the pipeline to do a single worker pass per photo while keeping output quality effectively unchanged. - Blurhash is now encoded from a <=64px canvas instead of the full-resolution image (measured ~1.3s -> <3ms on desktop). - Main image, thumbnail and blurhash are produced in one worker pass: the original is decoded once and the thumbnail is derived from the resized main image. - The Android fallback retries `createImageBitmap` via an in-memory `Blob` before stepped software scaling, and validates that the browser actually honored the requested resize. - The redundant full-resolution canvas is gone, and intermediate canvases are released during stepped scaling. - The upload preview swaps to the processed thumbnail and decodes asynchronously. - Main image JPEG quality lowered to 0.85 (thumbnail unchanged at 0.9). Adds unit tests for the image-processor service and documents the analysis and design in `doc/dev/photo-upload-performance.md`.
raucao added 1 commit 2026-11-27 22:53:06 +00:00
Speed up photo processing without noticeable quality loss
CI / Lint (pull_request) Successful in 54s
CI / Test (pull_request) Successful in 1m14s
Release Drafter / Update release notes draft (pull_request) Successful in 17s
6b37db7d42
Photo processing was slow on most devices because blurhash was encoded
from the full-resolution image, the original file was decoded up to five
times, and the Android fallback path skipped native resizing.

- Encode blurhash from a <=64px canvas instead of full resolution
- Process main image, thumbnail and blurhash in a single worker pass,
  decoding the original only once and deriving the thumbnail from the
  resized main image
- Retry createImageBitmap via an in-memory Blob before falling back to
  stepped software scaling, and validate the browser honored the resize
- Avoid the redundant full-resolution canvas and release intermediate
  canvases during stepped scaling
- Swap the preview to the processed thumbnail and decode it async
- Lower main image JPEG quality to 0.85

Adds unit tests for the image-processor service and documents the design
in doc/dev/photo-upload-performance.md.
raucao added the enhancementnostrperformance labels 2026-11-27 22:55:35 +00:00
raucao merged commit ff56236722 into master 2026-11-27 22:56:14 +00:00
raucao deleted branch photo-upload-perf 2026-11-27 22:56:14 +00:00
Sign in to join this conversation.