From 582ac990a4a78f02444a148850bb82e143337cd0 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Fri, 4 Dec 2015 23:38:50 -0800 Subject: [PATCH] webtorrent perf: create 5 offers at a time --- lib/client/websocket-tracker.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/client/websocket-tracker.js b/lib/client/websocket-tracker.js index 0a842c8..c5284f0 100644 --- a/lib/client/websocket-tracker.js +++ b/lib/client/websocket-tracker.js @@ -42,9 +42,8 @@ WebSocketTracker.prototype.announce = function (opts) { return self.socket.once('connect', self.announce.bind(self, opts)) } - // TODO: Limit number of offers (temporarily) - // TODO: remove this when we cleanup old RTCPeerConnections cleanly - var numwant = Math.min(opts.numwant, 10) + // Limit the number of offers that are generated, since it can be slow + var numwant = Math.min(opts.numwant, 5) self._generateOffers(numwant, function (offers) { var params = { @@ -177,6 +176,7 @@ WebSocketTracker.prototype._onSocketData = function (data) { var peer if (data.offer && data.peer_id) { + debug('creating peer (from remote offer)') peer = new Peer({ trickle: false, config: self.client._rtcConfig, @@ -260,6 +260,7 @@ WebSocketTracker.prototype._generateOffers = function (numwant, cb) { function generateOffer () { var offerId = hat(160) + debug('creating peer (from _generateOffers)') var peer = self.peers[offerId] = new Peer({ initiator: true, trickle: false,