Technology

Engineering record

Partner workoutReplaced

Partner workout: replicating shared progress on both phones

We connected two phones in September, but a workout done together still wasn't one thing. This time, instead of messages, we let the two phones share the progress itself.

In September we built a path for the two phones to talk, but the engine didn't know whose turn it was. Each phone reconciled the state it had computed, and in the process turns and sets drifted apart. Would sending messages more often help? If the two phones understand the same workout differently, faster messages don't fix it.

So we decided to keep one shared progress, identical on both phones. But at first, every button press sent every action done so far. With eight actions the message was 3.5 KB. Sending it in seven pieces took about a third of a second, and it got longer with every action. The longer you worked out, the slower it got. Now we send only the actions the other side doesn't know yet.

Can we trust “at the same time”?

For the start countdown to end together on both phones, we need to know the difference between their clocks. Measuring with a single message mixes the clock difference with the message's travel time. So while the messages go back and forth we take four timestamps, and use them to separate travel time from clock difference. Among the measurements, we use the one from when the message traveled fastest.

We also cut the two phones' communication loose from waiting on the server. Even with a signal it could wait 0.2 to 0.3 seconds, and when the signal was bad, up to the request limit of 30 seconds. We used Bluetooth so the phones could connect without a server, and yet the Bluetooth side was slowed down by waiting on the server. Sending to the server now goes on separately.

The whole design, in one paper

Written from that day’s point of view, using the documents and change history of the time. Published 2026.12.01.