Re: [whatwg/streams] Allow web devs to synchronize branches with tee()? (#1157)

> This would help ensure both branches stay real-time, at the cost of both dropping frames if one of them lags.

It's starting to sound like readable streams may not be a good fit for this use case... In the streams model, it is not acceptable to drop chunks in the middle of the stream. From [the FAQ](https://github.com/whatwg/streams/blob/5d86b65e45e0d56fcb8fbbff52fbbf2394918154/FAQ.md):

> Readable streams fit best in situations where:
>
> - Consumers care about the logical concatenation of all chunks of the stream, such that every value produced is important.

If I understand the draft spec correctly, the `MediaStreamTrackProcessor` is allowed to drop frames if nobody is actively reading from the stream. But as soon as a frame is enqueued onto the stream, it becomes part of this "logical concatenation" and mustn't be dropped by a branch from `tee()`, no matter how fast/slow the branch is being consumed. That is, this should *always* be true:
```javascript
const [branch1, branch2] = readable.tee();
let chunks1 = [];
let chunks2 = [];
for await (let chunk of branch1) chunks1.push(chunk);
for await (let chunk of branch2) chunks2.push(chunk);
chunks1.forEach((chunk, i) => chunk === chunks2[i]);
```

Looks like you're running into much of the same issues [as WebCodecs did](https://github.com/w3c/webcodecs/blob/a044235116df03f3a97f574a1a546e45eff26346/explainer.md#integrating-with-whatwg-streams). 😕 

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/1157#issuecomment-893280417

Received on Thursday, 5 August 2021 08:45:11 UTC