[webrtc-extensions] ICE improvements: prevent candidate pair removal (#166)

sam-vi has just created a new issue for https://github.com/w3c/webrtc-extensions:

== ICE improvements: prevent candidate pair removal ==
**Background**: An incremental approach for improving ICE control capabilities was discussed at the WebRTC WG [April 2023 interim meeting](https://www.w3.org/2023/04/18-webrtc-minutes.html#t08). This issue relates to the first in a series of proposed improvements.

**Problem**: Applications should be able to maintain multiple candidate pairs by preventing the removal of candidate pairs that are not in active use for transport. This is necessary for applications that want to maintain redundant candidate pairs for connection resiliency, or move traffic to an alternate route based on the network cost or other factors.

**Proposal**: This could be achieved a few different ways.

1.  Cancelable event for candidate pair removal

    When the ICE agent has decided to prune a candidate pair (eg. due to inactivity), the user agent fires a [`cancelable`](https://dom.spec.whatwg.org/#ref-for-dom-event-cancelable%E2%91%A1) event to let the application know that a candidate pair is about to be removed. The application can prevent the removal from happening by calling [`preventDefault()`](https://dom.spec.whatwg.org/#ref-for-dom-event-preventdefault%E2%91%A2) on the event. If not [prevented](https://dom.spec.whatwg.org/#ref-for-dom-event-defaultprevented%E2%91%A0), the ICE agent is free to prune the candidate pair.
  
    The API looks like
  
    ```webidl
    partial interface RTCIceTransport  {
      attribute EventHandler /* RTCIceCandidatePairEvent */ oncandidatepairadded;      // not strictly necessary for this to work
      attribute EventHandler /* RTCIceCandidatePairEvent */ oncandidatepairremoval;    // before removal
    };
    
    interface RTCIceCandidatePairEvent : Event {    // cancelable
      readonly attribute RTCIceCandidatePair candidatePair;
    };
    ```

    This approach to preventing the user agent from taking default action has a precedent in [touch event](https://w3c.github.io/touch-events/#cancelability) and form [submit event](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#submitevent).

    This event conveys to the application exactly when the removal is to occur, and allows the decision to permit or prevent removal to be deferred until it actually needs to be made. It sidesteps any race conditions that may have to be averted with the other options. 

2.  Change automatic behaviour - `removable` attribute

    The application can change the ICE agent's automatic behaviour by setting an attribute (or an internal slot, through a method) to prevent a candidate pair from being automatically pruned by the ICE agent.
  
    ```webidl
    partial interface RTCIceTransport  {
      attribute EventHandler /* RTCIceCandidatePairEvent */ oncandidatepairadded;
      attribute EventHandler /* RTCIceCandidatePairEvent */ oncandidatepairremoved;    // after removal
    };
    
    partial interface RTCIceCandidatePair {
      attribute boolean removable;
    };
    ```

3. Change automatic behaviour - `idleTimeout` attribute

    This attribute leaves it up to the ICE agent to manage the candidate pair lifecycle, but with input from the application. The ICE agent may prune the candidate pair if no data or ICE check activity has occurred on the candidate pair within the timeout duration.

    ```webidl
    partial interface RTCIceTransport  {
      attribute EventHandler /* RTCIceCandidatePairEvent */ oncandidatepairadded;
      attribute EventHandler /* RTCIceCandidatePairEvent */ oncandidatepairremoved;    // after removal
    };
    
    partial interface RTCIceCandidatePair {
      attribute unsigned long idleTimeout;    // initialized to the default timeout
    };
    ```

    The `idleTimeout` can achieve the same effect as `removable`, with max value meaning never remove, and 0 meaning the ICE agent can prune freely.

    This option gives more control than a `removable` attribute - an application can choose to simply extend the duration for which an inactive candidate pair is retained.

    Another benefit is that there is no need for a new API to let the application prune candidate pairs. The ICE agent will eventually clean up inactive candidate pairs after the timeout. The user agent could also enfore policies on how long of a timeout the application is allowed to set.

Please view or discuss this issue at https://github.com/w3c/webrtc-extensions/issues/166 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Monday, 8 May 2023 14:24:01 UTC