From f279615b003098555d8ca80e941ced0538237247 Mon Sep 17 00:00:00 2001 From: Raphael Kubo da Costa Date: Tue, 13 Dec 2022 14:35:57 +0100 Subject: [PATCH 1/5] Editorial: Export the "sensor task source" definition. Extension specifications may need to use to queue tasks in their own operations. --- index.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.bs b/index.bs index 009f03a..c5e3621 100644 --- a/index.bs +++ b/index.bs @@ -916,7 +916,7 @@ dictionary SensorOptions { A {{Sensor}} object has an associated [=platform sensor=]. -The [=task source=] for the [=tasks=] mentioned in this specification is the sensor task source. +The [=task source=] for the [=tasks=] mentioned in this specification is the sensor task source.
In the following example, firstly, we check whether the user agent has permission to access From e7c2bc41f922ea0638064e470a28a2cfd6329b00 Mon Sep 17 00:00:00 2001 From: Raphael Kubo da Costa Date: Tue, 13 Dec 2022 14:39:40 +0100 Subject: [PATCH 2/5] Mention algorithms from #429 in "Extensibility Definition Requirements". The new algorithms were defined in the "Sensor Type" section, but it makes sense to list them when describing what extension specifications may do. --- index.bs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/index.bs b/index.bs index c5e3621..16b65a6 100644 --- a/index.bs +++ b/index.bs @@ -2066,6 +2066,11 @@ for each [=sensor types=]: For [=sensor types=] where multiple [=device sensor|sensors=] are common, [=extension specifications=] may choose not to define a [=default sensor=], especially when doing so would not make sense. +- A [=threshold check algorithm=], which returns a boolean indicating whether + two sensor readings differ enough to cause the [=latest readings=] map to + be updated. +- A [=reading quantization algorithm=], which may return a sensor reading + with reduced accuracy.

Automation

From 2f8702b8d7226410c2f02ade73a493fce5132b2f Mon Sep 17 00:00:00 2001 From: Raphael Kubo da Costa Date: Tue, 13 Dec 2022 16:23:31 +0100 Subject: [PATCH 3/5] Define a "pre-activation checks algorithm". Related to w3c/ambient-light#79, where we want to replace the "ambient-light" powerful feature with an integration with the Media Capture and Streams spec by only providing illuminance readouts if the same page has an active local video source. Part of it requires checking the above condition when `Sensor.start()` is called; the new algorithm introduced here does it in the "activate a sensor object" abstract operation. Additionally, `Sensor.start()` is now invoking "activate a sensor object" as a queued task, as we want it to run in the main event loop rather than in parallel since at least the Ambient Light Sensor implementation of the "pre-activation checks algorithm" needs access to the relevant global object and its internal slots. --- index.bs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/index.bs b/index.bs index 16b65a6..a3c15b2 100644 --- a/index.bs +++ b/index.bs @@ -810,6 +810,10 @@ A [=sensor type=] may have an associated reading quantization algorithm, which takes a [=sensor reading=] and returns a less accurate [=sensor reading=]. +A [=sensor type=] may have an associated pre-activation checks +algorithm, which takes a {{Sensor}} instance and returns a boolean, to +perform extra checks before activating the given {{Sensor}} instance. +

Sensor

The current [=browsing context=]'s [=platform sensor=] must have: @@ -1169,7 +1173,7 @@ It represents a [=reading timestamp=]. but it is a tradeoff some User Agent might choose to make. --> 1. Queue a task to run [=notify error=] with [=this=] and |e| as arguments. 1. Return. - 1. Invoke [=activate a sensor object=] with [=this=] as argument. + 1. Queue a task to run [=activate a sensor object=] with [=this=] as argument.
@@ -1330,6 +1334,14 @@ to {{SensorErrorEventInit}}. :: None 1. Let |sensor| be the [=platform sensor=] associated with |sensor_instance|. + 1. Let |type| be |sensor|'s associated [=sensor type=]. + 1. If |type|'s [=pre-activation checks algorithm=] is defined: + 1. Let |result| be the result of invoking |type|'s [=pre-activation checks algorithm=] with |sensor_instance|. + 1. If |result| is false: + 1. Let |e| be the result of [=created|creating=] a "{{NotReadableError}}" {{DOMException}}. + + 1. Queue a task to run [=notify error=] with |sensor_instance| and |e|. + 1. Return. 1. [=set/Append=] |sensor_instance| to |sensor|'s set of [=activated sensor objects=]. 1. Invoke [=set sensor settings=] with |sensor| as argument. 1. Queue a task to run [=notify activated state=] with |sensor_instance| @@ -2071,6 +2083,8 @@ for each [=sensor types=]: be updated. - A [=reading quantization algorithm=], which may return a sensor reading with reduced accuracy. +- A [=pre-activation checks algorithm=] with extra steps that are run + before a {{Sensor}} instance is activated.

Automation

From 92fefabe9b117db7b4c8591c0c21ccccc07fdcda Mon Sep 17 00:00:00 2001 From: Raphael Kubo da Costa Date: Tue, 13 Dec 2022 16:28:08 +0100 Subject: [PATCH 4/5] Stop requiring sensor permissions names to be a non-empty set. Related to w3c/ambient-light#79, where we want to replace the "ambient-light" powerful feature with an integration with the Media Capture and Streams spec by only providing illuminance readouts if the same page has an active local video source. In this case, we rely on the Media Capture and Streams' permission model, as having an active local video source implicitly means the "camera" permission has already been granted. Mention the Ambient Light Sensor case and change the requirement for the snesor permissions name set. --- index.bs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/index.bs b/index.bs index a3c15b2..ef2cfbd 100644 --- a/index.bs +++ b/index.bs @@ -84,8 +84,12 @@ urlPrefix: https://w3c.github.io/geolocation-sensor/; spec: GEOLOCATION-SENSOR urlPrefix: https://w3c.github.io/proximity; spec: PROXIMITY type: dfn text: ProximitySensor; url: proximity-sensor-interface +urlPrefix: https://w3c.github.io/mediacapture-main/; spec: MEDIACAPTURE-STREAMS + type: dfn + text: stopped; url: source-stopped