-
Notifications
You must be signed in to change notification settings - Fork 19
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
Describe more precisely transfered track lifetime management. #30
Conversation
This PR needs more work, in particular to add more links to external concepts. |
Yes, this needs more work. In particular, the PR does not consider sources that might themselves be transferable, or might not be relevant to the originating context. The rules suggested (such as privacy indicators) are appropriate for cameras and microphones, and something like this is probably the right behavior for those devices. But generalizing this to all track sources is not appropriate. I do not believe the addition of a concrete TransformStream as the method for communicating between the source and the track is appropriate at all; it's possible that one can describe this as an abstract operation with the same properties as if one had a TransformStream, but the concrete-sounding description of this non-observable behavior is not useful. |
Can you give more details about transferable sources and why we should have special treatment for them? All current 'sources' I know of are tied to their originating context: getUserMedia, getDisplayMedia, WebAudio, RTCPeerConnection, HTMLMediaElement. The PR works for all of them. Looking at the proposed MediaCaptureTrackGenerator, its writable can be transferred but its writable is not the source. I have some difficulties to reason about transferable sources since sources are more a concept than a JS object.
We can extend the algorithm to 'transferable' sources once we have a common understanding of what is a transferable source and whether that is useful to optimize. For instance, sources could have a boolean [isTransferable] slot. If so, we could transfer the source (like we do for the readable in the current algorithm). I do not see transferable source handling as a blocker to the current proposal, more as a follow-up issue.
An algorithm is usually better as it is more precise. To help the reader, I am fine adding some text that is describing what our intent is. |
c858bbe
to
c83ae05
Compare
To focus the discussion on lifetime management properties first, I removed the algorithm and made the rules become MUST statements. Feedback most welcome! |
The two cases I can think of that matter are OffscreenCanvas (if it supports capturing) and GetDisplayMedia; in both cases, it's not clear to me that it's logical to make the track dependent on the original context. |
Co-authored-by: Jan-Ivar Bruaroey <jan-ivar@users.noreply.github.com>
Co-authored-by: Jan-Ivar Bruaroey <jan-ivar@users.noreply.github.com>
.... and now that I think of it, indicators are a browser element, not a renderer element ... which means that sticking with the original frame as the owner of a source flies somewhat against the idea of "transferring an object as a capability" that @annevk argued for. |
Co-authored-by: Jan-Ivar Bruaroey <jan-ivar@users.noreply.github.com>
If this closes #29 a follow-up should be filed as both serialization and transferring are to be defined as two sets of steps. |
The spec contains the two set of steps but in a minimal way that does not address lifetime management. |
We should probably put the horse before the cart and concentrate first on what lifetime properties we want, and document those. |
This is editorial. MediaStreamTracks already have well-established lifetime properties. Sure, making them transferable challenges us to revisit those properties, but until we do, they are still there — because a lot of privacy and security considerations rely on them — so we should clarify them vis-a-vis transfer until we decide to change them. Any concerns over decision lock-in seem unwarranted, because these assumptions are already there. We just made a mistake introducing ambiguity that wasn't there before. But such new ambiguity does not override previous decisions. Thus this PR is the conservative way to iterate here and should be merged asap IMHO. |
I honestly thought we had consensus on these properties when we discussed them during March interim and at the editor's meeting we decided to merge the initial PR specifying the two sets of steps. This PR is trying to reflect that in English and not as an algorithm based on your feedback. getDisplayMedia tracks, like getUserMedia tracks, are bound to the context they are created in. I validated that Chrome, Firefox and Safari all stop getDisplayMedia tracks when its context is navigating away. We are building on that to be as conservative as possible. This does not prevent to be more ambitious in the future if we have further use cases. As of OffscreenCanvas, we cannot capture from it but from a canvas dom element which is not transferable. |
I will have to return to this issue two weeks from now, but sketching out some approaches (that need detailing). One approach: In the model of [[mediacapture-main]], a track is inextricably linked to a source. Sources are non-JS-visible objects that exist in a single Javascript context, and it is part of the definition of a source that it can never be moved from that context, and dies when that context dies. A transferred MediaStreamTrack retains its linkage to the original source; when the context dies (this term has to find its exact definition), the source ceases to exist, and the track ends. This is a cross-context observable event. |
Another approach: In the model of [[mediacapture-main]], a track is inextricably linked to a source. Some sources are not JS-visible objects; others are JS-visible objects, which may or may not be transferable. The currently defined sources of tracks include:
|
This seems like a good addition to me. I would tend to go with proposal 1. In my mental model, a DOM object or a device is not a source. |
I uploaded a PR in mediacapture-main to tackle this issue at w3c/mediacapture-main#805. |
Fixes #29.
Preview | Diff