Ghost calls across devices
Picking up on one device, leaving the others ringing — a classic distributed-state bug.
The bug.
The user has three devices logged into the same account — iPhone, iPad, Mac. A call comes in. All three ring (correct). They pick up on the iPhone. The iPad keeps ringing. Then, five seconds in, the iPad somehow also answers, the server opens a second media leg, and the caller hears doubled audio.
Welcome to multi-device call sync. It's one of those bugs you don't see in dev — you have one Simulator open. You see it in production, from a bug report that says “audio echoed and we had to hang up.”
Why it happens.
The default pattern — the one you'll write if you don't think about it — gives each device ownership of the call state. iPhone receives the push, iPhone starts ringing. User answers on iPhone, iPhone transitions to connected, iPhone tells the server “I picked up.”
What about the iPad? The iPad ALSO received the push, started ringing, and is sitting there in its own local ringing state. Nothing has told it the call is over. If the user taps the green button on the iPad five seconds later (because they forgot to put it down), the iPad also tries to answer. Now there are two active peer connections on the same server-side call. Doubled audio, broken call.
The problem isn't your signaling layer. The problem is that each device thinks it owns the truth about the call state. Three devices, three local sources of truth, no coordination.
The fix: subscribers, not owners.
Flip the model. The server owns the authoritative call state. Every device subscribes to it. No device is allowed to unilaterally transition the call; it can only request a transition, and the server broadcasts the result to everyone — including the device that requested it.
This is the same pattern Slack uses for message read-receipts, the same pattern CRDTs use for conflict-free replicas: avoid local state as the source of truth. The server is the source of truth; devices mirror it.
1// Every device subscribes. No device owns.2// The server broadcasts the authoritative transition — including back to3// the device that requested it — and that broadcast is the only thing4// that changes local state.56final class CallStateSubscriber {7 private let socket: SignalingSocket8 private let callManager: CallManager9 private let myDeviceId: String1011 func start() {12 socket.on("call:state") { [weak self] (evt: CallStateEvent) in13 guard let self else { return }1415 // Reject stale / out-of-order events using the server-assigned seq.16 guard evt.seq > self.lastSeq(for: evt.uuid) else { return }17 self.setLastSeq(evt.seq, for: evt.uuid)1819 switch evt.phase {20 case .answered where evt.deviceId != self.myDeviceId:21 // Another device picked up — dismiss our local ring silently.22 self.callManager.endLocalRing(uuid: evt.uuid)2324 case .ended:25 self.callManager.hangUp(uuid: evt.uuid)2627 default:28 break29 }30 }31 }3233 // When THIS device wants to answer, we REQUEST — we don't transition.34 func requestAnswer(uuid: UUID) async throws {35 try await socket.send(.answer(uuid: uuid, deviceId: myDeviceId))36 // The server's broadcast will drive our local transition.37 }38}
What the server needs to do.
For this to work, the server has to own one tiny piece of state per call:
- Current phase —
ringing|answered|ended. - Who answered (if phase == answered) — the device ID that won the race.
- A sequence number — monotonically increasing per call, so clients can reject out-of-order events.
When any device sends call:answer, the server's state machine applies the transition (or rejects it as a duplicate if the call is already answered by another device), then broadcasts the new phase to every subscribed device.
The subtle races you still have to handle.
1. Simultaneous answer from two devices.
User taps answer on iPhone. 50ms later, phone slips and triggers the iPad answer too. Both arrive at the server within milliseconds. The server picks one (first-write-wins by sequence number), broadcasts answered-by: iphone to everyone. iPad receives the broadcast, realises it lost the race, dismisses its local ring quietly.
The important part: the iPad does NOT show the user an error. From the user's perspective they answered on iPhone; the iPad silently stepping back is the correct behaviour.
2. Server echo arriving before the local tap finishes.
Device A sends call:answer. Server broadcasts answered-by: deviceA. If the broadcast arrives before Device A's own answer tap finishes its local UI transition, you can double-callfulfill() on the CXAnswerCallAction. CallKit does not like that.
The fix: idempotent transitions. Before fulfill()-ing a CallKit action, check your local callManager.phase; if it's alreadyanswered, no-op. Same thing for endLocalRing — if the call is already locally dismissed, no-op.
3. The device that was offline when the call ended.
Scenario: iPad was in a bad WiFi spot when the call wrapped up. It never received the call:ended broadcast. User walks back into range, iPad reconnects, and starts ringing a stale call.
Solution: when the subscriber socket reconnects, it sends a sync message with the sequence numbers it last saw. The server responds with any events the device missed, in order. The device catches up to the authoritative state before showing any UI.
Debugging this bug in production.
Multi-device sync bugs are the hardest to reproduce because they require multiple devices + specific timing. Here's what I built to catch them before users did:
- Per-call event log on the server. Every state transition + the device that requested it + the sequence number. When a bug report comes in, you can see the exact sequence of events.
- Client-side “expected vs actual” assertions in debug builds. If a device receives a state transition it didn't expect (
endedwhile it's still inringing, for example), log a breadcrumb. Not an error — a signal. - A multi-device integration test harness. Spin up three simulated clients + the server in a single test, script the scenarios: “both devices answer within 50ms”, “device goes offline during ring”, “device reconnects after end”. Assert the final state converges on all three.
Why this generalises beyond calls.
The lesson here is older than WebRTC and bigger than CallKit: when multiple clients share state, don't let any of them own it. The server is the authority. Clients subscribe. They can request changes, but the broadcast is the only thing that changes local state.
You'll meet this pattern again — in collaborative editing, in multi-device notifications, in anything with a “seen” or “read” state. The subscriber pattern isn't exotic. The reason it's not the default in your codebase is that one-device apps don't need it, so you build the ownership pattern reflexively and then it's wrong the day you add a second surface.
Related chapters.
Chapter 02: The SDP offer/answer race is the per-call version of the same lesson — serialize transitions through one owner. This chapter is the across-devices version. Both are the same shape of bug at different scales.
The subscriber pattern in this chapter is in production at YEO Messaging across iPhone + iPad + web. The WebSocket contract is a few lines of JSON; the server state machine is ~80 lines of TypeScript. The complexity is architectural, not volumetric — once the pattern is in your head, the code is short.