Repository navigation
TST fix intermittent blank frame in the MP4 playback check - #767
Open
kroq-gar78 wants to merge 2 commits into
Open
kroq-gar78 wants to merge 2 commits into
kroq-gar78 wants to merge 2 commits into
Conversation
Annotate test_rendering_downloads_an_mp4 and the helpers it uses: _render_setup, _mp4_boxes, _find_box, _play_mp4, _js_value and _js_attrs. A recursive _Box alias describes the MP4 box tree. _find_box now asserts that the box it returns holds data rather than child boxes, and the test asserts that fps is a number, so the rest type-checks under mypy.
The playback check drew the video into a canvas on loadeddata, but Chromium can fire loadeddata before the first decoded frame is ready to draw. drawImage then paints nothing, and the test failed intermittently with lit == 0 although the file was well formed. Wait instead for requestVideoFrameCallback, which fires once a frame has been presented, and report an error if none is within 10 s. Under contention (16 concurrent playbacks on 24 cores) the loadeddata page gave lit 0 in 10 of 400 runs, each time with a fully transparent canvas, i.e. nothing drawn rather than a black frame. The requestVideoFrameCallback page gave the full frame in 400 of 400. A black H.264 video still fails on lit, and truncated or garbage files fail with a decode error.
kroq-gar78
marked this pull request as ready for review
October 23, 2026 00:17
This branch has not been deployed
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.
test_rendering_downloads_an_mp4fails intermittently on CI with:indicating that the rendered frame is blank.
Likely cause
The MP4 is fine, but the check that plays it back is racy. The test loads the file into a
<video>and draws it into a canvas onloadeddata. Chromium can fireloadeddatabefore the first decoded frame reaches the element, sodrawImagedraws nothing and every pixel reads as unlit.Evidence, from playing one saved MP4 repeatedly with the old page under load (16 playbacks at once on 24 cores):
lit == 0in 10 of 400 runs. The other 390 drew the full frame from the same file.Fix
The playback page now waits for
video.requestVideoFrameCallback, which fires once a frame has been presented, and then draws it once. If no frame arrives within 10 s, it returns an error. A frame normally arrives within 20 ms; the slowest run under load took 141 ms.Under the same load the new page drew the full frame in 400 of 400 runs. Bad files still fail: an all-black video fails the
litcheck, and truncated or garbage files fail with a decode error.