Skip to content

Chrome warn "VideoFrame was garbage collected without being closed" #7327

@jprochazk

Description

@jprochazk

When playing back video, the console periodically receives this error message:

localhost/:1 A VideoFrame was garbage collected without being closed. Applications should call close() on frames when done with them to prevent stalls.

The thing is... we are calling close on every frame already:

impl Drop for VideoFrame {
fn drop(&mut self) {
self.0.close();
}
}

The instant we receive a web_sys::VideoFrame from the decoder, we wrap it in a struct that calls close on drop:

let decoder = init_video_decoder({
let frames = frames.clone();
move |frame: web_sys::VideoFrame| {
frames.lock().push((
TimeMs::new(frame.timestamp().unwrap_or(0.0)),
VideoFrame(frame),
));
}
})?;

I believe it should be impossible for us to not be calling close.

In the first place, the browser VideoDecoder refuses to decode more than ~10 frames at a time, and until the oldest one is closed, it will not produce any more, no matter how many EncodedVideoChunks we give it. That's the "stall" the error message is talking about. Our decoder would not work at all if we weren't calling close! Either I'm missing something obvious, or there's a bug in Chromium.

This doesn't seem to cause any issues such as memory leaks or unnecessary slowness of any kind, so it's only an annoyance, because we would like to not be spewing errors into the console all the time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feat-videoanything video decoding, player, querying, data modelling of videos etc.🕸️ webregarding running the viewer in a browser😤 annoyingSomething in the UI / SDK is annoying to use🪳 bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions