MobileNativeFoundation / MobileNativeFoundation/Kronos
Clock.sync() sometimes responses with no TimeInterval
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 699
- Forks
- 100
- PR merge metrics
- No merged PRs in 30d
Description
I sometimes have problems with Clock.sync() not returning a TimeInterval in the completion closure. After an analysis I found out that the problem lies in the NTPClient in private func offset(from responses: [[NTPPacket]]) throws -> TimeInterval. All server responses are filtered here by originTime (which is afaik ok). Now it can happen that certain responses take longer than 10 seconds (= kMaximumResultDispersion), especially if I use the default NTP server(s) time.apple.com with the default 4 samples. If this happens with the last response, no TimeInterval is returned. Although validate timeIntervals might have been returned beforehand. Is this done on purpose or would it also be possible to save the offsets in the sync() function (Clock.swift) and then return an average value at the end?
If I use the first closure I always get a valid offset (maybe there are cases where this response is also filtered).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in Clock.swift at sync() and NTPClient at private func offset(from responses: [[NTPPacket]]) throws -> TimeInterval. Trace how originTime filtering and kMaximumResultDispersion affect the completion closure, comparing the behavior with the first closure. Done means the sync result remains valid when a late final response is filtered, with the intended averaging behavior established and covered by the relevant tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100