From 310e36d1282b5f7b852dea6c93e2fc00133e76c8 Mon Sep 17 00:00:00 2001 From: Philipp Hancke Date: Thu, 21 Aug 2014 17:04:27 +0200 Subject: [PATCH] keep a reference to the datachannel to avoid buggy garbage collection --- data_channels.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/data_channels.js b/data_channels.js index ac6ce4dd1..9470f6153 100644 --- a/data_channels.js +++ b/data_channels.js @@ -1,9 +1,15 @@ /* global connection, Strophe, updateLargeVideo, focusedVideoSrc*/ + +// cache datachannels to avoid garbage collection +// https://code.google.com/p/chromium/issues/detail?id=405545 +var _dataChannels = []; + /** * Callback triggered by PeerConnection when new data channel is opened * on the bridge. * @param event the event info object. */ + function onDataChannel(event) { var dataChannel = event.channel; @@ -82,7 +88,11 @@ function onDataChannel(event) dataChannel.onclose = function () { console.info("The Data Channel closed", dataChannel); + var idx = _dataChannels.indexOf(dataChannel); + if (idx > -1) + _dataChannels = _dataChannels.splice(idx, 1); }; + _dataChannels.push(dataChannel); } /**