Intent to Prototype: GravitySensor API

Skip to first unread message

Mandy, Arnaud

Jan 26, 2021, 12:32:00 PM1/26/21
to Abridged recipients
Contact emails


API spec

Expose the GravitySensor API, which provides a 3-axis reading of the gravity force, to users. Together with the readings from a LinearAccelerometer, its values form the readings obtained from an Accelerometer object.

Blink component

A gravity sensor is used to measure the force of gravity around the x, y, z axes.

As states, it is already possible for users to manually derive readings close to a GravitySensor’s by manually inspecting an Accelerometer and a LinearAccelerometer’s readings, but this can be cumbersome and depend on the accuracy of the values provided by those sensors.

Platforms such as Android can provide gravity readings as part of the platform, which should be cheaper in terms of computation, provide more accurate values depending on the user’s hardware and easier to use in terms of API ergonomics.

Search tags

TAG review

TAG review status
Issues addressed

Interoperability and Compatibility
Generic Sensor APIs, as well as other hardware-related APIs, can be controversial when it comes to interoperability because other browser engine developers have voiced privacy-related concerns.

We believe the Chromium implementation addresses those concerns. Additionally, all the data exposed by this API can already be read by users in JavaScript by calculating gravity from the Accelerometer and LinearAccelerometer readings we already provide.
Gecko: Negative Mozilla has not been asked about this specific API, but have raised concerns about the Generic Sensor APIs, including Accelerometer.
WebKit: Negative ( Although Apple has not been specifically asked about this API, they are not part of the Devices & Sensors WG, and have generally been contrary to the Generic Sensor APIs.
Web developers: Positive (

Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?

Yes, except for Mac. The readings are obtained directly from the platform on Android when possible, and implemented as a fusion sensor on top of the Accelerometer implementation otherwise (and in other OSes except for macOS). There is support for gravity sensors in the Linux kernel as well, but we need to write some extra logic to handle falling back to a fusion sensor if they are not present".

Per this discussion, only older Mac laptops seem to ship with accelerometers. We currently only ship the Accelerometer interface on Macs, but not LinearAccelerometer, in order to support the older Device Orientation/Motion APIs. As such, there does not seem to make much sense to ship this API on Macs either. 

Is this feature fully tested by web-platform-tests?

Tracking bug

Link to entry on the Chrome Platform Status

This intent message was generated by Chrome Platform Status.

Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki
Business Identity Code: 0357606 - 4
Domiciled in Helsinki

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

Thomas Steiner

Feb 5, 2021, 8:51:24 AM2/5/21
to Mandy, Arnaud, Abridged recipients
Hi all,

FYI, I have covered the new GravitySensor in the updated and migrated Generic Sensor API article (staging link, the final link will be that was initially written by two of your colleagues from Intel. 


You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

Thomas Steiner, PhD—Developer Advocate (,

Google Germany GmbH, ABC-Str. 19, 20354 Hamburg, Germany
Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
Registergericht und -nummer: Hamburg, HRB 86891

Version: GnuPG v2.1.23 (GNU/Linux)


Mandy, Arnaud

Feb 8, 2021, 3:56:51 AM2/8/21
to Thomas Steiner, Abridged recipients

Thanks for the update!


From: Thomas Steiner <>
Sent: Friday, February 5, 2021 15:51
To: Mandy, Arnaud <>
Cc: Abridged recipients <>
Subject: Re: [blink-dev] Intent to Prototype: GravitySensor API

Balazs Engedy

Feb 9, 2021, 10:17:02 AM2/9/21
to blink-dev,, Abridged recipients, Thomas Steiner
What is the accuracy of the sensor readings here? I am seeing rounding for other types of accelerometers, but not this one:

Thomas Steiner

Feb 9, 2021, 11:47:58 AM2/9/21
to Balazs Engedy, Kubo Da Costa, Raphael,, Abridged recipients, Thomas Steiner
Hi Balazs,

On Tue, Feb 9, 2021 at 4:16 PM Balazs Engedy <> wrote:
What is the accuracy of the sensor readings here? I am seeing rounding for other types of accelerometers, but not this one:

It was mentioned by @Kubo Da Costa, Raphael in #c15 that this new interface would add rounding, too (based on #c14, which, coming from the requester of this feature, makes me happy! More of this!). 


Balazs Engedy

Feb 23, 2021, 9:54:19 AM2/23/21
to blink-dev, Thomas Steiner,, Abridged recipients, Balazs Engedy, Raphael Kubo Da Costa
Thanks, Thomas! To close the loop on this, in the meantime was landed which addresses my concern.
Reply all
Reply to author
0 new messages