Skip to content

fix: reset clock sync state on reconnect#67

Merged
chrisuthe merged 1 commit intomainfrom
fix/clock-sync-on-reconnect
Mar 8, 2026
Merged

fix: reset clock sync state on reconnect#67
chrisuthe merged 1 commit intomainfrom
fix/clock-sync-on-reconnect

Conversation

@chrisuthe
Copy link
Copy Markdown
Owner

Summary

  • After WebSocket reconnection, the Kalman time filter's thaw() was restoring the full pre-disconnect measurement count, causing isConverged to return true immediately. This made TimeSyncManager use the slow converged burst strategy (3s interval, 3 bursts) instead of the aggressive initial strategy needed to re-establish accurate sync with the server.
  • Fixed by resetting measurementCount to MIN_MEASUREMENTS (2) on thaw so isReady stays true (playback continues) but isConverged returns false (forces fast re-sync).
  • Increased covariance inflation from 10x to 100x so the filter adapts faster to potentially changed conditions after reconnection.
  • Reset convergence tracking so reconvergence milestones get logged for diagnostics.

Test plan

  • Connect to a server and let sync converge (verify in Stats for Nerds)
  • Kill the server or disconnect WiFi briefly to trigger reconnection
  • Verify in logs that time filter thaw message appears and sync reconverges with aggressive burst strategy
  • Verify playback resumes without audible sync drift after reconnection
  • Verify initial connection flow is unaffected (no regression)
  • Run existing unit tests: ./gradlew :shared:testAndroidHostTest --tests "com.sendspindroid.sendspin.SendspinTimeFilterTest" (pre-existing stabilityScore test failure is unrelated)

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant