d2lang/d2 · critical
Failed to decompress paper texture: %v
Error message
Failed to decompress paper texture: %v
What it means
The WASM build's init decompresses the embedded brotli-computed paper background texture into the package-level paper variable. If compression.DecompressBrotli(paperBr) fails, init panics. This signals corrupt/truncated embedded paper texture data, independent of any user input.
Source
Thrown at d2renderers/d2svg/d2svg_embed_wasm.go:22
import (
_ "embed"
"fmt"
"github.com/d2lang/d2/lib/compression"
)
//go:embed paper.txt.br
var paperBr []byte
var paper string
func init() {
// Decompress paper texture for WASM builds
var err error
paper, err = compression.DecompressBrotli(paperBr)
if err != nil {
panic(fmt.Sprintf("Failed to decompress paper texture: %v", err))
}
}
View on GitHub (pinned to 0d69dca6f5)
Solutions
- Rebuild from a clean checkout to restore a valid embedded paper texture blob
- Verify paperBr decompresses standalone (brotli -d) and replace it if corrupt
- Re-generate paper.br from the original texture with the project's asset pipeline
- Increase the WASM memory limit if failure is allocation-related
Example fix
// before paper.br // corrupt git checkout -- d2renderers/d2svg/assets/paper.br && go build // after git checkout -- d2renderers/d2svg/assets/paper.br && go build
Defensive patterns
Strategy: try-catch
Validate before calling
// Validate the embedded paper asset at build/test time
b, _ := os.ReadFile("d2renderers/d2svg/assets/paper.br")
if _, err := compression.DecompressBrotli(b); err != nil {
panic("paper.br is corrupt: " + err.Error())
} Try / catch
// init panic cannot be caught; guard the embedding site instead
paper, err = compression.DecompressBrotli(paperBr)
if err != nil {
log.Printf("paper texture unavailable: %v", err)
paper = "" // degrade gracefully, render without texture
} Prevention
- CI: decompress-check every embedded brotli asset
- Allocate sufficient WASM memory for asset decompression
- Restore assets via git rather than manual edits
- Regenerate paper.br only with the project asset pipeline
When it happens
Trigger: Process start of a WASM build: init at d2renderers/d2svg/d2svg_embed_wasm.go:22 gets a non-nil error from DecompressBrotli(paperBr) — the embedded asset is invalid or the decompressor fails (e.g. OOM in constrained WASM memory).
Common situations: Corrupted paperBr asset in the repo or after a bad build; asset regenerated with incompatible brotli settings; very low WASM memory limits causing decompression allocation failure.
Related errors
- Failed to decompress SourceCodePro-Italic: %v
- Failed to decompress FuzzyBubbles-Regular: %v
- Failed to decompress FuzzyBubbles-Bold: %v
- Failed to initialize font faces: %v
- failed to decode %q response for %s: %w
AI-assisted analysis of d2lang/d2@0d69dca6f5 (2026-08-31).
Data as JSON: /api/errors/1fa92319110b5182.
Report an issue: GitHub.