fix(examples): exclude SVG from Vite asset inlining#43
Merged
Conversation
Vite inlines small assets as data: URIs by default (4 KB threshold). For SVG this routes the texture through ImageTexture.loadImage → createImageBitmap(blob), which Chromium can't decode for SVG MIME types (crbug 606319) — the texture upload silently produces an empty bitmap. File-URL SVGs take the loadSvg canvas-rasterization path instead, which works. Excluding only SVG from inlining keeps the default behavior for PNG/etc. and ensures every SVG in the examples app exercises the renderer's SVG code path, in dev and in the CI snapshot runner. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
The new svg-icons VRT test from #42 was rendering correctly in dev but the icon rows came out empty in the Docker CI snapshot. Root cause:
Vite inlines small assets as
data:image/svg+xml,...URIs by default (4 KB threshold). The 16 Material Design icons added in #42 are ~150 bytes each, so the production build bundles them as inline data URIs. That changes the texture code path:isSvgImage(url)matches →ImageTexture.loadSvg→ canvas rasterization. Works.isSvgImagedoesn't match →ImageTexture.loadImage→createImageBitmap(svgBlob). Chromium can't decode SVG viacreateImageBitmap(crbug 606319) — the texture silently uploads an empty bitmap, the icon disappears.This is a general footgun for the renderer: any inlined SVG silently bypasses
loadSvgand ends up broken in Chromium. Excluding SVG from the inline threshold makes every SVG go through the renderer's SVG path, in dev and in the CI snapshot runner.Change
examples/vite.config.ts—build.assetsInlineLimitbecomes a per-file callback that returnsfalsefor.svgand falls back to Vite's default (4 KB) for everything else. PNG/etc. inlining behavior is unchanged.Test plan
pnpm --filter examples build— MDI icons now emit asdist/assets/play_arrow-*.svg, etc., instead of being inlined.pnpm test:visual:update) —svg-icons-1.pngshows all 16 icons rendered in rows 1–3.svg-icons-1should be regenerated against the now-working build.🤖 Generated with Claude Code