Skip to content

Does SensorReading always need a timeStamp ? #105

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

Closed
riju opened this issue May 9, 2016 · 14 comments
Closed

Does SensorReading always need a timeStamp ? #105

riju opened this issue May 9, 2016 · 14 comments

Comments

@riju
Copy link
Contributor

riju commented May 9, 2016

@timvolodine asked : concrete sensors readings would derive from SensorReading. However do we always need a timeStamp? looks like can be potentially overhead for very hi-frequency
sensors. Maybe it should be nullable or not there at all ?

@tobie
Copy link
Member

tobie commented May 9, 2016

timestamps are the only way to compute both latency and frequency, so it seems like they're super useful.

What's the overhead of providing those? I imagine they're provided by the underlying platforms anyway, no?

@tobie
Copy link
Member

tobie commented May 9, 2016

Also, without timestamps, how would we know the freshness of the sensor reading?

@riju
Copy link
Contributor Author

riju commented May 11, 2016

Atleast on Android side, SensorEvent provides timestamps.

public void onSensorChanged(SensorEvent event) {
     if (event.sensor.getType() == Sensor.TYPE_LIGHT) {
          mLastUpdate.illuminance = event.values[0];
          mLastUpdate.timestamp = event.timestamp;
     }
} 

@tobie
Copy link
Member

tobie commented May 11, 2016

What does that timestamp correspond to? It's unclear from the docs.

@riju
Copy link
Contributor Author

riju commented May 11, 2016

The time in nanosecond at which the event happened
Source : SensorEvent

@tobie
Copy link
Member

tobie commented May 11, 2016

So it's the time at which the event object is constructed, not the time of the reading.

@riju
Copy link
Contributor Author

riju commented May 11, 2016

Yes there is some confusion in the docs, maybe I should use the timestamps this way

long timeInMillis = System.currentTimeMillis()
                             + ((event.timestamp 
                             -  SystemClock.elapsedRealtimeNanos())/1000000L);

@tobie
Copy link
Member

tobie commented May 11, 2016

Well, what we want is a monotonic clock here, so DOMHighResTimeStamp is the way to go. I don't know if the above gives you that.

@tobie
Copy link
Member

tobie commented May 11, 2016

So there seems to be confusion as to what base this timestamp is from, and whether it's the timestamp at which the event is dispatched or at which the sensor data is obtained.

@mwichmann
Copy link

mwichmann commented May 14, 2016

This is an interesting problem. There are all kinds of sensors, and thus a number of different reporting styles. In some cases it's important to relate the event to a real time - we want to know that this reading was taken at 8:02 AM locally, which means we want to know the timezone/DST situation as well. In some other cases the interesting data is the relative time to other captures - here we don't want tz/dst, and we don't want to be affected by any possible time changes on the device. Think of these as Realtime Clock vs. Monotonic Clock. And I can imagine in some cases, we may not care at all about the time - that's the original subject of this issue. In general, the situation is more determined by the sensor in question than the application talking to it. Can there be a way to express the time in a flexible way such that the sensor can choose any of these three as their preferred reporting style?

@tobie
Copy link
Member

tobie commented May 14, 2016

This spec exclusively focuses on local MEMS sensors for now, so we're looking at monotonic time stamps only as I don't think there are use cases for epoch-based timestamps which can't be easily solved with an in document conversion. Of course, once we'll move these to service workers, considerations will be different, but that's not the only thing that'll need to be reconsidered.

I think the key questions here are:

  • are there perf reasons to avoid timestamps?
  • what do the timestamps in the underlying platform actually measure?
  • do those underlying timestamps actually help us meet our use cases?

@timvolodine
Copy link

timvolodine commented May 16, 2016

We should probably stick to using the timestamps provided by the platform (?)
not really sure about the use-cases, but may be actually useful for measuring how "stale" a particular data is (as was already mentioned by @tobie I think)

Looks like on Android and Windows there are timestamps provided by the platform (although the exact semantics may be different). However I am curious as to what will happen if a platform is unable (or unwilling ;)) to provide timestamps.. or does this never happen?

@tobie
Copy link
Member

tobie commented May 16, 2016

We should probably stick to using the timestamps provided by the platform (?)

Agreed (though we'll obviously have to convert them to whatever baseline we're using).

not really sure about the use-cases, but may be actually useful for measuring how "stale" a particular data is (as was already mentioned by tobie@ I think)

Yes. Measuring latency (granted the timestamp is that of the sensor reading, and not the Java event) and frequency also come to mind.

Looks like on Android and Windows there are timestamps provided by the platform (although the exact semantics may be different). However I am curious as to what will happen if a platform is unable (or unwilling ;)) to provide timestamps.

Well, in that case, I guess we'd just use the equivalent of calling performance.now().

or does this never happen?

I think all underlying platforms have at least a timestamp for when the reading is communicated to UA (or can generate one pretty easily).

@anssiko
Copy link
Member

anssiko commented Sep 20, 2016

F2F agreement, we'll do need a timestamp for SensorReadings.

@anssiko anssiko closed this as completed Sep 20, 2016
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

5 participants