-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a realtime mode to ReadableStream.tee #1186
Comments
In #1157 (comment), we discussed and prototyped a "synchronized" variant of If I understand correctly, this "realtime" variant is slightly different. It would pull from the original stream if at least one of the two branches is pulling, and only enqueue the received chunk to branches that are actively pulling. That way, we avoid overfilling the queue of the slower branch by "skipping" chunks. What should happen if one branch is only slightly slower than the other? That is:
I see two options:
Or perhaps some combination of these two, with some sort of "max age" to decide between enqueuing the previous chunk or pulling a new chunk? 🤷 |
My understanding was to go with this approach. |
This would imply that if |
Is "in the meantime" = anytime before a chunk newer than "new pull" is delivered to branch 2? (The pull promise is unreliable here imho) If the underlying source's internal queue is not empty, this would seem to devolve into delivering different chunks to each branch, pulling at a rate faster than either of the branches would have individually. I don't think we ever want to steal chunks from the fast branch, even if upstream has backed up.
This would appear to keep the pull rate = max(pull rate A, pull rate B), and expose mostly the same (cloned) frames, which seems desirable or at least easier to reason about.
Yes, though we need to solve that somehow anyway for when a stream is errored. |
Yes, that's what I meant.
Agreed. We also definitely don't want to pull faster than the fastest branch, because that could get very bad if you do multiple I probably should have thought a bit more about this option first, because now it sounds like an obviously bad idea. 😛
Yes, this seems much better. 👍
Yes, whatever solution we end up choosing for #1185 will also need to be integrated in We do have to be careful with how we design explicit closure. If we go with |
For realtime applications dealing with ReadableStreams of VideoFrames, it is very nice to be able to limit buffering between teed branches. This also ensures that both branches will receive the most recent video frame.
As discussed during today's WebRTC/WhatWG stream call, we could envision something like a tee({structuredClone: true, noBuffer: true}).
The text was updated successfully, but these errors were encountered: