v1.3.180
Highlights
- P2P direct connection: WebRTC DataChannel between Host (Go) and Mobile
(Flutter) is now stable with P2P-priority protocol, zero message loss, and
automatic relay fallback. - Message loss fix:
sendViaTransportnow falls back to relay on P2P send
failure instead of silently dropping messages. - Gap detection fix:
SyncP2PReplayandTriggerReplayNowuse EventID
matching instead of numeric index, fixing broken gap detection when
projection store exceeds its 1000-event cap.
Fixes
P2P Message Loss Prevention
Two root causes of messages not reaching mobile have been fixed:
-
sendViaTransportsilently dropped messages on P2P send failure: The
function returnedtrueeven whenDataChannel.Send()failed, causing
senderLoopto skip relay fallback. Now returnsfalseto trigger relay
fallback — messages are never silently dropped. -
Broken gap detection in
SyncP2PReplay/TriggerReplayNow: Both
functions usedrelayHistoryCount(relay total, can be 2000+) as an array
index into the projection store capped at 1000 events. When
relayCount >= localCount, they concluded "no gap" and skipped sync. Fixed:SyncP2PReplay: usesrelayLastEventID(Event ID string match) to find
the suffix in projection events.TriggerReplayNow: replays ALL projection events (mobile deduplicates by
EventID) instead of computing a broken suffix.
P2P-Priority Protocol
SetP2PNegotiating(true)called beforehandleRelayConnectedruns recovery
plan, preventing relay replay from flooding mobile during P2P negotiation.SyncP2PReplay()sends incremental missing events via DataChannel after P2P
establishes.TriggerReplayNow()immediately replays missing events to relay after P2P
failure (not waiting for next reconnect).
Stability
- signalCh race condition: Each
Restart()creates a new channel + 5s
debounce to coalesce multipleconfirmed as clientevents. - ICE timeout: Increased to 25s with
SetICETimeouts(15s, 30s, 700ms)for
TURN/STUN tolerance behind GFW/CGNAT. p2pDonechannel: Replacesctx.Done()for P2P active state — prevents
ICE timeout from killing an active P2P connection.- pion/webrtc logging: Redirected to
debug.Log("webrtc", ...)via custom
LoggerFactory, preventing TUI corruption. - Standard log redirect: Third-party libraries using
log.Printfare
redirected todebug.Log("stderr", ...). - countTokens debug spam: Removed excessive
debug.Logcalls from context
manager.
Documentation
- Updated
docs/design/p2p-direct-connection.mdfrom design proposal to actual
implementation reference, including architecture diagrams, protocol flow,
message loss prevention, and debugging guide.
Internal
- Flutter
flutter_webrtcplugin integrated for P2P DataChannel support. - Desktop
go.mod:pion/webrtc/v4promoted from indirect to direct dependency. - TURN server configured at
turn.allpayone.net:8443with proper realm.