Repository navigation
fix: free observers and factories safely while they are still in use - #528
Merged
Merged
Conversation
Registering, removing and disposing through one Java object may now run on several threads at once. WebRTC is told by one of them at a time, without anyone waiting, and an observer is freed once WebRTC has a newer one. A dispose frees the observer only once no registration through the object is running any more, so none is left registered.
WebRTC calls the observers of a track from a copy of their list, so a listener that disposed the track, or removed a listener, freed observers that were still to be called, its own included. They are now detached at once and freed, with the track, after the notification; detached ones are no longer called.
A connection closed from a callback, or while another thread was still in one of its methods, is freed later on the factory's signaling thread. A factory disposed meanwhile stopped and freed that thread first. The close now holds the factory's handle until the connection is freed, so the factory is released after it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
dispose(). Only one thread talks to WebRTC per object: a concurrent registration hands its observer over and returns, without waiting for WebRTC to take it. CoversRTCDataChannel,RTCDtlsTransport,RTCDtmfSender,RTCRtpSenderandRTCRtpReceiver.PeerConnectionFactory.dispose()during a pendingclose()returns at once, and the factory is freed after the connection. This used to crash the JVM as well.