-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
Consistency of closed events #236
Comments
After this comment #223 (comment) I thought the same thing. I am totally OK with resetting all callbacks on close, but this will be a breaking change. |
Hmm, I'm not sure I fully understand the details here (or remember the full context from when I opened #87) but in general I was running into issues where I assumed that I'm mainly tracking this on entire connections, but to be honest I would've expected the same from channels & tracks too. Is there no practical way to fire the closed event, and then clean up the callbacks on nextTick or similar? Of course they do need cleaning up, but I don't understand why it's not possible to run the close callback before doing so. |
Introducing the same procedures on channels is possible. Since this is a breaking change I want to also ask you because of that issue. |
That's true, although I'd be very interested to know why the spec was written that way. The opposite is true for datachannels in browsers though, which do always fire a It's up to you of course, but I think node-datachannel has quite different use cases to browser environments and I wouldn't tie yourselves to the browser API design - I expect many users are in server-like environments, tracking many different WebRTC connections over longer time spans along with other state, and so there's much more value in being able to manage and clean up other resources when they close. Having a single reliable way to be informed when the resources are closed is very useful. |
I think for polyfills we should follow specs and for main part ,since this is a binding, we should follow libdatachannel. @paullouisageneau |
@murat-dogan libdatachannel always triggers the There might be a way to do that without the explicit |
With this PR #239 I introduced a cleanup function, that will be called after calling JS cb. With this PR the procedure for peer connection, data channel, track and WebSocket will be like;
Also for polyfills, onClosed callback will be called and I think this will not be harmful. |
I am also investigating why we needed a destroy function. |
@murat-dogan Great, I like your idea to add a cleanup function! However, I'm afraid #239 might reintroduce the issue I originally fixed in #106. The original issue was reported by @pimterry in #103: A peer connection emits a track, libdatachannel triggers I don't think this is desirable behavior. Maybe some specific callbacks like |
It will be beneficial to have a test case. I pushed new commıts @paullouisageneau |
Sorry, I don't really have any spare time to look at this right now! I've got quite a bit of work going on and I haven't touched the RTC bits for a little while. From the original issue tehre, it might be quite difficult to write a normal test for anyway, since there's some sort of internal race condition going on. I think this kind of thing is probably best covered by some kind of stress test, that just opens & then closes a lots of connections in a loop for a while, with a couple of tracks & data channels on each (and calling some method on each one as it opens to check it's OK - e.g. just logging the channel label). Testing like that might be useful to flush out other issues too. In #104 I added assertions so I think most race condition cases should now immediately fail in that kind of environment if there are any issues. |
I added a multiple call here |
I have released new version with latest changes https://github.com/murat-dogan/node-datachannel/releases/tag/v0.7.0 If you still think there is a problem please write here or we can close the issue |
@murat-dogan Sorry, I'm very busy at the moment, thank you for addressing the issue! I'm only concerned about scenarios where cleanup is not done, for instance I think it's not called if the user does not set a closed callback. Fixing this can be a bit tricky because |
Thanks for the hint @paullouisageneau , good point. |
I will just released V0.9.0 with latest changes. |
Following the discussion in #223, it appears there is currently an inconsistency in the way closed states events are handled.
PeerConnectionWrapper
has an explicitdestroy()
method which callsdoResetCallbacks()
, which means theonStateChange
callback is triggered withclosed
state after callingclose()
. However, since callbacks are not reset, it creates memory leak issues similar to #223 when not using the API through the polyfill.DataChannelWrapper
does not have such a mechanism, it resets callabcks immediately indoClose()
soonClosed
is not triggered afterclose()
. However, this does not create memory leaks.MediaTrackWrapper
acts likeDataChannelWrapper
, it resets callbacks immediately andonClosed
is not triggered afterclose()
.Is this expected behavior? Does it really make sense to have this mechanism in
PeerConnectionWrapper
while other places don't have it?The text was updated successfully, but these errors were encountered: