Skip to content

Cover the streaming render path, which was never broken - #495

Merged
thcp merged 1 commit into
mainfrom
test/streaming-zoom-coverage
Aug 29, 2026
Merged

Cover the streaming render path, which was never broken#495
thcp merged 1 commit into
mainfrom
test/streaming-zoom-coverage

Conversation

@thcp

@thcp thcp commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

Closes #494

I claimed in #493 that the streaming render path was reasoned about rather than
measured, because looking for its canvases found none. That claim was wrong, and
this corrects it.

The false negative

document.querySelector("#multitrack-container").querySelectorAll("canvas").length
// 0

Zero after eight seconds, with the loading overlay cleared, canplay fired, no
failed requests, and the same result against main. Every signal said the
streaming path renders nothing.

It renders nine canvases. WaveSurfer draws into shadow roots, and
querySelectorAll does not cross a shadow boundary. Walking the roots finds them
all, correctly sized.

That is worth more than the coverage it cost: the obvious way to look at this
path returns a convincing wrong answer, so the first person to check concludes it
is broken. The helper that walks the roots carries that warning next to it.

What the test asserts

The zoom promise rests on a different mechanism here than on the SVG path.
WaveSurfer bars are configured in pixels (barWidth 3, barGap 2), so they keep
their width across a zoom only if it re-renders rather than letting a
fixed-size canvas stretch.

Backing store width against CSS width is what separates the two, and it is now
measured:

1x 5x
Content width 910 px 4550 px
Canvases per lane 1 x 910 4000 + 550
Backing == CSS yes yes

WaveSurfer chunks at 4000 px, which is why a zoomed lane is two canvases rather
than one wide one. A stretched canvas would keep its 910 px backing store while
its box grew, and fails the assertion.

Verification

12 zoom tests pass, 78 browser tests overall. No production code changed: this is
coverage for behaviour that was already correct.

I said in #493 that the streaming path was reasoned about rather than measured,
because looking for its canvases found none:

    document.querySelector("#multitrack-container").querySelectorAll("canvas")
    // 0

after eight seconds, with the overlay cleared, canplay fired and no failed
requests. That was convincing and wrong. WaveSurfer renders into shadow roots
and querySelectorAll does not cross a shadow boundary. Walking the roots finds
nine canvases, correctly sized, and a zoom re-renders them: 910px each at 1x,
and at 5x a 4550px lane cut into 4000 + 550, backing store matching CSS width
in every case.

So there was nothing to fix, and the gap was mine. The path is covered now, and
the assertion is the one that matters on it: WaveSurfer bars are configured in
pixels, so they keep their width across a zoom only if it re-renders rather than
letting a fixed-size canvas stretch. Backing width equal to CSS width is what
distinguishes the two, and a stretched canvas fails it.

The shadow-root walk lives in a helper with the trap written down next to it,
because the next person to look for a canvas here will otherwise reach the same
false conclusion.

Closes #494
@thcp
thcp merged commit 71a10f9 into main Aug 29, 2026
10 checks passed
@thcp
thcp deleted the test/streaming-zoom-coverage branch August 29, 2026 17:55
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.

The streaming render path is untested, and looking for its canvases the obvious way says it is broken

1 participant