Browse Source

Fixing Chrome crashing

Michelle Bu 11 năm trước cách đây
mục cha
commit
52bc598e40
4 tập tin đã thay đổi với 28 bổ sung11 xóa
  1. 22 7
      dist/peer.js
  2. 0 0
      dist/peer.min.js
  3. 5 3
      lib/negotiator.js
  4. 1 1
      lib/util.js

+ 22 - 7
dist/peer.js

@@ -1012,9 +1012,22 @@ Reliable.higherBandwidthSDP = function(sdp) {
   // AS stands for Application-Specific Maximum.
   // Bandwidth number is in kilobits / sec.
   // See RFC for more info: http://www.ietf.org/rfc/rfc2327.txt
-  var parts = sdp.split('b=AS:30');
-  var replace = 'b=AS:102400'; // 100 Mbps
-  return parts[0] + replace + parts[1];
+
+  // Chrome 31+ doesn't want us munging the SDP, so we'll let them have their
+  // way.
+  var version = navigator.appVersion.match(/Chrome\/(.*?) /);
+  if (version) {
+    version = parseInt(version[1].split('.').shift());
+    if (version < 31) {
+      var parts = sdp.split('b=AS:30');
+      var replace = 'b=AS:102400'; // 100 Mbps
+      if (parts.length > 1) {
+        return parts[0] + replace + parts[1];
+      }
+    }
+  }
+
+  return sdp;
 };
 
 // Overwritten, typically.
@@ -1142,7 +1155,7 @@ var util = {
       var reliablePC = new RTCPeerConnection(defaultConfig, {});
       try {
         var reliableDC = reliablePC.createDataChannel('_PEERJSRELIABLETEST', {});
-        reliable = reliableDC.reliable && navigator.mozRTCPeerConnection;
+        reliable = reliableDC.reliable;
       } catch (e) {
       }
       reliablePC.close();
@@ -1963,10 +1976,12 @@ Negotiator.startConnection = function(connection, options) {
     if (connection.type === 'data') {
       // Create the datachannel.
       var config = {};
-      if (util.supports.reliable && !options.reliable) {
+      // Dropping reliable:false support, since it seems to be crashing
+      // Chrome.
+      /*if (util.supports.reliable && !options.reliable) {
         // If we have canonical reliable support...
-        config = {maxRetransmits: 0}
-      }
+        config = {maxRetransmits: 0};
+      }*/
       var dc = pc.createDataChannel(connection.label, config);
       connection.initialize(dc);
     }

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 0 - 0
dist/peer.min.js


+ 5 - 3
lib/negotiator.js

@@ -28,10 +28,12 @@ Negotiator.startConnection = function(connection, options) {
     if (connection.type === 'data') {
       // Create the datachannel.
       var config = {};
-      if (util.supports.reliable && !options.reliable) {
+      // Dropping reliable:false support, since it seems to be crashing
+      // Chrome.
+      /*if (util.supports.reliable && !options.reliable) {
         // If we have canonical reliable support...
-        config = {maxRetransmits: 0}
-      }
+        config = {maxRetransmits: 0};
+      }*/
       var dc = pc.createDataChannel(connection.label, config);
       connection.initialize(dc);
     }

+ 1 - 1
lib/util.js

@@ -116,7 +116,7 @@ var util = {
       var reliablePC = new RTCPeerConnection(defaultConfig, {});
       try {
         var reliableDC = reliablePC.createDataChannel('_PEERJSRELIABLETEST', {});
-        reliable = reliableDC.reliable && navigator.mozRTCPeerConnection;
+        reliable = reliableDC.reliable;
       } catch (e) {
       }
       reliablePC.close();

Một số tệp đã không được hiển thị bởi vì quá nhiều tập tin thay đổi trong này khác