-
-
Notifications
You must be signed in to change notification settings - Fork 981
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Segmentation fault from node-webrtc when accessing RTCPeerConnection.localDescription #812
Comments
@dguenther This appears to be an issue with the wrtc library itself. I tried your workaround by removing If it helps, I'm using Node v20.3.1 on a 2020 Macbook Pro MacOS 13.4.1 (22F82) |
I've been running node-datachannel successfully for a time, but I've only tested the data channels, not the media support. Another option I've seen is werift-webrtc. When I tested it a while ago, the performance was not great relative to node-datachannel and node-wrtc, but judging by the GitHub issues, it looks like there have been some improvements since. |
@dguenther Perfect! werift appears to be a drop-in replacement for node-wrtc that works great with simple-peer. Many thanks! |
@dguenther Well, crud. werift-webrtc has the same segmentation fault issue as node-webrtc. |
Is there an issue for it? Offhand I wouldn't expect that, since as far as I know werift doesn't use any native modules. |
So, I think the error was in my own code for both node-wrtc and for werift-webrtc. I am using simple-peer to create a partial mesh, and I think my partial mesh peer rebalancing logic created the problem. I have had my partial mesh network up and running fine since last night with no errors or crashes in both node and the browser. I am back to using node-wrtc. My research into this bug suggests that it occurs when peers quickly disconnect/reconnect repeatedly. I think that's what was happening in my case. |
@dguenther Here's what I found out. I am building on webtorrent-hybrid. It uses |
What version of this package are you using?
What operating system, Node.js, and npm version?
I haven't tested this in other environments.
What happened?
When creating, connecting, and destroying several SimplePeer instances in Node.js,
wrtc
crashes with a segmentation fault:Reproduction case
I created a repository with a demo, and also pasted example code below. Unfortunately it's not deterministic, but when running it in 4 windows, it crashes before 1000 iterations in at least one of them.
https://github.com/dguenther/simple-peer-issue-demo
Click to expand example code block
What did you expect to happen?
No crash 😄 Since ultimately it should be node-webrtc's responsibility to manage itself without crashing, I've created an issue here: node-webrtc/node-webrtc#696
However, I noticed that removing
this._pc.localDescription
from this line fixes the crash:simple-peer/index.js
Line 618 in d972548
Several WebRTC examples seem to pass localDescription to the other peer rather than passing the offer itself, so I wasn't sure if there was a reason for that, or if this is a viable workaround.
Are you willing to submit a pull request to fix this bug?
👍 Yep, if one is necessary.
The text was updated successfully, but these errors were encountered: