-
Notifications
You must be signed in to change notification settings - Fork 55
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
[BUG] "Cannot create so many PeerConnections" on Chrome after 500 accepted calls #145
Comments
As requested by the Twilio support team, here is a Call SID for which we detected the problem: CA72b33d8da7bdd27d331f4f6283910143. Twilio logs for this call only show the following log:
This call was received by our application after the 500 calls. What happened was the following:
|
@asmeikal , thanks for submitting! I can see that we are indeed closing the peer connections (by looking at webrtc-internals) , but they don't go away if you continue to monitor the webrtc-internals tab. However, I can see the same behavior in when I load the webrtc example applications. https://webrtc.github.io/samples/. I can see that peer connections are also getting closed but they don't go away. I believe this is still an issue on Chrome. But to make sure, I will submit an internal ticket to track this down and maybe there are references that we are not cleaning up. For now, whenever this issue happens, can you programmatically reload the page? |
@charliesantos the example application you linked is actually leaking references to the connection. Using the "Basic peer connection demo in a single tab" I see too the peer connections number growing without limits by clicking the "Call" and "Hang Up" buttons, and "forcing" the garbage collector to run does nothing to free up the closed connections. However, references to the connections can be found in the console (as the "currentTarget" of some of the events logged by the example application). Clearing the console and then forcing the garbage collector to run again clears up the old connections. See this comment on the Chromium issue for reference: https://bugs.chromium.org/p/chromium/issues/detail?id=825576#c38 Since garbage collection works when no references to the peer connections are present, I believe the problem we are currently experiencing is caused by similar reference leaks inside the Twilio JS Voice SDK. Unfortunately I still haven't had the chance to go over the SDK code to try and identify the leak. As for the solution you proposed (programmatically reloading the page), it's something we are using and that mitigates the problem (as all connections made before the reload are garbage collected), but it's quite disruptive for the user flow due to other features of our application, and as such it's only used when we are sure that the user is inactive. The problem still arises when the user makes 500 calls in a single session, without giving us the chance to reload the application. |
Thanks for the additional information @asmeikal . We'll keep this in mind once we start looking into this more. |
Related to #87 |
Should be fixed in 2.4.0 |
Code to reproduce the issue:
An example is available here: https://github.com/asmeikal/voice-javascript-sdk-quickstart-node
After starting up the device, click on the "Start loop" button. The script will connect and then disconnect calls in a loop, keeping a counter.
Expected behavior:
An unlimited number of calls can be made.
Actual behavior:
As soon as the counter reaches 500, no more calls can be made. The stack trace of the error is the following:
The root of the problem is this Chromium bug, that is still open: https://bugs.chromium.org/p/chromium/issues/detail?id=825576
RTCPeerConnections are not garbage collected quickly enough by Chrome, but workarounds are available, as shown in this comment: https://bugs.chromium.org/p/chromium/issues/detail?id=825576#c40
Forcing garbage collection through the workaround in the comment, or by relying directly on the garbage collector in Electron, reclaims part of the RTCPeerConnections, and other RTCPeerConnections can be made.
However, the workarounds do not work when using the Twilio JS Voice SDK, even after waiting up to an hour and after recreating the Twilio device.
This may be caused by references to the RTCPeerConnection being leaked by the Twilio JS Voice SDK, as pointed out in some of the comments: https://bugs.chromium.org/p/chromium/issues/detail?id=825576#c39
This prevents even a manual trigger of the garbage collection from cleaning up the closed RTCPeerConnections.
We detected this problem in our application, where call center operators usually reach the 500 calls after roughly 6 hours.
Software versions:
The text was updated successfully, but these errors were encountered: