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.

perf: migrate from simple-peer to polite-peer

See original GitHub issue

Please consider migrating from simple-peer to polite-peer: https://github.com/jimmywarting/jimmy.warting.se/blob/master/packages/peer/perfect-negotiation.js [there isn’t an NPM package for this but I could make one]

Why this matters: simple-peer relies on stream which in turn relies on buffer, and process which relies on setTimeout. This is an important issue because those require to be polyfilled, and those polyfills are VERY slow. Since WebTorrent was mentioned, from my testing more than half of the app’s CPU time was consumed by node’s stream and buffer or actually it’s polyfills. Another massive issue is the reliance on the slow process polyfill of most bundlers which uses setTimeouts for delying tasks instead of promises or microtask.

Problems: polite-peer is a much simper package than simple-peer [oh the irony] and as such doesn’t expose that many wrappers so it might require extra work. Another issue might be the immaturity of the package as very little people actually used it [not to be confused with it wasn’t used a lot, because it was used in public projects a lot] so unexpected issues might arise.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:5
  • Comments:20 (19 by maintainers)

github_iconTop GitHub Comments

2reactions
ThaUnknowncommented, Jul 31, 2022

🥳 @gfodor with these changes pako, stream we went from 156.9kB/46.9kB to 39.6kB/12.5kB

2reactions
ThaUnknowncommented, Jul 30, 2022

I’ll pretend like I understood what you said, nod twice and hope you manage to pull some black magic and drop simple-peer sometime soon, I can’t wait to be able to use this in my electron projects which can’t do signaling via the web push api, which is the hack I used up until now to get signaling for free :p

Read more comments on GitHub >

github_iconTop Results From Across the Web

WebRTC 1.0: Real-Time Communication Between Browsers
This document defines a set of ECMAScript APIs in WebIDL to allow media and generic application data to be sent to and received...
Read more >
simple-peer - npm
Create a new WebRTC peer connection. A "data channel" for text/binary communication is always established, because it's cheap and often useful.
Read more >
Establishing a connection: The WebRTC perfect negotiation ...
This article introduces WebRTC perfect negotiation, ... By doing so, the polite peer has switched from being the caller to the callee!
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