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

> according https://github.com/whatwg/streams/blob/main/FAQ.md:


The FAQ is trying to be helpful and reflect the (current) spec, but is not authoritative I don't think. If we improve the spec's "fit" for real-time streams (through issues like this one, https://github.com/whatwg/streams/issues/1156 and https://github.com/whatwg/streams/issues/1158), we should update the FAQ.

FWIW the spec's [Introduction](https://streams.spec.whatwg.org/#intro) says _"the Streams Standard enables use cases like: • Video effects: piping a readable video stream through a transform stream that applies effects in real time."_

> 2. Consumers care about the logical concatenation of all chunks of the stream, such that every value produced is important.

As a criteria of exclusion, this seems inaccurate, since consumers are free to [drop data](https://jsfiddle.net/jib1/rfp9jqnx/):
```js
numbers
  .pipeThrough(new TransformStream({transform: (chunk, ctrl) => chunk % 2 || ctrl.enqueue(chunk)}))
  .pipeTo(new WritableStream({write: c => console.log(c)})); // 0, 2, 4, 6, 8, 10
```
I also see no prohibition on sources (whether a camera or a WebTransport datagram receiver) dropping data as a solution to back pressure.

> 3. Your usual use case is a single consumer, with allowances for multi-consumer via teeing.

I think this fits, modulo this issue. Most use cases will be single consumer; a few might be multi-consumer, like [this cropping example with both self-view and video "sending"](https://jsfiddle.net/jib1/g5t3ovn8/) that works in Chrome (with _"Experimental Web Platform features"_ enabled).

> Point 4 is also debatable: errors are not a type of data and errors are generally recoverable in a video processing pipeline.

I doubt camera source errors are recoverable. Do you mean WebCodecs errors? While writing the above fiddle, the error I ran into most was "frame closed", due to VideoFrame's lifetime issues. I solved those with a custom version of `tee()` that both synchronizes and clones, the way this issue and  https://github.com/whatwg/streams/issues/1156 propose.

-- 
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-916501745

Received on Thursday, 9 September 2021 23:11:52 UTC