Skip to Content
Platform.Ontology

AmbientLightSensor

Reads the light level (lux) around the device; not shipped by default anywhere.

Asks you firstLocation and motionGeneric Sensor APIWeb browsersWhile you use it

In one line

Can't use your device's light sensor in most browsers today

Reads the light level (lux) around the device; not shipped by default anywhere.

Shows whether the person is indoors, outdoors or in a dark room. Research showed it can leak visited links and cross-origin pixels, so Chrome keeps it behind a flag and Firefox removed it.

What it can and can't do

What the user does: Nothing. Chrome keeps it off by default behind a setting, and Firefox removed it

It can

  • Measure the light level (lux) if you turn the browser flag on
  • Hint whether you are outside, indoors or in a dark room
  • Dim or brighten a page when it works

It cannot

  • Run by default in Chrome, Edge or Samsung Internet; it sits behind a flag
  • Run in Firefox, which removed it, or in Safari, which never had it
  • Avoid privacy risks; research found it can leak visited links and screen pixels

How it differs between platforms: Chrome-based browsers have it only behind a flag. Firefox removed it and Safari never added it.

Browser support

BrowserStatusFirst versionReleasedNote
ChromeBehind a flag67Not listedNeeds chrome://flags generic-sensor-extra-classes
EdgeBehind a flag79Not listedNone
FirefoxRemoved622018-09-05devicelight events removed from release builds
SafariNot supportedNot availableNot listedNone
Safari on iPhoneNot supportedNot availableNot listedNone
Chrome on AndroidBehind a flag67Not listedNone
Samsung InternetBehind a flag9.0Not listedNone

How a site asks for it

APInew AmbientLightSensor({frequency}); sensor.illuminance; legacy 'devicelight' event
Permission nameambient-light-sensor
Permissions policyambient-light-sensor
Browser compat keysapi.AmbientLightSensor
How access is grantedprompt
What the user seesChromium 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 gestureNo
How long it lastsSite setting Allow or Block per origin
How to take it backchrome://settings/content/sensors; Permissions API 'change' event
Inside an iframeCross-origin iframes blocked unless allow="ambient-light-sensor"; page must be focused and visible

Typical flow

  1. Check isSecureContext and Permissions Policy
  2. Construct the sensor with {frequency: 60}
  3. sensor.start()
  4. '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)

FieldTypeUnitRangePrecision
illuminancefloatlux0 to about 100000coarse rounding in flag builds
frequencyfloatHz1 to 101 Hz

Technical limits

  • Unusable on stable by default in major browsers
  • Secure context and policy still apply when flagged on

The story

What it is

Reads how bright it is around your device. Not available by default in browsers.

For you

Almost no one will see this. If it were on, a page could dim itself in a dark room. It is not turned on in browsers by default, because it was found to leak information.

For makers

Makers wanted it for auto dark mode and for reading light for photos. It was held back after research showed it could leak links you visited and pixels from another site.

Where you see it

TypeExampleApps
mediaA reading or video page could switch to dark mode when your room goes dark.None named
accessibilityA web app could raise contrast in bright sunlight to help low vision readers.None named
ar-vrA web AR scene could match virtual lighting to the room.None named
gamesA browser game could change its look at night to match your room light.None named
analyticsTrackers would see if you are indoors or outside, and a screen reflection could leak details.None named
securityResearchers showed it could guess visited links and cross site pixels, so browsers held it back.None named

Risks

  • Leaks what is on screen
  • Hardly shipped

Good uses and abuse

Legitimate uses

  • Auto dark mode
  • Reading apps

Known abuse

  • Cross-origin link and pixel leaks via light reflection

Scores

ScoreValueMeaning
Sensitivity2 of 5How revealing the data is
Utility2 of 5How useful it is to honest apps
Friction3 of 5How much the user has to do
Fingerprint bits2Rough identifying entropy, when known

History

  • 2017, paper n/a: Olejnik analysis of light sensor leaks (links, pixels)
  • 2018-05, Chrome 67: Implemented but disabled by default
  • 2018-09, Firefox 62: devicelight and lightlevel events disabled after privacy findings

Sources

How well checked: Based on official documentation.

On this page