Re: [mediacapture-transform] MSTP's VideoFrame lifetime management model assumes a single consumer (#56)

> `MediaStreamTrackProcessor` [appears to expect](https://w3c.github.io/mediacapture-transform/#video-processing) _consumers_ to call `VideoFrame.close()` manually. Unfortunately, this:
> 
> 1. Assumes a single consumer per VideoFrame

VideoFrames can be cloned and a separate clone can be passed to multiple consumers. Each clone should be closed, of course. Clone is an inexpensive operation  since it's just adding a reference to an underlying resource.

> 2. Creates a footgun where consumers may forget to call this method, with potentially devastating OS-level side-effects

What are those devastating side effects?
AFAICT, the only one that has been mentioned is exhausting a shared fixed pool of open underlying video frames, but implementations can limit the number of open underlying frames for a single page in order to prevent resource exhaustion. 

Automatic closing by MSTP might help with an application that accidentally forgets to close, but it is not useful against an application that intentionally keeps VideoFrames alive (e.g., by cloning them and not closing the clone). The effects of accidentally forgetting to close are normally very visible, so automatic closing is of very limited utility in practice.  

> 
> Ditto `MediaStreamTrackGenerator` which [calls](https://w3c.github.io/mediacapture-transform/#generator) `VideoFrame.close()` implicitly, preventing reuse with another sink. It too:
> 
> 1. Assumes a single consumer per VideoFrame

MSTG is a consumer of VideoFrame objects and does not have VideoFrame consumers. It closes VideoFrame objects automatically in order to allow piping to work well. Note that MSTG closes the JS VideoFrame objects. The underlying resources may still be alive after closing the VideoFrame, depending on the sinks to which MSTG is connected to.


I'm closing this issue since the premise is that MSTP assumes a single consumer, which is obviously incorrect.
The issue of resource exhaustion is separate and has also been discussed and addressed.

-- 
GitHub Notification of comment by guidou
Please view or discuss this issue at https://github.com/w3c/mediacapture-transform/issues/56#issuecomment-900053025 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 17 August 2021 07:13:03 UTC