w3c / webrtc-nv-use-cases

Use cases for WebRTC NV
https://w3c.github.io/webrtc-nv-use-cases/
Other
32 stars 13 forks source link

Send transferable data #42

Closed aboba closed 1 year ago

aboba commented 5 years ago

Copied from Issue https://github.com/w3c/webrtc-pc/issues/2055

Hi. I'm using DataChannel to transfer a large file to another peer. While monitoring the performance of my javascript (in chrome v71) I notice channel.send(uInt8Array) takes up the most of the scripting time skarmavbild 2019-01-12 kl 23 12 58

I assume that it has to has to copy the ArrayBufferView and that is why it block the main thread for a bit? since i might still have a reference to it somewhere... Now my proposal is make it optional to make it transferable just like postMessage is able to do. port1.postMessage(message, [transfer]) dataChannel.send(message, [transfer]) I don't need the data after that point so there is no need for it to be copied. it would also help to free memory

aboba commented 1 year ago

This PR has been addressed by transferrable data channels, which shipped in Safari 16.5.

Specification link: https://w3c.github.io/webrtc-extensions/#rtcdatachannel-transferable