You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(artwork): cache SVG logos at full size instead of their tiny canvas - #5214
Related issue: N/A
Validation tasks: changes #1210 C1 (an applied SVG logo is now cached at full size; the case's steps and expected results are unchanged)
Other clients: N/A (server-side fix; every client gets the corrected artwork without changes)
On servers that cache artwork, title logos from TMDB show up as a blur on title pages. TMDB serves most logos as SVGs, and the cache rasterized each one at its declared canvas. For these logos that canvas is a few dozen units wide, so the original and every rung were tiny. Back to the Future's logo declares a 53.921×24 viewBox, and every cached size of it was 54×24 px. The web detail page then draws that image about 280 px wide. Servers that don't cache artwork send clients the TMDB SVG directly, so they never showed the problem.
This change draws SVGs at the cache's full original size and repairs logos that were already cached the old way.
Approach
imageutil.Rasterize sends SVG sources to a small cgo function. It loads the SVG with libvips' svgloadscale option, so the longest edge comes out at MaxCachedOriginalDimension (3840 px), and encodes a PNG. bimg has no way to pass that option. The scale and the decode-budget charge both come from the size libvips reports for that scale, not from bimg's declared size. bimg rounds a fractional canvas to whole pixels, which would make the charge differ from what libvips draws. HEIF and AVIF keep the existing path.
On a node with little memory, a square or tall SVG drawn 3840 px wide can need more pixels than the decode budget accepts at all. Such an SVG is drawn as large as the node allows instead of failing.
The admin artwork picker's SVG sidecar previews use a new RasterizeWithin, which draws at preview size instead of 3840 px.
A migration re-queues the cache job of every logo cached from an SVG (on media_items and media_item_localizations) where the job row still exists, including library-file sources that end in a ?v= fingerprint, so the image cache stores it again at full size. Logos from metadata providers also go back to their provider source path, so clients get the provider's SVG right after the upgrade, the same as on a server that doesn't cache artwork. Logos from library files and NFOs keep their cached path, because clients can't load those sources.
The jellycompat image routes serve the same cached objects, so the fix applies there too.
Validation
Real TMDB logo through Rasterize and GenerateVariants: before, original/w1280/w500 were all 54×24. After: 3840×1709 / 1280×570 / 500×223. Rendering takes about 0.65 s per logo, once.
New unit test: an SVG with only a viewBox, and one whose declared canvas is fractional, each rasterize to the requested size. The test asks for a size that fits any node's decode budget.
Migration SQL ran inside a rolled-back transaction on a development database. All three statements ran without errors.
Go gate: build, gofmt, go mod tidy -diff, vet, lint-changed, lint-router-recovery, verify-migrations, verify-local-paths, verify-size-ratchet and verify-bidi pass. make test-go passes on the first commit. After the review fixes, the imageutil, imagecache and metadata packages, vet, lint-changed and the silo_node build pass again. Four packages whose tests refuse group-writable temp directories failed under this machine's umask 002 and pass when re-run with umask 022. The API contract, settings binding and route inventory checks were not run because none of those files changed.
The web gate was not run because no web files changed.
Evidence
Checked with the Back to the Future logo from TMDB (7hXsyx9em5FhNdeEf0tehFmG06r.svg). Before this change, its cached w500 rung was 54×24 px. Scaled to the web detail page's logo height, it matched the blur users reported. With this change the w500 rung is 500×223 px and the logo is sharp at that size. The build was this branch at 42dd3c75b6.
Risks
Migration: cached SVG logos from providers show the provider's SVG until they are cached again. Re-queued jobs wait an hour so that, during a rolling upgrade, a node still on the old version doesn't claim one and cache the tiny image again. A cluster whose upgrade takes longer than that can still re-cache some logos the old way.
Pruned jobs: the image cache removes jobs that succeeded more than 30 days ago, so older logos have no job to re-queue. Those get cached again by "Backfill Metadata Images" or by the item's next metadata refresh. A library-file or NFO logo with no job left keeps its tiny cached image until the item is scanned or refreshed again.
If the provider plugin behind a logo's source (for example TMDB) is no longer installed, that logo can't be loaded and the title shows as text until the item's artwork is refreshed.
Rendering an SVG at 3840 px costs more CPU and memory than the old tiny raster: about 26 MB of pixels per logo while it renders, within the decode budget. It happens once per logo.
Checklist
I read and can explain the complete diff.
This pull request addresses one concern.
Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
The Evidence section shows every change a user can see, or how I checked a change nobody sees.
AI Disclosure
Harness: Claude Code, run inside T3 Code
Tool(s): Claude Code, GitHub CLI
Model(s): claude-opus-5-5
Involvement: Fully AI-generated, at the maintainer's direction; maintainer review pending
Adversarial review: an independent Claude Code reviewer (claude-opus-5-5) that was not given these conclusions read the commit and the code it touches. It checked cgo memory and error handling, the build tags, libvips compatibility, the decode budget, other Rasterize callers, and the migration's SQL against the job table's constraints, the processor's success path and artwork GC. It found three problems, all fixed here: tall SVGs failed outright on small-memory nodes, the migration repointed library-file and NFO logos to sources clients can't load, and old nodes in a rolling upgrade could re-cache the tiny image. The Kody and CodeRabbit review bots then found four more, also fixed: SVG previews drawn at full size, library-file jobs missed because of their ?v= fingerprint, a test that depended on the machine's memory, and the budget charge for fractional SVG canvases.
Fix SVG logo caching: rasterize at full size instead of tiny canvas
SVG rasterization previously used the SVG's declared canvas size, which is often tiny for logos. imageutil.Rasterize now renders SVGs at MaxCachedOriginalDimension on their longest edge via a new imageutil.RasterizeWithin function that accepts a caller-specified longest-edge limit (implemented in imageutil.go).
New libvips C bridges in svg.go measure and render SVGs at a chosen scale, clamping the pixel count to source and decode-budget limits. SVGs with only a viewBox or fractional dimensions are covered by tests.
LocalImagePreview in local_artwork_picker.go now rasterizes SVG/HEIF/AVIF sidecars to at most twice the preview width.
Risk: Rasterize output size for SVGs changes, so anything relying on the old canvas-sized output must be checked; migration edits item/localization logo paths in place and cannot be undone (down migration is a no-op).
The image cache drew an SVG at its declared canvas. TMDB logos declare
canvases a few dozen units wide, so a cached logo's original and every
rung were a 54px image, and title pages stretched it into a blur.
Rasterize now draws an SVG at the cache's 3840px original width through
libvips' SVG scale option, or as large as the node's decode budget
allows, and the budget is charged for that raster. A migration
re-queues the cache jobs of logos already cached from an SVG, an hour
out so old nodes in a rolling upgrade leave them alone, and points the
ones from metadata providers back at their provider source.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No actionable comments were generated in the recent review.
Walkthrough
SVG inputs now use dimension-limited rasterization that respects the decode budget. Local artwork previews use a bounded rasterization size. A migration requeues qualifying logo jobs and updates qualifying cached logo paths.
Rasterize delegates to RasterizeWithin, which applies a caller-selected dimension limit and routes SVG input through libvips. SVG rendering adjusts its scale to fit the dimension and pixel limits and reserves decode budget. Local previews use a limit of twice their display width. Tests check rendered dimensions, and the documentation describes the cached-original limit and SVG rendering size.
Logo cache repair migrations/sql/20261123160655_recache_svg_logos.sql
The migration requeues qualifying succeeded or failed logo jobs and resets qualifying item and localization logo paths to their SVG source paths. The down migration performs no reversal.
This change renders SVG title logos at up to 3840 px instead of their tiny declared canvas, keeps admin previews at preview size, and requeues affected logo cache jobs. No unresolved defects remain in the reviewed changes. The migration data repair cannot be reversed by the Down migration, which is documented and intentional.
Security architecture risk: Moderate · up to 42dd3
The new renderer limits the size of the image it produces, but the repair can send clients back to the original provider and does not restore the previous cached logo on rollback. During a rolling upgrade, some jobs can also be picked up by older workers before the intended delay ends, leaving the blurry logo cached.
Retained concerns
Medium · reliability · inferred: The migration's one-hour delay does not fence old workers. Reset local jobs qualify for existing early-claim paths because their attempt count is zero and their last error is empty. Routine workers can also claim the jobs after the delay regardless of version. If an old worker completes a repair for the same source, the usual source and lease checks accept its result and the job can finish with the old rasterization behavior.
Medium · reliability · observed: Provider-backed logo pointers are rewritten without requiring a surviving job or a successful replacement upload. A missing or failed job can therefore leave users dependent on provider delivery until refresh or backfill. The Down migration restores neither the prior pointers nor the queue state, so a database downgrade does not recover the previously cached delivery path.
Low · security · inferred: The SVG branch replaces the declared-canvas admission check with a rendered-pixel check. A source that exceeded the old canvas limit can now reach native rendering if its scaled dimensions fit. The shared reservation still bounds output pixels, but does not account for the newly added input copy and repeated header loads before reservation, or establish a bound on embedded-raster work. The incremental availability impact on the rendering process was not measured.
Security review details
Security Blast Radius
inferred — The renderer change applies to SVGs reaching the existing artwork cache and administrator preview, not just migrated logos. The database repair is narrower: it affects qualifying item and localization logos and their matching queue rows.
Security Findings and Attack Paths
inferred — Provider or library SVG bytes can reach the native renderer through existing artwork workflows. The changed admission check can expose the rendering process to inputs formerly rejected on canvas size, but the inspected call paths do not establish a new anonymous route or a demonstrated exhaustion outcome.
Trust Boundaries and Controls
observed — The migration restores provider delivery for previously cached qualifying logos but excludes known internal source schemes, including file, upload, and generated artwork. Provider-hosted delivery already exists for uncached artwork; the change extends that delivery mode to the migrated rows before recaching completes.
Resilience and Maintainability Implications
observed — The decode budget already documented that an SVG's embedded images can cost more to decode than the canvas suggests. That limitation predates this PR; charging the rendered output does not resolve it.
Hardening Proposals
proposed — Keep serving the previous cached logo until the replacement is ready, and activate repair jobs only once workers capable of the new render are eligible. If immediate provider fallback is required, preserve the prior pointers for an explicit recovery operation.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title names the main change: SVG logos are now cached at full size instead of their small declared canvas. The changeset adds an SVG rasterization path in imageutil, a migration that re-queues SVG…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description check
The description states the problem (blurry TMDB SVG logos caused by rasterizing at the declared canvas size), the approach (libvips svgload scale to MaxCachedOriginalDimension, RasterizeWithin for the…
Full details: Title check
Explanation
The title names the main change: SVG logos are now cached at full size instead of their small declared canvas. The changeset adds an SVG rasterization path in imageutil, a migration that re-queues SVG logo cache jobs, and a test for full-size SVG rendering. The title is short, specific, and matches the primary fix.
Full details: Description check
Explanation
The description states the problem (blurry TMDB SVG logos caused by rasterizing at the declared canvas size), the approach (libvips svgload scale to MaxCachedOriginalDimension, RasterizeWithin for the admin picker, a migration that re-queues cache jobs and repoints provider logos), validation, and risks. It matches the changeset closely, so the check passes.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 70f2b6b5-2a38-4c1b-b88e-5a99a73cbdf7
Commits
Reviewing files that changed from the base of the PR and between 4243d3b and 42dd3c7.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
bimg rounds an SVG's declared canvas to whole pixels, and libvips
scales the fractional canvas, so the decode budget could be charged
for a smaller raster than the one drawn. The scale and the reservation
now come from libvips' own header at each scale, which also lands the
cached original exactly on 3840px.
The admin artwork picker drew each SVG sidecar at 3840px only to
shrink it to a 300px preview; RasterizeWithin draws it at preview size.
The migration also re-queues jobs for library-file SVG logos, whose
sources end in a "?v=" fingerprint, and the full-size test no longer
depends on the machine's memory.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
silo-triageBot
added
size/L
200–499 added + deleted lines (all files); change volume, not priority.
and removed
size/M
50–199 added + deleted lines (all files); change volume, not priority.
labels
Nov 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bugSomething isn't workingimpact: polishAnnoyance, cosmetic, or nice-to-havepriority: P2Limited scope, workaround exists, or polishsize/L200–499 added + deleted lines (all files); change volume, not priority.
1 participant
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Related issue: N/A
Validation tasks: changes #1210 C1 (an applied SVG logo is now cached at full size; the case's steps and expected results are unchanged)
Other clients: N/A (server-side fix; every client gets the corrected artwork without changes)
On servers that cache artwork, title logos from TMDB show up as a blur on title pages. TMDB serves most logos as SVGs, and the cache rasterized each one at its declared canvas. For these logos that canvas is a few dozen units wide, so the original and every rung were tiny. Back to the Future's logo declares a 53.921×24 viewBox, and every cached size of it was 54×24 px. The web detail page then draws that image about 280 px wide. Servers that don't cache artwork send clients the TMDB SVG directly, so they never showed the problem.
This change draws SVGs at the cache's full original size and repairs logos that were already cached the old way.
Approach
imageutil.Rasterizesends SVG sources to a small cgo function. It loads the SVG with libvips'svgloadscaleoption, so the longest edge comes out atMaxCachedOriginalDimension(3840 px), and encodes a PNG. bimg has no way to pass that option. The scale and the decode-budget charge both come from the size libvips reports for that scale, not from bimg's declared size. bimg rounds a fractional canvas to whole pixels, which would make the charge differ from what libvips draws. HEIF and AVIF keep the existing path.RasterizeWithin, which draws at preview size instead of 3840 px.media_itemsandmedia_item_localizations) where the job row still exists, including library-file sources that end in a?v=fingerprint, so the image cache stores it again at full size. Logos from metadata providers also go back to their provider source path, so clients get the provider's SVG right after the upgrade, the same as on a server that doesn't cache artwork. Logos from library files and NFOs keep their cached path, because clients can't load those sources.Validation
RasterizeandGenerateVariants: before, original/w1280/w500 were all 54×24. After: 3840×1709 / 1280×570 / 500×223. Rendering takes about 0.65 s per logo, once.go mod tidy -diff, vet,lint-changed,lint-router-recovery,verify-migrations,verify-local-paths,verify-size-ratchetandverify-bidipass.make test-gopasses on the first commit. After the review fixes, theimageutil,imagecacheandmetadatapackages, vet,lint-changedand thesilo_nodebuild pass again. Four packages whose tests refuse group-writable temp directories failed under this machine's umask 002 and pass when re-run with umask 022. The API contract, settings binding and route inventory checks were not run because none of those files changed.Evidence
Checked with the Back to the Future logo from TMDB (
7hXsyx9em5FhNdeEf0tehFmG06r.svg). Before this change, its cached w500 rung was 54×24 px. Scaled to the web detail page's logo height, it matched the blur users reported. With this change the w500 rung is 500×223 px and the logo is sharp at that size. The build was this branch at42dd3c75b6.Risks
Checklist
AI Disclosure
Rasterizecallers, and the migration's SQL against the job table's constraints, the processor's success path and artwork GC. It found three problems, all fixed here: tall SVGs failed outright on small-memory nodes, the migration repointed library-file and NFO logos to sources clients can't load, and old nodes in a rolling upgrade could re-cache the tiny image. The Kody and CodeRabbit review bots then found four more, also fixed: SVG previews drawn at full size, library-file jobs missed because of their?v=fingerprint, a test that depended on the machine's memory, and the budget charge for fractional SVG canvases.🤖 Generated with Claude Code
Note
Fix SVG logo caching: rasterize at full size instead of tiny canvas
imageutil.Rasterizenow renders SVGs atMaxCachedOriginalDimensionon their longest edge via a newimageutil.RasterizeWithinfunction that accepts a caller-specified longest-edge limit (implemented in imageutil.go).viewBoxor fractional dimensions are covered by tests.LocalImagePreviewin local_artwork_picker.go now rasterizes SVG/HEIF/AVIF sidecars to at most twice the preview width.Rasterizeoutput size for SVGs changes, so anything relying on the old canvas-sized output must be checked; migration edits item/localization logo paths in place and cannot be undone (down migration is a no-op).Macroscope summarized 42dd3c7.