Window object has a strong reference to any RTCPeerConnection objects created from the constructor whose global object is that Window object.--
---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi All,
I'm currently attempting to build a randomised unstructured peer to peer overlay network to run over WebRTC in the browser as part of an academic project. A characteristic of the project is that peers engage in periodic exchanges of information with other random peers in the network and the idea is that the involvement in the network potentially is very long-lived, so in one browser session peers might engage in exchanges with hundreds (even thousands?) of other peers.
My initial implementation created a new RTCPeerConnection for each exchange that occurred, which worked fine except for the small issue of (non-heap) browser memory consumption slowly increasing, I believe due to the following statement from the webrtc spec (http://www.w3.org/TR/webrtc/#garbage-collection)
AWindowobject has a strong reference to anyobjects created from the constructor whose global object is thatRTCPeerConnectionWindowobject.
i.e. the issue discussed here;
So I'm experimenting with the idea of keeping a pool of RTCPeerConnections that can be used for exchanges. This would only need to be small in size because each peer is only engaged in one, MAYBE two exchanges concurrently. The problem I have with this is the RTCPeerConnection in Chrome doesn't seem to like certain patterns of reuse.
The problems arise (I think) due to the fact it is impossible to unset local/remote session descriptions in order to "reset" an RTCPeerConnection in readiness for connection to another peer, so when I pull a second-hand RTCPeerConnection from the pool and create a data channel in readiness to create an offer the datachannel immediately fires an onopen event. I assume because the browser at each end are still connected and the RTCPeerConnection is still in the "stable" state (http://www.w3.org/TR/webrtc/#rtcpeerstate-enum).
If I attempt to close the RTCPeerConnection before its returned to the pool I of course get the IllegalStateError thrown when reuse is attempted.
-- Randell Jesup -- rjesup a t mozilla d o t com
I think you don't want to cache PC's - the overhead to build one isn't that large. In some situations, you might want to have one pre-built and ready to use if setup latency is critical, but given trickle ICE, that's less of an issue.
If you stop() your peerconnection, and then drop *all* references to it, it should be garbage-collected "soon". The item you reference about chrome and webrtc-internals I think was/is a Chrome bug where webrtc-internals kept the PC alive after close(). It does survive after close() so long as there is a reference to it, so stats can be gathered - but if the last reference is dropped, it should disappear (and does in FF). Note that GC is unpredictable unless forced by something like about:memory in FF.
You want to renegotiate, but you want to do it with a *different* partner, which is not per-se renegotiation. Which isn't to say it couldn't be somehow made to work, but I wouldn't try it. There's little if any win, and tons of pain. And on top of that, FF doesn't support renegotiation yet, either.
--