Browse Source

keep a reference to the datachannel to avoid buggy garbage collection

master
Philipp Hancke 11 years ago
parent
commit
310e36d128
1 changed files with 10 additions and 0 deletions
  1. 10
    0
      data_channels.js

+ 10
- 0
data_channels.js View File

@@ -1,9 +1,15 @@
1 1
 /* global connection, Strophe, updateLargeVideo, focusedVideoSrc*/
2
+
3
+// cache datachannels to avoid garbage collection
4
+// https://code.google.com/p/chromium/issues/detail?id=405545
5
+var _dataChannels = [];
6
+
2 7
 /**
3 8
  * Callback triggered by PeerConnection when new data channel is opened
4 9
  * on the bridge.
5 10
  * @param event the event info object.
6 11
  */
12
+
7 13
 function onDataChannel(event)
8 14
 {
9 15
     var dataChannel = event.channel;
@@ -82,7 +88,11 @@ function onDataChannel(event)
82 88
     dataChannel.onclose = function ()
83 89
     {
84 90
         console.info("The Data Channel closed", dataChannel);
91
+        var idx = _dataChannels.indexOf(dataChannel);
92
+        if (idx > -1) 
93
+            _dataChannels = _dataChannels.splice(idx, 1);
85 94
     };
95
+    _dataChannels.push(dataChannel);
86 96
 }
87 97
 
88 98
 /**

Loading…
Cancel
Save