-
Notifications
You must be signed in to change notification settings - Fork 680
Description
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:
rerun/crates/viewer/re_renderer/src/renderer/video/decoder/web.rs
Lines 25 to 29 in 5df2aed
| 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:
rerun/crates/viewer/re_renderer/src/renderer/video/decoder/web.rs
Lines 89 to 97 in 5df2aed
| 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.