Skip to content
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

Make data channels transferable to DedicatedWorker #2988

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions amendments.json
Original file line number Diff line number Diff line change
Expand Up @@ -1017,5 +1017,84 @@
"web-platform-tests/wpt#47663"
]
}
],
"webidl-rtcdatachannel": [
{
"description": "Make RTCDataChannel transferable to DedicatedWorker",
"pr": 2988,
"type": "addition",
"status": "candidate",
"id": 48,
"tests": [
"webrtc/transfer-datachannel.html"
],
"testUpdates": [
"web-platform-tests/wpt#47707"
]
}
],
"rtcdatachannel-istransferable-init-1": [
{
"description": "Make RTCDataChannel transferable to DedicatedWorker",
"pr": 2988,
"type": "addition",
"status": "candidate",
"difftype": "append",
"id": 48,
"tests": [
"webrtc/transfer-datachannel.html"
],
"testUpdates": [
"web-platform-tests/wpt#47707"
]
}
],
"rtcdatachannel-istransferable-init-2": [
{
"description": "Make RTCDataChannel transferable to DedicatedWorker",
"pr": 2988,
"type": "addition",
"status": "candidate",
"difftype": "append",
"id": 48,
"tests": [
"webrtc/transfer-datachannel.html"
],
"testUpdates": [
"web-platform-tests/wpt#47707"
]
}
],
"rtcdatachannel-send-istransferable": [
{
"description": "Make RTCDataChannel transferable to DedicatedWorker",
"pr": 2988,
"type": "addition",
"status": "candidate",
"difftype": "append",
"id": 48,
"tests": [
"webrtc/transfer-datachannel.html"
],
"testUpdates": [
"web-platform-tests/wpt#47707"
]
}
],
"transfering-a-data-channel": [
{
"description": "Make RTCDataChannel transferable to DedicatedWorker",
"pr": 2988,
"type": "addition",
"status": "candidate",
"difftype": "append",
"id": 48,
"tests": [
"webrtc/transfer-datachannel.html"
],
"testUpdates": [
"web-platform-tests/wpt#47707"
]
}
]
}
2 changes: 1 addition & 1 deletion base-rec.html
Original file line number Diff line number Diff line change
Expand Up @@ -13891,7 +13891,7 @@ <h4 id="x6-2-7-receiving-messages-on-a-data-channel"><bdi class="secno">6.2.7 </
</ol>
</section>
<div>
<pre class="idl has-tests def" data-tests="idlharness.https.window.js" id="webidl-1143016005"><span class="idlHeader"><a class="self-link" href="#webidl-1143016005">WebIDL</a></span><span data-idl="" class="idlInterface" id="idl-def-rtcdatachannel" data-title="RTCDataChannel">[<span class="extAttr"><a data-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed">Exposed</a>=<a data-type="interface" href="https://html.spec.whatwg.org/multipage/window-object.html#window">Window</a></span>]
<pre class="idl has-tests def" data-tests="idlharness.https.window.js" id="webidl-rtcdatachannel"><span class="idlHeader"><a class="self-link" href="#webidl-1143016005">WebIDL</a></span><span data-idl="" class="idlInterface" id="idl-def-rtcdatachannel" data-title="RTCDataChannel">[<span class="extAttr"><a data-type="extended-attribute" href="https://heycam.github.io/webidl/#Exposed">Exposed</a>=<a data-type="interface" href="https://html.spec.whatwg.org/multipage/window-object.html#window">Window</a></span>]
interface <a class="internalDFN idlID" data-link-type="interface" href="#dom-rtcdatachannel" id="ref-for-dom-rtcdatachannel-42"><code>RTCDataChannel</code></a> : <span class="idlSuperclass"><a data-type="interface" href="https://dom.spec.whatwg.org/#eventtarget">EventTarget</a></span> {<span data-idl="" class="idlAttribute" id="idl-def-rtcdatachannel-label" data-title="label" data-dfn-for="RTCDataChannel">
readonly attribute<span class="idlType"> <a data-type="interface" href="https://heycam.github.io/webidl/#idl-USVString">USVString</a></span> <a class="internalDFN idlName" data-link-type="attribute" href="#dom-datachannel-label" id="ref-for-dom-datachannel-label-1"><code>label</code></a>;</span><span data-idl="" class="idlAttribute" id="idl-def-rtcdatachannel-ordered" data-title="ordered" data-dfn-for="RTCDataChannel">
readonly attribute<span class="idlType"> <a data-type="interface" href="https://heycam.github.io/webidl/#idl-boolean">boolean</a></span> <a class="internalDFN idlName" data-link-type="attribute" href="#dom-datachannel-ordered" id="ref-for-dom-datachannel-ordered-1"><code>ordered</code></a>;</span><span data-idl="" class="idlAttribute" id="idl-def-rtcdatachannel-maxpacketlifetime" data-title="maxPacketLifeTime" data-dfn-for="RTCDataChannel">
Expand Down
52 changes: 49 additions & 3 deletions webrtc.html
Original file line number Diff line number Diff line change
Expand Up @@ -14042,6 +14042,14 @@ <h4>
<dfn data-dfn-for="RTCDataChannel">[[\Negotiated]]</dfn>, and <dfn data-dfn-for="RTCDataChannel">[[\DataChannelId]]</dfn>.
</p>
</li>
<li id="rtcdatachannel-istransferable-init-1">Let <var>channel</var> have a <dfn data-dfn-for="RTCDataChannel">[[\IsTransferable]]</dfn> internal slot initialized to <code>true</code>.</li>
<li id="rtcdatachannel-istransferable-init-2">[=Queue a task=] to run the following step:<ol>
<li>Set <var>channel</var>.{{RTCDataChannel/[[IsTransferable]]}} to <code>false</code>.
</li>
</ol>
<p>This task needs to run before any task enqueued by the [=receiving messages on a data channel=] algorithm for <var>channel</var>.
This ensures that no message is lost during the transfer of a {{RTCDataChannel}}.</p>
</li>
<li class="no-test-needed">
<p>
Return <var>channel</var>.
Expand Down Expand Up @@ -14256,7 +14264,7 @@ <h4>
</section>
<section>
<h4>
Announcing a data channel as closed
<dfn class="abstract-op">Announcing a data channel as closed</dfn>
</h4>
<p>
When an {{RTCDataChannel}} object's [= underlying data transport =]
Expand Down Expand Up @@ -14302,6 +14310,42 @@ <h4>
</li>
</ol>
</section>
<section id="transfering-a-data-channel">
<h4>Transfering data channel</h4>
<p>The {{RTCDataChannel}} [=transfer steps=], given <var>value</var> and <var>dataHolder</var>, are:</p>
<ol>
<li><p>If <var>value</var>.{{RTCDataChannel/[[IsTransferable]]}} is <code>false</code>, throw a {{DataCloneError}} DOMException.</p></li>
<li><p>Set <var>dataHolder</var>.{{RTCDataChannel/[[ReadyState]]}} to <var>value</var>.{{RTCDataChannel/[[ReadyState]]}}.</p></li>
<li><p>Set <var>dataHolder</var>.{{RTCDataChannel/[[DataChannelLabel]]}} to <var>value</var>.{{RTCDataChannel/[[DataChannelLabel]]}}.</p></li>
<li><p>Set <var>dataHolder</var>.{{RTCDataChannel/[[Ordered]]}} to <var>value</var>.{{RTCDataChannel/[[Ordered]]}}.</p></li>
<li><p>Set <var>dataHolder</var>.{{RTCDataChannel/[[MaxPacketLifeTime]]}} to <var>value</var>..{{RTCDataChannel/[[MaxPacketLifeTime]]}}</p></li>
<li><p>Set <var>dataHolder</var>.{{RTCDataChannel/[[MaxRetransmits]]}} to <var>value</var>.{{RTCDataChannel/[[MaxRetransmits]]}}.</p></li>
<li><p>Set <var>dataHolder</var>.{{RTCDataChannel/[[DataChannelProtocol]]}} to <var>value</var>.{{RTCDataChannel/[[DataChannelProtocol]]}}.</p></li>
<li><p>Set <var>dataHolder</var>.{{RTCDataChannel/[[Negotiated]]}} to <var>value</var>.{{RTCDataChannel/[[Negotiated]]}}.</p></li>
<li><p>Set <var>dataHolder</var>.{{RTCDataChannel/[[DataChannelId]]}} to <var>value</var>.{{RTCDataChannel/[[DataChannelId]]}}.</p></li>
<li><p>Set <var>dataHolder</var>’s [= underlying data transport =] to <var>value</var> [=underlying data transport=].</p></li>
<li><p>Set <var>value</var>.{{RTCDataChannel/[[IsTransferable]]}} to <code>false</code>.</p></li>
<li><p>Set <var>value</var>.{{RTCDataChannel/[[ReadyState]]}} to "closed".</p></li>
</ol>
</div>
<div><p>The {{RTCDataChannel}} [=transfer-receiving steps=], given <var>dataHolder</var> and <var>channel</var>, are:</p>
<ol>
<li><p>Initialize <var>channel</var>.{{RTCDataChannel/[[ReadyState]]}} to <var>dataHolder</var>.{{RTCDataChannel/[[ReadyState]]}}.</p></li>
<li><p>Initialize <var>channel</var>.{{RTCDataChannel/[[DataChannelLabel]]}} to <var>dataHolder</var>.{{RTCDataChannel/[[DataChannelLabel]]}}.</p></li>
<li><p>Initialize <var>channel</var>.{{RTCDataChannel/[[Ordered]]}} to <var>dataHolder</var>.{{RTCDataChannel/[[Ordered]]}}.</p></li>
<li><p>Initialize <var>channel</var>.{{RTCDataChannel/[[MaxPacketLifeTime]]}} to <var>dataHolder</var>.{{RTCDataChannel/[[MaxPacketLifeTime]]}}.</p></li>
<li><p>Initialize <var>channel</var>.{{RTCDataChannel/[[MaxRetransmits]]}} to <var>dataHolder</var>.{{RTCDataChannel/[[MaxRetransmits]]}}.</p></li>
<li><p>Initialize <var>channel</var>.{{RTCDataChannel/[[DataChannelProtocol]]}} to <var>dataHolder</var>.{{RTCDataChannel/[[DataChannelProtocol]]}}.</p></li>
<li><p>Initialize <var>channel</var>.{{RTCDataChannel/[[Negotiated]]}} to <var>dataHolder</var>.{{RTCDataChannel/[[Negotiated]]}}.</p></li>
<li><p>Initialize <var>channel</var>.{{RTCDataChannel/[[DataChannelId]]}} to <var>dataHolder</var>.{{RTCDataChannel/[[DataChannelId]]}}.</p></li>
<li><p>Initialize <var>channel</var>’s [=underlying data transport=] to <var>dataHolder</var>’s [= underlying data transport =].</p></li>
</ol>
<p>The above steps do not need to transfer {{RTCDataChannel/[[BufferedAmount]]}} as its value will always be equal to <code>0</code>.
The reason is an {{RTCDataChannel}} can be transferred only if its [=send() algorithm=] was not called prior the transfer.</p>
<p>If the [=underlying data transport=] is closed at the time of the [=transfer-receiving steps=],
the {{RTCDataChannel}} object will be closed by running the [=announcing a data channel as closed=] algorithm immediately after the [=transfer-receiving steps=].</p>

</section>
<section>
<h4>
Error on creating data channels
Expand Down Expand Up @@ -14347,7 +14391,7 @@ <h4>
</section>
<section>
<h4>
Receiving messages on a data channel
<dfn class="abstract-op">Receiving messages on a data channel</dfn>
</h4>
<p>
When an {{RTCDataChannel}} message has
Expand Down Expand Up @@ -14432,7 +14476,7 @@ <h4>
</ol>
</section>
<div>
<pre class="idl" data-tests="idlharness.https.window.js">[Exposed=Window]
<pre class="idl" id="webidl-rtcdatachannel" data-tests="idlharness.https.window.js">[Exposed=(Window,DedicatedWorker), Transferable]
interface RTCDataChannel : EventTarget {
readonly attribute USVString label;
readonly attribute boolean ordered;
Expand Down Expand Up @@ -14794,6 +14838,8 @@ <h2>
which data is to be sent.
</p>
</li>
<li id="rtcdatachannel-send-istransferable"><p>Set <var>channel</var>.{{RTCDataChannel/[[IsTransferable]]}} to <code>false</code>.</p></li>

<li data-tests="RTCDataChannel-send.html">
<p>
If <var>channel</var>.{{RTCDataChannel/[[ReadyState]]}} is not
Expand Down
Loading