peers/peerjs — pull request #130 by sbalko (2013-12-18 06:15:50+00:00)
Title: Make Chrome and Firefox interoperable for large messages

In an attempt to make Chrome and Firefox interoperable on reliable data channels, I made the following changes:

(1) All messages above the "chunkedMTU" threshold are being chunked - both in Firefox and in Chrome.
(2) As Blobs are not supported in Chrome's data channels, Firefox also falls back to ArrayBuffers
(3) Surprisingly, I also had to reduce the "chunkedMTU" property to ~16000 bytes (from 60000). This is because of the following phenomenon: Chrome can send data to Firefox in 60000 byte blocks. However the other way around when Firefox sends data to Chrome in 60000 byte blocks, these get split up into 16384 byte blocks. At this point, I cannot say if Firefox (the sender) or Chrome (the receiver) does this. At any rate, the "onmessage" callback of the WebRTC DataConnection object is called with data that is no larger than 16384 bytes. As a result, the "unpacker" gets confused. To work around this, I reduced the chunkedMTU threshold to 16300 bytes.