lyft / lyft/Kronos-Android

KronosClock returns stale cached time after device reboot if syncInBackground is called before getCurrentTime

Open
#67 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Kotlin
Stars
287
Forks
17
PR merge metrics
No merged PRs in 30d

Description

PR https://github.com/lyft/Kronos-Android/pull/51 attempted to fix an issue where the local cache was not cleared after a device reboot, but it overlooked another edge case.

If the user calls `syncInBackground` before `getCurrentTime`, the `SntpService.state` variable will be set to `State.SYNCING`. As a result, the `isCachedFromPreviousBoot` check always evaluates to false while the sync is in progress. This creates a short window (a few seconds) during which `getCurrentTime` may return an incorrectly computed time based on a stale local cache.

Additionally, PR https://github.com/lyft/Kronos-Android/pull/51 removes `State.INIT`, which introduces another issue described in https://github.com/lyft/Kronos-Android/issues/61, where the local cache is cleared every time the user manually changes the system time.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in SntpService by tracing syncInBackground, getCurrentTime, state, and isCachedFromPreviousBoot during reboot handling. Review PR #51 and issue #61 for the related state behavior; done means stale cached time is not returned during synchronization and the cache is not cleared incorrectly after manual time changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.