Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comparison between seconds and milliseconds in "Report latest reading updated"? #441

Open
rakuco opened this issue Oct 6, 2022 · 1 comment

Comments

@rakuco
Copy link
Member

rakuco commented Oct 6, 2022

https://w3c.github.io/sensors/#report-latest-reading-updated has:

  • Let reportingInterval be the result of 1 / reportingFrequency.
  • Let timestampDelta be the result of latest reading["timestamp"] - lastReportedTimestamp.
  • If timestampDelta is greater than or equal to reportingInterval
    • [...]

reportingFrequency is measured in Hz, so reportingInterval is measured in seconds. latest reading["timestamp"] and lastReportedTimestamp, on the other hand, are high resolution timestamps measured in milliseconds.

A timestampDelta of 2 means a different of two milliseconds, while a sampling frequency of 1Hz means reportingInterval is 1 and the check above will be true even though it should not.

@reillyeon
Copy link
Member

Good catch. I assume this bug doesn't exist in the implementation thanks to using safer time types in actual code.

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

No branches or pull requests

2 participants