Skip to content

(Issue #27) Fix rendering stalling on multi-segment timelines#33

Open
SimonMav wants to merge 1 commit into
supermosh:mainfrom
SimonMav:main
Open

(Issue #27) Fix rendering stalling on multi-segment timelines#33
SimonMav wants to merge 1 commit into
supermosh:mainfrom
SimonMav:main

Conversation

@SimonMav

@SimonMav SimonMav commented Jul 4, 2026

Copy link
Copy Markdown

Chunks from each clip start their timestamps at 0, so concatenating segments (or repeating one) makes the timestamps jump backwards. Chrome's VideoDecoder doesn't like that and closes the codec, which then spams "decode on a closed codec" errors and stalls the render.
Rendering would pause partway through and the console filled up with:

Uncaught InvalidStateError: Failed to execute 'decode' on 'VideoDecoder':
Cannot call 'decode' on a closed codec.

Happens whenever the timeline has more than one segment (or a segment repeated). Each clip's
chunks carry timestamps starting from 0, so once we stitch them together the
timestamps reset backwards at every boundary. The decoder rejects the
backwards jump, closes itself, and the setInterval keeps hammering decode()
on the dead codec, leading to the "pausing" and the error spam.

Fix is to renumber the timestamps into a single monotonic sequence before
feeding them to the decoder. Types (key/delta) are left untouched so the
mosh effect still works.

Chunks from each clip start their timestamps at 0, so concatenating
segments (or repeating one) makes the timestamps jump backwards. Chrome's
VideoDecoder doesn't like that and closes the codec, which then spams
"decode on a closed codec" errors and stalls the render.

Rewrite the timestamps into one increasing sequence before decoding.
@ninofiliu

Copy link
Copy Markdown
Collaborator

Interesting, thanks for the contribution!

Can you provide a video and a screenshot of the timeline that produces such a bug? Like that I'll be able to reproduce the issue and rapidly check if your fix fixes it.

It smells like a good fix because I had to implement something similar in the v3.

@ninofiliu ninofiliu self-assigned this Jul 9, 2026
@ninofiliu ninofiliu added the bug Something isn't working label Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants