w3c / accelerometer

Accelerometer
https://www.w3.org/TR/accelerometer/
Other
18 stars 25 forks source link

Should we throw exception when screen coordinate system is not supported? #35

Closed alexshalamov closed 6 years ago

alexshalamov commented 6 years ago

In my opinion, yes, from https://w3c.github.io/accelerometer/#construct-spatial-sensor-object operation

alexshalamov commented 6 years ago

@pozdnyakov wdyt?

pozdnyakov commented 6 years ago

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.

alexshalamov commented 6 years ago

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.

alexshalamov commented 6 years ago

GenericSensor spec could have two hooks for error conditions related to unsupported sensor options:

@pozdnyakov @anssiko wdyt?

anssiko commented 6 years ago

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?).

anssiko commented 6 years ago

Marked as "Level 1" per WG call decision.

pozdnyakov commented 6 years ago

Fixed with https://github.com/w3c/sensors/pull/356 and https://github.com/w3c/accelerometer/pull/45

anssiko commented 6 years ago

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