Skip to content

Commit

Permalink
Don't crash on iOS 5.x when using WebSockets on Safari resume
Browse files Browse the repository at this point in the history
  • Loading branch information
avital committed May 4, 2013
1 parent 088db86 commit c6dd83b
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion packages/livedata/sockjs-0.3.4.js
Original file line number Diff line number Diff line change
Expand Up @@ -1250,7 +1250,26 @@ var WebSocketTransport = SockJS.websocket = function(ri, trans_url) {
};

WebSocketTransport.prototype.doSend = function(data) {
this.ws.send('[' + data + ']');
// <METEOR>
// https://github.com/sockjs/sockjs-client/pull/117
var self = this;
var _send = function () {
self.ws.send('[' + data + ']');
};

if (/iPhone|iPad|iPod/.test(navigator.userAgent) &&
/OS 5_0|OS 5_1/.test(navigator.userAgent)) {
// On iOS 5.x, sending data to a websocket that has been closed
// while the app is sleeping can cause Safari to crash. Work
// around this with `utils.delay`.
//
// https://bugs.webkit.org/show_bug.cgi?id=81517
// http://openradar.appspot.com/10811789
utils.delay(_send);
} else {
_send();
}
// </METEOR>
};

WebSocketTransport.prototype.doCleanup = function() {
Expand Down

0 comments on commit c6dd83b

Please sign in to comment.