소스 검색

keep a reference to the datachannel to avoid buggy garbage collection

j8
Philipp Hancke 11 년 전
부모
커밋
310e36d128
1개의 변경된 파일10개의 추가작업 그리고 0개의 파일을 삭제
  1. 10
    0
      data_channels.js

+ 10
- 0
data_channels.js 파일 보기

@@ -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…
취소
저장