Closed Bug 1296125 Opened 5 years ago Closed 5 years ago

position.timestamp is microseconds in native location providers

Categories

(Core :: DOM: Geolocation, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla51
Tracking Status
firefox51 --- fixed

People

(Reporter: dietrich, Assigned: dougt)

Details

(Keywords: DevAdvocacy)

Attachments

(1 file, 1 obsolete file)

<script>
  navigator.geolocation.watchPosition(function(position) {
    document.body.innerHTML = 'timestamp: ' + position.timestamp
      + ', new Date(timestamp): ' + new Date(position.timestamp);
  });
</script>

MDN says should be milliseconds:

https://developer.mozilla.org/en-US/docs/Web/API/Position/timestamp

Spec says should be milliseconds:

https://www.w3.org/TR/geolocation-API/#position

Fennec implements as milliseconds.




(If it were up to me, it'd be implemented in millivanilliseconds.)
Keywords: DevAdvocacy
Priority: -- → P3
Confirmed this is only on Mac. Linux and Windows are unaffected.
Thanks Dietrich.

Basically Mac (nightly?) uses the native location provider.  Most platforms use the network based on (GLS/MLS).


The bug on the mac is here:

https://dxr.mozilla.org/mozilla-central/source/dom/system/mac/CoreLocationLocationProvider.mm?q=CoreLocationLocationProvider.mm&redirect_type=direct#103

PR_Now() is defined in microseconds:

https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSPR/Reference/PR_Now


I think we should just replace this PR_Now() with PR_IntervalToMicroseconds(PR_IntervalNow())


We should audit the other places we use PR_Now(). For example, windows does:

https://dxr.mozilla.org/mozilla-central/source/dom/system/windows/WindowsLocationProvider.cpp#176
Summary: position.timestamp is microseconds on desktop (mac), should be milliseconds → position.timestamp is microseconds in native location providers
Attached file bug_1296125_use_milliseconds (obsolete) —
Attachment #8784113 - Flags: review?(kchen)
Attachment #8784113 - Attachment is obsolete: true
Attachment #8784113 - Attachment is patch: false
Attachment #8784113 - Flags: review?(kchen)
Assignee: nobody → doug.turner
Attachment #8784115 - Flags: review?(kchen)
Comment on attachment 8784115 [details] [diff] [review]
bug_1296125_use_milliseconds

Review of attachment 8784115 [details] [diff] [review]:
-----------------------------------------------------------------

LGTM
Attachment #8784115 - Flags: review?(kchen) → review+
Keywords: checkin-needed
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/b4a425b5c3ae
Geolocation timestamp sometimes uses microseconds instead of milliseconds. r=kchen
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/b4a425b5c3ae
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla51
You need to log in before you can comment on or make changes to this bug.