Repository navigation
Use the time filter parameters from the spec - #227
Merged
Merged
Conversation
There was a problem hiding this comment.
🔵 Needs a closer look
The clock-filter tuning still needs real-browser validation under jitter and network stalls to verify convergence and playback stability beyond 100 sync rounds, when adaptive forgetting activates.
No open issues 🎉
What changed in this PR
Aligns the SDK’s clock synchronization filter with the Sendspin specification, replacing custom tuning with shared defaults.
Changes:
- Updates filter defaults, adaptive forgetting thresholds, and measurement-error scaling.
- Rejects non-positive
max_errorsamples and uses half-away-from-zero rounding for time conversions. - Updates unit tests to cover the revised defaults, rounding, and skipped-sample behavior.
| File | Description |
|---|---|
tests/unit/time-filter.test.ts |
Updates expected values and adds rounding and invalid-sample tests. |
src/core/time-filter.ts |
Implements revised filter parameters, sample validation, and rounding. |
src/core/core.ts |
Uses the time filter’s defaults instead of explicit custom parameters. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this implement/fix?
Tested with Brave, Firefox and Safari on macOS and Chrome and Firefox on Android, including a 24 minute session with 100 ms latency, 50 ms jitter and a one-way latency spike. Sync matched
mainon every device, and the clock stayed within 2 ms through the spike.The clock sync filter used its own tuning instead of the parameter values the spec now defines. It now uses the spec values, drops samples with a
max_errorof zero or less, and rounds converted times with halves away from zero, as the spec says.For the first 100 sync rounds (about 15 minutes), the clock estimate stays the same as before. The reported sync error halves, since the spec scales
max_errorby 0.5. After 100 rounds, the filter reacts to outliers less often but more strongly. The exportedSendspinTimeFilteralso defaults to the spec values now.Related issue or spec PR (if applicable):
ADAPTIVE_FORGETTING_CUTOFFwith the C++ implementation #120Types of changes
bugfixnew-featureenhancementbreaking-changerefactordocumentationmaintenancecidependencies