W3C home > Mailing lists > Public > public-device-apis-log@w3.org > September 2018

Re: [sensors] Garbage collection behavior unclear in Generic Sensor spec

From: Wanming Lin via GitHub <sysbot+gh@w3.org>
Date: Thu, 20 Sep 2018 08:52:19 +0000
To: public-device-apis-log@w3.org
Message-ID: <issue_comment.created-423099310-1537433538-sysbot+gh@w3.org>
If a Sensor object is eligible for garbage collection, UA must invoke "Deactivate a sensor object".  Looking at the implementation of "Deactivate" in chromium, which is defined as [`Deactivate();`](https://cs.chromium.org/chromium/src/third_party/blink/renderer/modules/sensor/sensor.cc?type=cs&sq=package:chromium&g=0&l=279). I try to find out where it's called for garbage collection, but searching it in [Chromium CS](https://cs.chromium.org/chromium/src/third_party/blink/renderer/modules/sensor/sensor.cc?type=cs&sq=package:chromium&g=0&l=279), only following three situations call `Deactivate()`.
- `HandleError`  //when error occurs
- `ContextDestroyed`   //when current context is destroyed
- `stop()`  //when stop() invokes

Seems Chromium did not implement the garbage collection, @rakuco, could you please confirm this?

I am not sure if my understanding is correct, actually the spec does not explicitly state the circumstances when a Sensor object(with activated/activating state) is eligible for garbage collection, but it states the circumstances when a Sensor object **must** not be garbage collected.


> It also seems that readings are only taken if an onreading handler is present. 

Looking at the spec below, and Chrome implementation, readings could be get without an "onreading" handler. (via invoking [get value from latest reading](https://w3c.github.io/sensors/#get-value-from-latest-reading) directly)

>The extension sensor interface attributes which expose sensor readings are read only and their getters must return the result of invoking [get value from latest reading](https://w3c.github.io/sensors/#get-value-from-latest-reading) with this and attribute identifier as arguments.

-- 
GitHub Notification of comment by Honry
Please view or discuss this issue at https://github.com/w3c/sensors/issues/372#issuecomment-423099310 using your GitHub account
Received on Thursday, 20 September 2018 08:52:22 UTC

This archive was generated by hypermail 2.3.1 : Thursday, 20 September 2018 08:52:22 UTC