Skip to content

fix(examples): exclude SVG from Vite asset inlining#43

Merged
chiefcll merged 1 commit into
mainfrom
svg-no-inline
May 26, 2026
Merged

fix(examples): exclude SVG from Vite asset inlining#43
chiefcll merged 1 commit into
mainfrom
svg-no-inline

Conversation

@chiefcll
Copy link
Copy Markdown
Contributor

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:

  • File-URL SVGsisSvgImage(url) matches → ImageTexture.loadSvg → canvas rasterization. Works.
  • Data-URI SVGsisSvgImage doesn't match → ImageTexture.loadImagecreateImageBitmap(svgBlob). Chromium can't decode SVG via createImageBitmap (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 loadSvg and 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.tsbuild.assetsInlineLimit becomes a per-file callback that returns false for .svg and 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 as dist/assets/play_arrow-*.svg, etc., instead of being inlined.
  • Local Playwright VRT (pnpm test:visual:update) — svg-icons-1.png shows all 16 icons rendered in rows 1–3.
  • Docker / CI VRT — needs to be re-run on this branch; certified snapshot for svg-icons-1 should be regenerated against the now-working build.

🤖 Generated with Claude Code

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>
@chiefcll chiefcll merged commit f15ca28 into main May 26, 2026
1 check failed
@chiefcll chiefcll deleted the svg-no-inline branch May 26, 2026 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant