Skip to content

flamegraph: give the page a favicon - #203

Merged
dpsoft merged 1 commit into
mainfrom
feat/flamegraph-favicon
Oct 6, 2026
Merged

dpsoft merged 1 commit into
mainfrom
feat/flamegraph-favicon

Conversation

@dpsoft

@dpsoft dpsoft commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Every page perf-agent writes showed the browser's blank-document icon. A
profiling session ends up with a dozen of them open at once — on-CPU,
off-CPU, GPU, fused, before and after — and they were indistinguishable in
the tab strip.

Inlined, not linked

The icon is a base64 data: URI. assets.go states the contract the whole
package is built around: nothing may reference an external URL, because the
deliverable is one file that renders from file:// with no server and no
network. A <link href="brand/favicon.svg"> would be a broken icon
everywhere but the directory the page happened to be written in.

Base64 rather than percent-encoding because the markup contains #, < and
" — the three characters that make a raw SVG data: URI fragile inside an
HTML attribute.

The artwork is the 16px mark, drawn for that size rather than scaled from the
full one: the full mark loses its top rows below about 24px and reads as a
smudge in a tab strip.

The test it broke, and why it is now stricter

TestRenderHTMLFetchesNothing forbade the substring "<link " outright, so
this change failed it. The rule that test exists to enforce is that the page
fetches nothing — and a data: URI fetches nothing.

It now parses every <link> in the output and requires its href to be a
data: URI. That is stricter than the old substring check, not looser:
the old one would have missed <link\n rel=... or any other spelling, while
the new one inspects every link the document actually contains.

Verified by mutation: pointing the favicon at an https:// URL fails the
test with a <link> must resolve to a data: URI. Restoring it passes.

Also confirmed on a real generated page (a 50k-sample PyTorch GPU profile):
the rel="icon" link is present and the page still contains zero http(s)
URLs of any kind.

Every page perf-agent writes showed the browser's blank-document icon. A
profiling session ends up with a dozen of these open at once -- on-CPU,
off-CPU, GPU, fused, before and after -- and they were indistinguishable in
the tab strip.

The icon is inlined as a base64 data: URI, not linked. assets.go states the
contract the whole package is built around: nothing may reference an
external URL, because the deliverable is one file that renders from file://
with no server and no network. A <link href="brand/favicon.svg"> would be a
broken icon everywhere but the directory it was written in.

Base64 rather than percent-encoding because the markup contains #, < and " —
the three characters that make a raw SVG data: URI fragile inside an HTML
attribute.

The artwork is the 16px mark, which is drawn for that size rather than
scaled from the full one: the full mark loses its top rows below about 24px
and reads as a smudge in a tab strip.

TestRenderHTMLFetchesNothing forbade "<link " outright, so it failed on this
change. The rule it exists to enforce is that the page fetches nothing, and
a data: URI fetches nothing -- so it now parses every <link> and requires
the href to be a data: URI. That is stricter than the old substring check,
not looser: it also catches a <link> that the old list would have missed by
spelling. Verified by mutation -- pointing the favicon at an https URL fails
it with "a <link> must resolve to a data: URI".
@dpsoft
dpsoft merged commit 0af1a28 into main Oct 6, 2026
16 checks passed
@dpsoft
dpsoft deleted the feat/flamegraph-favicon branch October 6, 2026 16:23
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