Re: [webrtc-rtptransport] API creates per-packet temporary objects, this is not ideal for GC (#77)

On a related note, the promise-based `sendRtp` has the same problem:
```
interface RTCRtpSendStream {
    undefined sendRtp(RTCRtpPacket packet);
    Promise<RTCRtpSendResult> sendRtp(RTCRtpPacketInit packetInit, optional RTCRtpSendOptions options = {});
    ...
};
```

The problem is a) we create a promise object on a per-packet basis, which needs to be GC'd, and b) if the app awaits all of these packets there will be a lot of context switching. To support the use case of having a promise for a batch of packets, we could do this instead:
```
interface RTCRtpSendStream {
    undefined sendRtp(RTCRtpPacket packet);

    // The promise resolves when all `packets` have been sent.
    Promise<RTCRtpSendResult> sendRtp(sequence<RTCRtpPacket> packets);
    ...
};
```

-- 
GitHub Notification of comment by henbos
Please view or discuss this issue at https://github.com/w3c/webrtc-rtptransport/issues/77#issuecomment-2396701242 using your GitHub account


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

Received on Monday, 7 October 2024 11:45:57 UTC