title: High CPU usage with RTCPeerConnections
body: <p>I have the following setup:</p>
  
  <p><a href="https://i.stack.imgur.com/LnoZr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LnoZr.png" alt="enter image description here"></a></p>
  
  <p>The idea is that <strong>Computer A</strong> captures a single local MediaStream from <strong>Cam 1</strong> using getUserMedia.  Two RTCPeerConnections are then created locally - <strong>R5Outbound</strong> and <strong>R6Outbound</strong>.  Both Computer B and Computer C create their own inbound RTCPeerConnections to capture this stream.</p>
  
  <p>I'm noticing that Computer A - with an i7 CPU - is running hot and occasionally crashes my instance of Chrome (60) with the below setup after hitting 95%+ CPU.  </p>
  
  <p>After some reading I'm starting to think that I'm creating too many instances of RTCPeerConnection here; though with multiple streams originating from a single device in some cases, I'm a bit confused about how to properly create and manage my RTCPeerConnections.  My question is - given the above topology and the requirement that all computers need to see all streams (though some computers may not have a stream to share), what RTCPeerConnections should be created?</p>
  
  <p>I should note that mesh is required for now; business constraints have us eager but unable to use an <code>MCU</code> or <code>SFU</code> architecture.</p>
  
  <p>Some answers to questions: </p>
  
  <blockquote>
    <p>How much RAM and disk space is available at Computer A?</p>
  </blockquote>
  
  <p>16GB / >1TB SSD.</p>
  
  <blockquote>
    <p>Why are two outbound streams necessary at Computer A?  What is the purpose of two outbound streams?</p>
  </blockquote>
  
  <p>Computer A has two cameras attached.  One stream per camera is captured.  Each stream is then shared with each other computer.</p>
  
  <blockquote>
    <p>Do you clone the original stream to supply the MediaStream for R5Outbound and R6Outbound?</p>
  </blockquote>
  
  <p>Both <code>R5.O</code> and <code>R6.O</code> use the same MediaStream instance (I say that with 80% confidence - need to check my code and post back).</p>