Skip to content

fix(preview): decode WebP previews and thumbnails without system loaders - #2189

Merged
l0gicgate merged 3 commits into
lgse:mainfrom
JoeJoeflyn:fix/1656-webp-previews
Nov 12, 2026
Merged

l0gicgate merged 3 commits into
lgse:mainfrom
JoeJoeflyn:fix/1656-webp-previews

Conversation

@JoeJoeflyn

@JoeJoeflyn JoeJoeflyn commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Description

WebP previews and thumbnails stayed empty on systems with neither a GDK Pixbuf WebP loader nor ImageMagick, as reported on Pop!_OS 24.04 in #1656. The sandbox helper now decodes WebP with the image crate's built-in decoder (already a dependency) before trying GDK Pixbuf, ImageMagick and dcraw.

  • Preview-pane images and browser thumbnails now share one fallback chain. Before this, the pooled thumbnail worker kept its own copy, which skipped any new decoder.
  • WebP dimensions come from the same decoder, so the decoded-frame budget is checked before decoding and oversized WebP files are rejected like oversized PNGs.
  • The built-in decoder applies EXIF orientation.

Visual evidence

popos_webp_verification

How to test

  1. On a system without a GDK Pixbuf WebP loader or ImageMagick (for example Pop!_OS or Ubuntu 24.04 without webp-pixbuf-loader and imagemagick), open a folder containing .webp images.
  2. Look at the thumbnails, then select a WebP file with the preview panel open.

Expected result: every WebP file shows a thumbnail in the file list and an image in the preview panel. Photos with an EXIF orientation appear upright.

Related issue

Refs #1656 (follow-up comment about WebP previews on Pop!_OS 24.04). No separate issue was opened for this follow-up.

The preview sandbox relied on a GDK Pixbuf WebP loader or ImageMagick, so
WebP previews and thumbnails stayed empty where neither is installed, as
reported on Pop!_OS 24.04. Decode WebP with the image crate's built-in
decoder first, read its dimensions from the same decoder so the decoded
frame budget still applies, and route browser thumbnails through the same
fallback chain as previews.

Refs lgse#1656
@github-actions github-actions Bot added the fix label Nov 12, 2026
The decoder applies EXIF orientation, but no test would fail if it stopped. Give the direct decoder test a rotated fixture so it checks the upright result.
@l0gicgate

Copy link
Copy Markdown
Contributor

Review and cleanup

Merged main at b97813450. No conflicts: Git followed the move of src/sandbox_helper/ to crates/strata-preview/src/sandbox_helper/ from #2112.

Review against the description and #1656. No reviews or inline comments existed. No blockers found.

  • WebP decodes without a pixbuf loader or ImageMagick: confirmed. render_webp runs first in the chain, and WebPDecoder::new rejects non-WebP files after reading the RIFF header, so other formats pay one small read.
  • Previews and thumbnails share one chain: confirmed. browser::raster_image and render_raw both go through render_raster; I compared the old and new branches (no dimensions, oversized, normal) and they match apart from the new first step.
  • Frame budget applies before decoding: confirmed. image_dimensions reads WebP dimensions from the decoder, render_raster rejects oversized files before render_webp runs, and render_webp checks again itself.
  • EXIF orientation is applied: confirmed in code, but no test would have failed without it. Fixed below.

Fixes pushed

  • 2dd86f612 test(preview): cover EXIF orientation in the built-in WebP decoder. webp_decodes_without_a_system_pixbuf_loader became webp_decodes_upright_without_a_system_pixbuf_loader: its fixture now carries EXIF orientation 6, so a 1200×600 source must come back 400×800.

Tests and comments. No tests removed. The table-driven preview/thumbnail test and the oversized test each gain a WebP axis that exercises new code (read_webp_dimensions, the shared chain). The direct render_webp test stays because it is the only one that fails on a host whose pixbuf loader would mask a broken built-in decoder. The added comments explain the decoder ordering and the test fixtures' header bytes; all kept.

Manual verification (debug build, Arch host)

  • Ran render_webp, render_pixbuf and browser_render over real files made with ImageMagick/libwebp: lossy 1000 px and 3000 px, lossless, alpha, two-frame animated, plus an EXIF-rotated file. All decode; alpha is kept, the animated file gives its first frame, and a 1000→800 downscale looks equivalent to the pixbuf result.
  • Launched the build on a private Xvfb display in a folder of those files: every row shows a thumbnail, and the EXIF-rotated file appears upright, which the pixbuf path does not do, so the built-in decoder is the one running inside the real sandbox worker. The preview panel was not opened; it uses the same render_raster.

Validation

  • ./scripts/test-headless.py sandbox_helper:: — 121 passed
  • cargo fmt --all --check, cargo clippy --workspace --all-targets --all-features -- -D warnings — clean (run natively)
  • scripts/code-health.sh on raster.rs, browser.rs, tests.rs — 9.68 / 10.0 / 7.9, same as main
  • Not run: full Rust suite locally (change is confined to the sandbox helper's raster path; CI ran it) and qa.sh (no scenario touched)

Follow-ups outside this PR

  • archive_cover::render_image still decodes only through PixbufLoader, so WebP covers inside CBZ/EPUB archives will stay empty on the systems this PR fixes.
  • For a WebP with EXIF orientation 5–8 the reported dimensions are the stored ones (for example 1200×600) while the image is shown rotated.

CI: all checks green on 2dd86f612 (QA scenarios is dispatch-only and skipped).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants