Closed ghost closed 7 years ago
Thanks, great find. Absolutely agree - should go hand in hand with #237 (moving out of engine.io)
Maybe it is as simple as removing this.emit('heartbeat');
from Socket.prototype.onPacket
?
Wait what? So this is engine.io code I'm looking at?
Yup, afraid so. There's quite a few of these, hence #237
Hi,
The Socket.prototype.onHeartbeat calls clearTimeout and setTimeout. These two calls are very heavy and could be replaced with one static timer with a fixed interval that simply checks a boolean "gotPing" like this:
static, fix timer: if (gotPing) { gotPing = false; } else { // fail the connection }
onHeartbeat: gotPing = true; // setting a boolean is far faster than clearing/setting a timer
This performance problem is very easy to spot in the space shooter demo app where the FPS drop dramatically on any kind of message receives due to these calls.