Figure53 / ActionSync

Code for synchronizing multiple timelines on two or more machines over OSC.
0 stars 0 forks source link

link pings to pongs for accurate offset calculations #6

Closed ChrisAshworth closed 5 years ago

ChrisAshworth commented 5 years ago

I suspect (based only on reading the code, not on using it) that we have a potential bug in the implementation of pings and pongs.

Specifically, it looks to me like any call to _sendPing assumes that the corresponding pong message will arrive before the next call to _sendPing:

https://github.com/Figure53/ActionSync/blob/master/ActionSyncClient.m#L204

I suspect that in experiments so far this has always been true, but it appears possible to:

@seandougall does that sound right to you?

If so, I believe one way to fix this would be to use a monotonically increasing index argument for each outgoing ping, and to send that index back for each pong. We'd need to also store an array of ping times, marking the local time when the ping was initiated, to calculate the correct offset when the pong is received.

Another option might be to prevent sending multiple pings at the same time, so that only one can be in flight at any given time.

ChrisAshworth commented 5 years ago

On Slack @seandougall sez:

Re pings/pongs, yeah, I think it makes sense. I suspect the likelihood of that much latency on a local network is pretty low, but it’s a good idea to guard against it.