Skip to content

@remotion/media: Close decoded video frames when rendering throws - #13747

Open
alec-watts wants to merge 2 commits into
remotion-dev:mainfrom
alec-watts:codex/close-render-frame
Open

alec-watts wants to merge 2 commits into
remotion-dev:mainfrom
alec-watts:codex/close-render-frame

Conversation

@alec-watts

Copy link
Copy Markdown
Contributor

A render-mode <Video> borrows its decoded frame to onVideoFrame, draws it and optionally awaits effects. An exception in any of those steps could bypass the final close().

Keep the frame alive through the last consumer and close it in finally, including when an effect returns early. The existing render error continues to propagate.

The browser regression renders a still from the existing WebM fixture, throws from the callback, and checks the original error and the close count on that specific frame. On the base commit, it observed zero closes. With this change, it observes one.

@vercel

vercel Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
bugs Ready Ready Preview Dec 2, 2026 7:36pm UTC
remotion Ready Ready Preview Dec 2, 2026 7:36pm UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-02T19:35:34.226532Z 2429f8b New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Approach: sound — a try/finally around the borrowed frame guarantees close() on every exit path.

Reviewed changes: the full diff (2 files), plus the surrounding code in video-for-rendering.tsx.

  • finally close in VideoForRendering: imageBitmap.close() now runs in finally, covering throws from onVideoFrame, drawImage and runEffectChain. The early return after an incomplete effect chain is covered too, and the explicit close() there is removed. Behavior is otherwise unchanged.
  • Regression test in video.test.tsx: renders a still from the existing WebM fixture, throws from onVideoFrame, and asserts the original error propagates and close is called once. It also swallows the duplicate unhandledrejection that cancelRender produces.

Pullfrog  | View workflow run | Using claude-sonnet-5-5 | 𝕏

This branch was successfully deployed

2 active deployments
Preview – remotion — 2429f8b0 Deployed Dec 2, 2026 by vercel[bot]
Preview – bugs — 2429f8b0 Deployed Dec 2, 2026 by vercel[bot]
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