Closed Bug 1209163 Opened 10 years ago Closed 6 months ago

[Meta] Make RTCDataChannels transferable (to workers)

Categories

(Core :: WebRTC: Networking, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
144 Branch
Tracking Status
relnote-firefox --- 144+
firefox144 --- fixed

People

(Reporter: jesup, Assigned: bwc)

References

(Blocks 1 open bug)

Details

(4 keywords)

Attachments

(8 files, 1 obsolete file)

From my posting to the W3 public-webrtc list. The PR is 317 Use-case: A number of applications using RTCDataChannels would benefit from being able to process the data and send data from a Worker. An example of this is a game which handles state updates and other processing in a Worker, keeping the mainthread application free to handle rendering and UI interactions, and avoiding or minimizing GC pauses. Basic Mechanism: The RTCDataChannel would be a transferrable object, which can be sent via postMessage: channel = createDataChannel("MyChannel", {}); // or we're in an ondatachannel callback/event triggered by the other // side creating an RTCDataChannel worker.postMessage(channel, [channel]); // channel is now owned by the worker; no more events will occur on the // sender's version of 'channel' The worker will receive the object, and can set event handlers on it. Handling of Events: After a transfer, all events occur in the worker, and the worker must set up event handlers to process them. Any events that occur during the transfer, or that were queued to be fired in the sender, will be held until the worker gets the transferred object. This means the worker should set EventHandlers on the channel immediately on receiving the channel. Close: The worker can call channel.close(), which will operate normally. If the PeerConnection is shut down via peerconnection.close(), or if the RTCDataChannel m=application line is renegotiated 'off', then the worker will receive a close event for the channel, as normal. An RTCDataChannel may be transferred at any time, and may be transferred more than once.
backlog: --- → webrtc/webaudio+
Rank: 25
Rank: 25 → 15
Priority: P2 → P1
Rank: 15 → 23
Priority: P1 → P2
Mass change P2->P3 to align with new Mozilla triage process.
Priority: P2 → P3

Hi Byron, is this on the roadmap at all?

Flags: needinfo?(docfaraday)

We do not have any near-term plan to implement this at the moment, since we have an excess of P1/P2 work.

Flags: needinfo?(docfaraday)
Severity: normal → S3
Type: defect → enhancement

Something like this can't be polyfilled nicely. would be great if this could be supported natively πŸ™

Besides Safari this now also has been implemented by Blink (will be available in Chrome v130).

Severity: S3 → S2
Rank: 23
Keywords: dev-doc-neededmeta
Summary: Make RTCDataChannels transferable (to workers) → [Meta] Make RTCDataChannels transferable (to workers)
Priority: P3 → --
backlog: webrtc/webaudio+ → ---

@jim and all.

How about the features. the features is critical to Zoom's web client. Which could make audio/video media data transfer be more stable without the impact of UI. Could you prioritize the features. Thanks

Assignee: nobody → docfaraday
Severity: S2 → S3
Depends on: 1974443

This will be necessary once it is possible for an RTCDataChannel to be
on a worker.

Depends on D260562

Includes a shim and corresponding worker code that allows mainthread test code
to use a transferred RTCDataChannel very similarly to a mainthread
RTCDataChannel, to make it easy to write tests quickly, and adapt existing test
code to the transferred RTCDataChannel case.

Depends on D261659

We want this because RTCDataChannels often have events dispatched to them
before we know what thread they will actually be operating on.

This class allows us to dispatch events as normal while we are in this
indeterminate state, and when we learn what the event target will be, connect
it and allow the events to flow.

For example, it is possible for an RTCDataChannel to be created on an already
active SCTP transport that is already firing events. We do not want those
events to go to main until we know that is where the datachannel will live. As
another example, it is possible for JS to create a data channel, make a
getStats call, and then transfer that data channel; we do not want the event
dispatch for that getStats call to be sent to main, we want it to go to the
worker, but the worker thread has not even been created yet.

Depends on D261660

We don't want to try to do this on a worker when we create an RTCDataChannel there.

Depends on D261661

Depends on D261662

Depends on D261663

Attachment #9506174 - Attachment is obsolete: true
Attachment #9506173 - Attachment description: WIP: Bug 1209163: Use MozPromise for datachannel stats gathering. → Bug 1209163: Use MozPromise for datachannel stats gathering. r?ng
Attachment #9508003 - Attachment description: WIP: Bug 1209163: Re-enable and fix existing test-cases for RTCDataChannel transfer. → Bug 1209163: Re-enable and fix existing test-cases for RTCDataChannel transfer. r?jib
Attachment #9508004 - Attachment description: WIP: Bug 1209163: Expand test-cases for RTCDataChannel transfer. → Bug 1209163: Expand test-cases for RTCDataChannel transfer. r?jib
Attachment #9508005 - Attachment description: WIP: Bug 1209163: StopGapEventTarget, a wrapper whose underlying target can be set after events have been dispatched. → Bug 1209163: StopGapEventTarget, a wrapper whose underlying target can be set after events have been dispatched. r?#xpcom-reviewers
Attachment #9508006 - Attachment description: WIP: Bug 1209163: Calculate the origin string once in PeerConnection init, instead of separately for every datachannel. → Bug 1209163: Calculate the origin string once in PeerConnection init, instead of separately for every datachannel. r?ng
Attachment #9508007 - Attachment description: WIP: Bug 1209163: This can be const. → Bug 1209163: This can be const. r?ng
Attachment #9508008 - Attachment description: WIP: Bug 1209163: Tighten up thread assertions. → Bug 1209163: Tighten up thread assertions. r?ng
Attachment #9508011 - Attachment description: WIP: Bug 1209163: (WIP) Implement RTCDataChannel transfer. → Bug 1209163: Implement RTCDataChannel transfer. r?ng!,#webidl!,#dom-core!
Duplicate of this bug: 1969293
Pushed by bcampen@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/6ff3d441b593 https://hg.mozilla.org/integration/autoland/rev/9ff70fdb5764 Use MozPromise for datachannel stats gathering. r=ng https://github.com/mozilla-firefox/firefox/commit/ead4f7d733bf https://hg.mozilla.org/integration/autoland/rev/2216cbf444b6 Re-enable and fix existing test-cases for RTCDataChannel transfer. r=jib https://github.com/mozilla-firefox/firefox/commit/9c92e0b999e5 https://hg.mozilla.org/integration/autoland/rev/ab7d3e0055c5 Expand test-cases for RTCDataChannel transfer. r=jib https://github.com/mozilla-firefox/firefox/commit/5c3ceb9d3330 https://hg.mozilla.org/integration/autoland/rev/2e3ec5c1c5b8 StopGapEventTarget, a wrapper whose underlying target can be set after events have been dispatched. r=xpcom-reviewers,nika https://github.com/mozilla-firefox/firefox/commit/593ae753b71c https://hg.mozilla.org/integration/autoland/rev/562dcf9a1628 Calculate the origin string once in PeerConnection init, instead of separately for every datachannel. r=ng https://github.com/mozilla-firefox/firefox/commit/19478ecafd24 https://hg.mozilla.org/integration/autoland/rev/329ebbc61718 This can be const. r=ng https://github.com/mozilla-firefox/firefox/commit/422443faa1d7 https://hg.mozilla.org/integration/autoland/rev/4bd86004f4c5 Tighten up thread assertions. r=ng https://github.com/mozilla-firefox/firefox/commit/439d0a878078 https://hg.mozilla.org/integration/autoland/rev/0ca166528417 Implement RTCDataChannel transfer. r=ng,webidl,smaug,asuth https://github.com/mozilla-firefox/firefox/commit/46d8b7408303 https://hg.mozilla.org/integration/autoland/rev/d6d506d58c91 1611953, 1884458, 1981202, 1983831: apply code formatting via Lando
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/54706 for changes under testing/web-platform/tests
Regressions: 1987064
Pushed by bcampen@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/04ab0ce9a292 https://hg.mozilla.org/integration/autoland/rev/4e3d560c9d7c Use MozPromise for datachannel stats gathering. r=ng https://github.com/mozilla-firefox/firefox/commit/51567d99ad76 https://hg.mozilla.org/integration/autoland/rev/e0dbd4eb11c0 Re-enable and fix existing test-cases for RTCDataChannel transfer. r=jib https://github.com/mozilla-firefox/firefox/commit/441057e0f4e1 https://hg.mozilla.org/integration/autoland/rev/beb3cb7b25d6 Expand test-cases for RTCDataChannel transfer. r=jib https://github.com/mozilla-firefox/firefox/commit/310807b93ff3 https://hg.mozilla.org/integration/autoland/rev/c5a258eed227 StopGapEventTarget, a wrapper whose underlying target can be set after events have been dispatched. r=xpcom-reviewers,nika https://github.com/mozilla-firefox/firefox/commit/2e797c543417 https://hg.mozilla.org/integration/autoland/rev/509df70895ea Calculate the origin string once in PeerConnection init, instead of separately for every datachannel. r=ng https://github.com/mozilla-firefox/firefox/commit/98fc8a3084d9 https://hg.mozilla.org/integration/autoland/rev/cc55cc118195 This can be const. r=ng https://github.com/mozilla-firefox/firefox/commit/71684c97f7c3 https://hg.mozilla.org/integration/autoland/rev/9844ec340530 Tighten up thread assertions. r=ng https://github.com/mozilla-firefox/firefox/commit/2b36bae0880f https://hg.mozilla.org/integration/autoland/rev/77533c2f3136 Implement RTCDataChannel transfer. r=ng,webidl,smaug,asuth https://github.com/mozilla-firefox/firefox/commit/bfcca3129599 https://hg.mozilla.org/integration/autoland/rev/a821550ed296 1611953, 1884458, 1981202, 1983831: apply code formatting via Lando
Pushed by smolnar@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/9a817cb4a482 https://hg.mozilla.org/integration/autoland/rev/593c7df571d0 Revert "Bug 1209163, 1611953, 1884458, 1981202, 1983831: apply code formatting via Lando" for causing build bustages @ TestStopGapEventTarget.cpp
Pushed by bcampen@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/e292e126ba6b https://hg.mozilla.org/integration/autoland/rev/bcb61012ba9d Use MozPromise for datachannel stats gathering. r=ng https://github.com/mozilla-firefox/firefox/commit/80dcee8bd7b2 https://hg.mozilla.org/integration/autoland/rev/aa46fdf155fd Re-enable and fix existing test-cases for RTCDataChannel transfer. r=jib https://github.com/mozilla-firefox/firefox/commit/4d73afe4c92a https://hg.mozilla.org/integration/autoland/rev/a3a6ad306482 Expand test-cases for RTCDataChannel transfer. r=jib https://github.com/mozilla-firefox/firefox/commit/05f20b632e13 https://hg.mozilla.org/integration/autoland/rev/6ee9daf54357 StopGapEventTarget, a wrapper whose underlying target can be set after events have been dispatched. r=xpcom-reviewers,nika https://github.com/mozilla-firefox/firefox/commit/ab19147db3f8 https://hg.mozilla.org/integration/autoland/rev/8423f51240fd Calculate the origin string once in PeerConnection init, instead of separately for every datachannel. r=ng https://github.com/mozilla-firefox/firefox/commit/18ef532d3ce2 https://hg.mozilla.org/integration/autoland/rev/8efee5d1c515 This can be const. r=ng https://github.com/mozilla-firefox/firefox/commit/13424b57e915 https://hg.mozilla.org/integration/autoland/rev/0e6b64411c08 Tighten up thread assertions. r=ng https://github.com/mozilla-firefox/firefox/commit/965e644b8534 https://hg.mozilla.org/integration/autoland/rev/2965cdb041d3 Implement RTCDataChannel transfer. r=ng,webidl,smaug,asuth https://github.com/mozilla-firefox/firefox/commit/bd1ff89aa136 https://hg.mozilla.org/integration/autoland/rev/78b06c570470 1611953, 1884458, 1981202, 1983831: apply code formatting via Lando

Release Note Request (optional, but appreciated)
[Why is this notable]:
The ability to transfer RTCDataChannel to a worker is a long awaited feature in Firefox.

[Suggested wording]:
Implemented worker transfer for RTCDataChannel.

[Links (documentation, blog post, etc)]:
I guess https://w3c.github.io/webrtc-pc/#transfering-a-data-channel ?

relnote-firefox: --- → ?
Flags: needinfo?(docfaraday)

Thanks, added to the Fx144 nightly release notes, please allow 30 minutes for the site to update.
Keeping the relnote-firefox flag as ? to keep it on the radar for inclusion in the final Fx144 release notes.

Regressions: 1987936
Keywords: dev-doc-needed

This isn't in the FF144 MDN release project because no one added dev-doc-needed.

My assumption is that all this needs is an update to the MDN release note, addition of RTCDataChannel to the list in Transferable objects, and a fix to the compatibility data in https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannel#browser_compatibility for the transferrable key.

@Donal FYI for MDN the docs link we use for information about this kind of thing is Transferable objects. You might choose to use that instead of a spec link.

Flags: needinfo?(dmeehan)

Thanks Hamis. I changed the URL in the release notes to use https://developer.mozilla.org/docs/Web/API/Web_Workers_API/Transferable_objects.

Flags: needinfo?(dmeehan)

Added to the Fx144 release notes

Upstream PR was closed without merging
Upstream PR merged by moz-wptsync-bot
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: