From 3c0350f20d08410a2dc17624cb7f2ed573f7878f Mon Sep 17 00:00:00 2001 From: Dominique Hazael-Massieux Date: Wed, 21 Aug 2024 10:35:12 +0200 Subject: [PATCH 1/2] Make data channels transferable to DedicatedWorker Moved from https://w3c.github.io/webrtc-extensions/#rtcdatachannel-extensions based on discussion in https://github.com/w3c/webrtc-extensions/issues/214 related WPT migration https://github.com/web-platform-tests/wpt/pull/47707 --- amendments.json | 63 +++++++++++++++++++++++++++++++++++++++++++++++++ base-rec.html | 6 ++--- webrtc.html | 58 ++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 118 insertions(+), 9 deletions(-) diff --git a/amendments.json b/amendments.json index f9940b354..a300a61f6 100644 --- a/amendments.json +++ b/amendments.json @@ -1017,5 +1017,68 @@ "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-slots-init": [ + { + "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-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" + ] + } + ], + "announcing-a-data-channel-as-closed": [ + { + "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" + ] + } ] } diff --git a/base-rec.html b/base-rec.html index dcae1e086..59c762fe2 100644 --- a/base-rec.html +++ b/base-rec.html @@ -13525,7 +13525,7 @@

6.2.1 internal slot initialized to 0.

-
  • +
  • Let channel have internal slots named [[DataChannelLabel]], [[Ordered]], @@ -13891,7 +13891,7 @@

    6.2.7
    -
    WebIDL[Exposed=Window]
    +          
    WebIDL[Exposed=Window]
     interface RTCDataChannel : EventTarget {
       readonly attribute USVString label;
       readonly attribute boolean ordered;
    @@ -14231,7 +14231,7 @@ 

    steps:

      -
    1. +
    2. Let channel be the RTCDataChannel object on which data is to be sent. diff --git a/webrtc.html b/webrtc.html index 49d2f6a47..23395af74 100644 --- a/webrtc.html +++ b/webrtc.html @@ -14032,7 +14032,7 @@

      internal slot initialized to 0.

    3. -
    4. +
    5. Let channel have internal slots named [[\DataChannelLabel]], [[\Ordered]], @@ -14042,6 +14042,14 @@

      [[\Negotiated]], and [[\DataChannelId]].

    6. +
    7. Let channel have a [[\IsTransferable]] internal slot initialized to true.
    8. +
    9. [=Queue a task=] to run the following step:
        +
      1. Set channel.{{RTCDataChannel/[[IsTransferable]]}} to false. +
      2. +
      +

      This task needs to run before any task enqueued by the [=receiving messages on a data channel=] algorithm for channel. + This ensures that no message is lost during the transfer of a {{RTCDataChannel}}.

      +
    10. Return channel. @@ -14254,9 +14262,9 @@

    -
    +

    - Announcing a data channel as closed + Announcing a data channel as closed

    When an {{RTCDataChannel}} object's [= underlying data transport =] @@ -14302,6 +14310,42 @@

  • +
    +

    Transfering data channel

    +

    The {{RTCDataChannel}} [=transfer steps=], given value and dataHolder, are:

    +
      +
    1. If value.{{RTCDataChannel/[[IsTransferable]]}} is false, throw a {{DataCloneError}} DOMException.

    2. +
    3. Set dataHolder.{{RTCDataChannel/[[ReadyState]]}} to value.{{RTCDataChannel/[[ReadyState]]}}.

    4. +
    5. Set dataHolder.{{RTCDataChannel/[[DataChannelLabel]]}} to value.{{RTCDataChannel/[[DataChannelLabel]]}}.

    6. +
    7. Set dataHolder.{{RTCDataChannel/[[Ordered]]}} to value.{{RTCDataChannel/[[Ordered]]}}.

    8. +
    9. Set dataHolder.{{RTCDataChannel/[[MaxPacketLifeTime]]}} to value..{{RTCDataChannel/[[MaxPacketLifeTime]]}}

    10. +
    11. Set dataHolder.{{RTCDataChannel/[[MaxRetransmits]]}} to value.{{RTCDataChannel/[[MaxRetransmits]]}}.

    12. +
    13. Set dataHolder.{{RTCDataChannel/[[DataChannelProtocol]]}} to value.{{RTCDataChannel/[[DataChannelProtocol]]}}.

    14. +
    15. Set dataHolder.{{RTCDataChannel/[[Negotiated]]}} to value.{{RTCDataChannel/[[Negotiated]]}}.

    16. +
    17. Set dataHolder.{{RTCDataChannel/[[DataChannelId]]}} to value.{{RTCDataChannel/[[DataChannelId]]}}.

    18. +
    19. Set dataHolder’s [= underlying data transport =] to value [=underlying data transport=].

    20. +
    21. Set value.{{RTCDataChannel/[[IsTransferable]]}} to false.

    22. +
    23. Set value.{{RTCDataChannel/[[ReadyState]]}} to "closed".

    24. +
    + +

    The {{RTCDataChannel}} [=transfer-receiving steps=], given dataHolder and channel, are:

    +
      +
    1. Initialize channel.{{RTCDataChannel/[[ReadyState]]}} to dataHolder.{{RTCDataChannel/[[ReadyState]]}}.

    2. +
    3. Initialize channel.{{RTCDataChannel/[[DataChannelLabel]]}} to dataHolder.{{RTCDataChannel/[[DataChannelLabel]]}}.

    4. +
    5. Initialize channel.{{RTCDataChannel/[[Ordered]]}} to dataHolder.{{RTCDataChannel/[[Ordered]]}}.

    6. +
    7. Initialize channel.{{RTCDataChannel/[[MaxPacketLifeTime]]}} to dataHolder.{{RTCDataChannel/[[MaxPacketLifeTime]]}}.

    8. +
    9. Initialize channel.{{RTCDataChannel/[[MaxRetransmits]]}} to dataHolder.{{RTCDataChannel/[[MaxRetransmits]]}}.

    10. +
    11. Initialize channel.{{RTCDataChannel/[[DataChannelProtocol]]}} to dataHolder.{{RTCDataChannel/[[DataChannelProtocol]]}}.

    12. +
    13. Initialize channel.{{RTCDataChannel/[[Negotiated]]}} to dataHolder.{{RTCDataChannel/[[Negotiated]]}}.

    14. +
    15. Initialize channel.{{RTCDataChannel/[[DataChannelId]]}} to dataHolder.{{RTCDataChannel/[[DataChannelId]]}}.

    16. +
    17. Initialize channel’s [=underlying data transport=] to dataHolder’s [= underlying data transport =].

    18. +
    +

    The above steps do not need to transfer {{RTCDataChannel/[[BufferedAmount]]}} as its value will always be equal to 0. + The reason is an {{RTCDataChannel}} can be transferred only if its [=send() algorithm=] was not called prior the transfer.

    +

    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=].

    + +

    Error on creating data channels @@ -14347,7 +14391,7 @@

    - Receiving messages on a data channel + Receiving messages on a data channel

    When an {{RTCDataChannel}} message has @@ -14432,7 +14476,7 @@

    -
    [Exposed=Window]
    +          
    [Exposed=(Window,DedicatedWorker), Transferable]
     interface RTCDataChannel : EventTarget {
       readonly attribute USVString label;
       readonly attribute boolean ordered;
    @@ -14788,12 +14832,14 @@ 

    steps:

      -
    1. +
    2. Let channel be the {{RTCDataChannel}} object on which data is to be sent.

    3. +
    4. Set channel.{{RTCDataChannel/[[IsTransferable]]}} to false.

    5. +
    6. If channel.{{RTCDataChannel/[[ReadyState]]}} is not From bfa8768463535f6bde30751713bb72033e574c4b Mon Sep 17 00:00:00 2001 From: Dominique Hazael-Massieux Date: Thu, 12 Sep 2024 16:53:57 +0200 Subject: [PATCH 2/2] Adapt to updated amendment management system see #2995 --- amendments.json | 22 +++++++++++++++++++--- base-rec.html | 4 ++-- webrtc.html | 14 +++++++------- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/amendments.json b/amendments.json index a300a61f6..cb0806049 100644 --- a/amendments.json +++ b/amendments.json @@ -1033,7 +1033,7 @@ ] } ], - "rtcdatachannel-slots-init": [ + "rtcdatachannel-istransferable-init-1": [ { "description": "Make RTCDataChannel transferable to DedicatedWorker", "pr": 2988, @@ -1049,7 +1049,7 @@ ] } ], - "rtcdatachannel-send-1": [ + "rtcdatachannel-istransferable-init-2": [ { "description": "Make RTCDataChannel transferable to DedicatedWorker", "pr": 2988, @@ -1065,7 +1065,23 @@ ] } ], - "announcing-a-data-channel-as-closed": [ + "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, diff --git a/base-rec.html b/base-rec.html index 59c762fe2..11f8ecbda 100644 --- a/base-rec.html +++ b/base-rec.html @@ -13525,7 +13525,7 @@

      6.2.1 internal slot initialized to 0.

    7. -
    8. +
    9. Let channel have internal slots named [[DataChannelLabel]], [[Ordered]], @@ -14231,7 +14231,7 @@

      steps:

        -
      1. +
      2. Let channel be the RTCDataChannel object on which data is to be sent. diff --git a/webrtc.html b/webrtc.html index 23395af74..60e3bb3c4 100644 --- a/webrtc.html +++ b/webrtc.html @@ -14032,7 +14032,7 @@

        internal slot initialized to 0.

      3. -
      4. +
      5. Let channel have internal slots named [[\DataChannelLabel]], [[\Ordered]], @@ -14042,8 +14042,8 @@

        [[\Negotiated]], and [[\DataChannelId]].

      6. -
      7. Let channel have a [[\IsTransferable]] internal slot initialized to true.
      8. -
      9. [=Queue a task=] to run the following step:
          +
        1. Let channel have a [[\IsTransferable]] internal slot initialized to true.
        2. +
        3. [=Queue a task=] to run the following step:
          1. Set channel.{{RTCDataChannel/[[IsTransferable]]}} to false.
          @@ -14262,7 +14262,7 @@

        -
        +

        Announcing a data channel as closed

        @@ -14310,7 +14310,7 @@

      -
      +

      Transfering data channel

      The {{RTCDataChannel}} [=transfer steps=], given value and dataHolder, are:

        @@ -14832,13 +14832,13 @@

        steps:

          -
        1. +
        2. Let channel be the {{RTCDataChannel}} object on which data is to be sent.

        3. -
        4. Set channel.{{RTCDataChannel/[[IsTransferable]]}} to false.

        5. +
        6. Set channel.{{RTCDataChannel/[[IsTransferable]]}} to false.