question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

datachannel has a great latency

See original GitHub issue

My Code

https://github.com/tsonglew/aiortc-datachannel-delay

run python main.py to start the server, then visit localhost:8080 with a web browser

My Problem

I’m trying to process the video frames from video track, and send back the result with datachannel.

the result is replaced with time.time() in the above demo repo as following:

self.channel.send(
      json.dumps({"now": time.time() * 1000})
)

the <client receive from datachannel time> - <datachennl.send() time> is considered as delay, and are console.loged with code:

ch.addEventListener("message", function (evt) {
	console.log(Date.now() - JSON.parse(evt.data).now);
});

the datachannel config is {ordered: false, maxRetransmits: 0}

Output

image

as illustrated in the sreenshot, the delay is growing, but video and audio are fluent.

How can I get rid of the growing delay? Thx

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:9

github_iconTop GitHub Comments

9reactions
tsonglewcommented, Sep 27, 2021

as a workaround, I altered my datachannel sending code like this

self.channel.send(json.dumps({"now": time.time() * 1000}))
await self.channel._RTCDataChannel__transport._data_channel_flush()
await self.channel._RTCDataChannel__transport._transmit()
1reaction
Interpausecommented, May 18, 2022

Could above be implemented as a option when creating a data channel?

Read more comments on GitHub >

github_iconTop Results From Across the Web

python aiortc datachannel has a great latency - Stack Overflow
I'm trying to process the video frames from video track, and send back the result with datachannel. the result is replaced with time.time()...
Read more >
Massive drop in data channel throughput when increasing ...
Does anyone know why SCTP data channel performance incurs a significant ... Seems like Firefox handles latency slightly by sending more data per...
Read more >
Higher latency on WebRTC DataChannels than Chrome
Visit a WebRTC DataChannel powered game here: ... Expected results: Run the same example in Chrome and the host latency is 0-2ms. The...
Read more >
Performance Evaluation of WebRTC Data Channels - Tuhat
Abstract—This paper covers a study on WebRTC data channel ... conditions and especially latency is not close to perfect. Changing.
Read more >
Data Communication | WebRTC for the Curious
A data channel is datagram based, and each has its own durability settings. ... Large lower-priority user messages will not delay the sending...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found