Accelerometer, LinearAccelerationSensor, GravitySensor
Reads device acceleration, with or without gravity, as a stream.
In one line
Can feel how your device moves and rests while the page is open
Reads device acceleration, with or without gravity, as a stream.
Shows how the phone moves and rests: walking cadence, vehicle vibration, on a table or in a pocket. Sensor noise can fingerprint the hardware.
What it can and can't do
What the user does: Nothing in most browsers. Chrome allows it by default unless you changed Motion sensors in site settings
It can
- Measure movement with or without gravity
- Spot walking, riding in a vehicle, or lying on a table
- Move a game or view as you shake or tilt
It cannot
- Run in Firefox or Safari, which do not support it
- Show a prompt in Chrome; there is none by default
- Measure movement while the page is closed
- Know your location from it
How it differs between platforms: Chrome, Edge and Samsung Internet support it. Safari and Firefox do not.
Browser support
| Browser | Status | First version | Released | Note |
|---|---|---|---|---|
| Chrome | Supported | 67 | 2018-05-29 | None |
| Edge | Supported | 79 | 2020-01-15 | None |
| Firefox | Not supported | DeviceMotion events only | Not listed | None |
| Safari | Not supported | Not available | Not listed | None |
| Safari on iPhone | Not supported | Not available | Not listed | None |
| Chrome on Android | Supported | 67 | 2018-05-31 | None |
| Samsung Internet | Supported | 9.0 | 2018-09-15 | None |
How a site asks for it
| API | new Accelerometer({frequency, referenceFrame}); new LinearAccelerationSensor(); new GravitySensor() |
| Permission name | accelerometer |
| Permissions policy | accelerometer |
| Browser compat keys | api.Accelerometerapi.LinearAccelerationSensorapi.GravitySensor |
| How access is granted | prompt |
| What the user sees | Chromium shows no bubble: access follows the Motion sensors site setting (default Allow) plus the Permissions API name. Safari and Firefox do not ship the API. |
| Needs a secure context (HTTPS) | Yes |
| Needs a user gesture | No |
| How long it lasts | Site setting Allow or Block per origin |
| How to take it back | chrome://settings/content/sensors; Permissions API 'change' event |
| Inside an iframe | Cross-origin iframes blocked unless allow="accelerometer"; page must be focused and visible |
Typical flow
- Check isSecureContext and Permissions Policy
- Construct the sensor with {frequency: 60}
- sensor.start()
- 'reading' events fire; 'error' event on NotAllowedError or NotReadableError
Data you get
What comes back: Sensor readings at the requested frequency
Shape: event
How often: up to 60 Hz (Chrome caps frequency)
| Field | Type | Unit | Range | Precision |
|---|---|---|---|---|
x, y, z | float | m/s2 | about -78 to 78 hardware limit | about 0.01 |
frequency | float | Hz | 1 to 60 (Chrome cap) | 1 Hz |
Technical limits
- Chrome caps at 60 Hz
- Stops when the page is hidden
- Not in Firefox or Safari
The story
What it is
The page reads a live stream of how your device moves and which way is down.
For you
You shake or walk and a web app reacts, for example a step counter or a ball that rolls. On many phones there is no big prompt. Tiny differences in the sensor can also make your device recognizable.
For makers
Makers use it for tilt controls, step counting and gestures. Trackers use sensor noise as a fingerprint, and researchers showed walking patterns and keystrokes can be guessed from it.
Where you see it
| Type | Example | Apps |
|---|---|---|
| games | A browser racing or maze game lets you steer by tilting your phone. | None named |
| fitness | A web fitness page counts steps or jumps and times your reps. | None named |
| health | A fall detection or walking test page uses motion to check balance. | None named |
| ar-vr | A web AR scene keeps a model steady as you move your phone. | 8th Wall |
| security | A fraud tool checks for natural motion, since a bot farm phone sits perfectly still. | None named |
| analytics | A fingerprinting script uses sensor noise to recognize a phone across sites. | None named |
Risks
- Sensor noise fingerprints devices
- Can leak typing
What the platform says
- Google Chrome: Generic Sensor API. Chrome describes a common way for web pages to read motion and environment sensors such as accelerometer and gyroscope.
Good uses and abuse
Legitimate uses
- Motion-controlled games
- Activity recognition PWAs
Known abuse
- Hardware fingerprinting from calibration error
- Keystroke inference side channels
Scores
| Score | Value | Meaning |
|---|---|---|
| Sensitivity | 3 of 5 | How revealing the data is |
| Utility | 3 of 5 | How useful it is to honest apps |
| Friction | 1 of 5 | How much the user has to do |
| Fingerprint bits | 5 | Rough identifying entropy, when known |
History
- 2018-05, Chrome 67: Generic Sensor API and Accelerometer ship
- 2019, Firefox n/a: Mozilla and WebKit declined Generic Sensor citing fingerprinting
Related capabilities
Related
- DeviceOrientation and DeviceMotion events. Can sense how your phone is tilted and shaken, sometimes only after you allow it
- Gyroscope. Can feel how fast your device turns while the page is open
Sources
How well checked: Based on official documentation.