twilio-video.js
twilio-video.js copied to clipboard
MaxListenersExceededWarning: Possible EventEmitter memory leak detected
When connecting to more than 5 rooms (a necessity for us to handle groups larger than 50) we start getting these errors as soon as we connect the 6th room:
events.js:46 MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 disabled listeners added. Use emitter.setMaxListeners() to increase limit
at _addListener (https://api.url/vendor.cea7801f6e2b6e161ba2.js:1277:15)
at LocalVideoTrack.addListener (https://api.url/vendor.cea7801f6e2b6e161ba2.js:1290:10)
at LocalVideoTrackPublication.LocalTrackPublication (https://api.url/vendor.cea7801f6e2b6e161ba2.js:212192:11)
at new LocalVideoTrackPublication (https://api.url/vendor.cea7801f6e2b6e161ba2.js:95251:137)
at asLocalTrackPublication (https://api.url/vendor.cea7801f6e2b6e161ba2.js:195354:10)
at LocalTrackPublicationV2.updated (https://api.url/vendor.cea7801f6e2b6e161ba2.js:115206:37)
at LocalTrackPublicationV2.emit (https://api.url/vendor.cea7801f6e2b6e161ba2.js:1226:7)
at LocalTrackPublicationV2.setSid (https://api.url/vendor.cea7801f6e2b6e161ba2.js:92952:14)
at LocalTrackPublicationV2.setSid (https://api.url/vendor.cea7801f6e2b6e161ba2.js:225240:154)
at LocalTrackPublicationV2.update (https://api.url/vendor.cea7801f6e2b6e161ba2.js:143969:16)
Can you increase the limit? Or how can we handle larger amounts of rooms/participants? We are needing to host events with possibly hundreds of participants.
Hi @tonymccallie,
Thank you for opening this issue. Could you please provide some more details on this? Such as what version of the SDK you're on, what browsers etc?
Regards, Joyce
We are using twilio-video 2.15.3 and Chrome 92.0.4515.131 on macOS 11.5.1
Thanks for those details @tonymccallie, could you also provide some repro steps as well?
I can't seem to reproduce this issue. Currently, I'm joining a room and disconnecting from the room, about 10x times without hitting that warning.
Best, Joyce
Joyce,
The problem happens when you join six separate rooms at once.. for a broadcast.
Thanks, Tony
Hi @tonymccallie,
I've attempted to reproduce this using our react app. Joined 6 rooms concurrently and added a 7th just for good measure, and still unable to reproduce this. Can you test out our react app to see if you're hitting these same issues?
Thanks, Joyce
Did you publish media to the rooms? Or just connect. I should have clarified. Our entire app is built in Angular, not react.
Hey @tonymccallie
Thank you for that information! I've got a repro going. Publish a single track, and in my case I was publishing a single video track, and it was being published to 10 different rooms. It seems that as a default, event emitters have a maximum of 10 listeners for a particular event.
Here's a couple of options:
-
You mentioned wanting to do this for broadcasting, we currently have a private beta open for live streaming. So you'd have to request access if you'd like to utilize this feature.
-
You can alternatively use
videoTrack.setMaxListeners(n)
. I've applied this method on thelocalVideoTrack
that is being published and simply increased it from the default 10, to 20.
Please let me know if this works for you!
Best, Joyce
I'm glad you were able to reproduce this. I will try option 2 tomorrow and see if I can get that to work. I'll report back my findings.
Thanks, Tony
Joyce,
I was able to attach 8 rooms with no errors by setting videoTrack.setMaxListeners(20).
Thanks for your help! Tony
A new problem though, this only pushes the problem out, it doesn't fix it. I was able to attach 8 rooms, but as soon as I detached those 8 rooms and added 8 new ones, I got the error again. We are working on an environment that is most likely on for 8 hours or more with several broadcasts of rooms starting and stopping. We will hit this error if the listeners aren't being cleaned up.
Hi @tonymccallie,
Thanks for letting me know. I've filed an internal ticket to track this issue and investigate further. I'll keep this thread open and keep it updated.
Please let me know if you come across any other issues!
Thanks again, Joyce
Joyce,
We met with Sergio today and were able to replicate the problem in Safari as well. He said he would try and contact you about this issue as well.
Thanks, Tony
Hi @tonymccallie,
Many apologies for the late response. As you may have heard from Sergio, the internal ticket that was filed for this issue is VIDEO-6529. I'm updating this thread in order for us to continue tracking the issue!
Best, Joyce
We encountered this today as well. If you switch rooms (join + leave) 10 or more times, this event emitter leak warning appears in the console.
I believe the issue is that there is no off
or removeEventListener
to match the on
event listener at https://github.com/twilio/twilio-video.js/blob/8050ae8edcfe479b917b1470ea45899fd4520386/lib/localparticipant.js#L336
Hi @canadaduane!
Thanks! I'll be handing this off to @manjeshbhargav.
Cheers
I'm having the same problem. We have a remote support app and if the support person connects/disconnects 10 times we receive this error on the person being helped side. The person being helped only ever connects a single room once.