Closed alexshalamov closed 6 years ago
@pozdnyakov wdyt?
Not sure, it might be so that we don't know what is supported until ask platform side, i.e. assume orientation information is provided on Android and is not provided on Windows but JS bindings are platform-agnostic. IMO onerror
is a safer option.
If device has no screen, i.e., window === null
, then we can throw immediately. In other cases, window.screen.orientation
is sync, and available on all platforms, except Safari that has window.orientation
.
I'm not aware of the cases / platforms where we would need to handle such errors asynchronously. We can keep this issue open, get more data and find solution after research is done.
GenericSensor spec could have two hooks for error conditions related to unsupported sensor options:
options
cannot be identified synchronously, or when platform support for particular feature changes at runtime.@pozdnyakov @anssiko wdyt?
I'd suggest we make this Level 1 since this feature is logically part of https://github.com/w3c/sensors/pull/340. Secondly, this feature was asked for by early adopters further raising the priority.
@alexshalamov can you open respective issues for other affected sensors?
It'd be more convenient for the usual feature detection scenarios if we can make this sync and throw at construction time. Based on the initial investigation it sounds like that is doable. For related runtime errors we can use the asynchronous error reporting path (e.g. if the user locks the screen orientation while using the app?).
Marked as "Level 1" per WG call decision.
All affected concrete sensor specifications have also been updated accordingly:
Accelerometer: https://github.com/w3c/accelerometer/pull/45 Gyroscope: https://github.com/w3c/gyroscope/pull/37 Magnetometer: https://github.com/w3c/magnetometer/pull/46 Orientation Sensor: https://github.com/w3c/orientation-sensor/pull/57
In my opinion, yes, from https://w3c.github.io/accelerometer/#construct-spatial-sensor-object operation