AbsoluteOrientationSensor and RelativeOrientationSensor
Fused device orientation as a quaternion or rotation matrix.
In one line
Can find which way your device is facing and tilted in 3D
Fused device orientation as a quaternion or rotation matrix.
Gives exact device attitude relative to Earth (absolute) or to its start pose (relative). Same privacy class as DeviceOrientation but easier to use for 3D scenes.
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
- Find the device's tilt and facing, compared with the Earth or with where it started
- Move a 3D scene, map or AR view as you turn the phone
- Give smoother results than basic tilt events
It cannot
- Run in Firefox or Safari, which do not support it
- Show a prompt in Chrome; there is none by default
- Know where you are on the map from it
- Measure orientation while the page is closed
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 | Not available | 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 AbsoluteOrientationSensor({frequency}); new RelativeOrientationSensor(); quaternion; populateMatrix() |
| Permission name | accelerometer, gyroscope, magnetometer (absolute); accelerometer, gyroscope (relative) |
| Permissions policy | accelerometer |
| Browser compat keys | api.AbsoluteOrientationSensorapi.RelativeOrientationSensorapi.OrientationSensor |
| 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 |
|---|---|---|---|---|
quaternion | list of 4 floats | unit quaternion | -1 to 1 | float32 |
frequency | float | Hz | 1 to 60 | 1 Hz |
Technical limits
- Absolute needs three sensor permissions, relative needs two
- Needs focus and secure context
The story
What it is
The page gets your exact device angle, from sensors blended together.
For you
A 3D scene or map matches the way you hold your phone with no jitter. On many phones there is no prompt. It is the same data as tilt, just smoother.
For makers
Makers use it for smooth 3D, AR and camera control. It has the same privacy class as tilt and motion events, so it can be fingerprinted and can leak typing.
Where you see it
| Type | Example | Apps |
|---|---|---|
| games | A browser 3D game or VR cardboard view turns the camera exactly with your head or phone. | None named |
| ar-vr | A web AR page keeps a 3D model locked to your room as you move. | 8th Wall, Model Viewer |
| maps | A map uses full orientation to show a street view pointing where you face. | Google Street View |
| media | A virtual tour or 360 video lets you look around by moving your phone. | None named |
| analytics | A tracker records orientation as part of a motion profile. | None named |
| security | A site checks for steady human hand motion to catch emulators. | None named |
Risks
- Same leaks as tilt data
- Fingerprint clue
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
- 3D model viewers
- Panoramas
Known abuse
- Same as DeviceOrientation
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 | 3 | Rough identifying entropy, when known |
History
- 2018-05, Chrome 67: Orientation sensors ship with the Generic Sensor API
Related capabilities
Related
- DeviceOrientation and DeviceMotion events. Can sense how your phone is tilted and shaken, sometimes only after you allow it
- Accelerometer, LinearAccelerationSensor, GravitySensor. Can feel how your device moves and rests while the page is open
Sources
How well checked: Based on official documentation.