- From: Peter Hoddie via GitHub <sysbot+gh@w3.org>
- Date: Tue, 18 Sep 2018 16:31:23 +0000
- To: public-device-apis-log@w3.org
phoddie has just created a new issue for https://github.com/w3c/sensors: == Garbage collection behavior unclear in Generic Sensor spec == I've created an implementation of Generic Sensor for the Moddable SDK. The implementation attempts to follow the specification as precisely as possible. In implementing the activation / garbage collection behavior I encountered what may be a problem with the specification. The text (https://w3c.github.io/sensors/#sensor-garbage-collection) describes two cases where the Sensor must NOT be collected. It then states that a sensor that is ELIGIBLE to be collected must be deactivated. Therefore, if the first two rules do not apply, then the sensor is eligible to be collected. Consider this fragment: ````` let a = new Accelerometer; a.start(); a.onactivate = function() {} `````` The intended behavior of the code is straightforward: a new `Accelerometer` sensor is created, it is started, and it has callback to receive activate events. The application will poll the sensor to retrieve readings. Following the specification, the sensor begins in the `idle` state. When `start` is called, the sensor progresses to the `activating` state. There are no Event Handlers installed, so the sensor is eligible to be garbage collected. Therefore, we run the deactivation steps which returns the state to `idle`. Actually, that last step unclear to me. The test for "Deactivate a sensor object" does not say set the state to `idle`. However, (1) the diagram in "Sensor lifecycle" indicates to return to `idle` if `activating` does not complete successfully and (2) if a sensor has determined it going to be collected, what other state should it be in? The implementation could remain in the `activating` state after running "Deactivate a sensor object." If an event handler is installed before the sensor is collected, then it is no longer eligible to be collected so it will run "Activate a sensor object". Perhaps that is what the specification intends, but that reading feels like a stretch. Please view or discuss this issue at https://github.com/w3c/sensors/issues/372 using your GitHub account
Received on Tuesday, 18 September 2018 16:31:24 UTC