-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Screen Brightness API #17
Comments
Love this proposal! Let’s discuss amendment
|
I agree with @tomayac. Use cases would benefit from simply setting max brightness with a screen wake lock. And with this, no problem of privacy and fingerprinting. // Request a screen wake lock with maximum brightness:
const wakeLock = await navigator.wakeLock.request({
maximumScreenBrightness: true,
});
// Release it again after 5s.
setTimeout(() => {
wakeLock.release();
}, 5000); |
Integrating into the Wake Lock API would be good, but how to feature detect if the screen brightness option is supported? |
A static method like |
(Catching up after the holidays.)
We'd probably need an engineering champion who would be willing to implement this. Raphael from Intel has been working on Wake Lock. @anssiko, do you know if he could be interested? |
Should we have an origin trial to try out, your company would be an ideal candidate to do so, and of course also spread the word about it on something like your company tech blog if you have one. We would probably also be interested in writing a case study if this feature proved useful. |
Having discussed this at the DAS WG meeting, I think it would be more productive to close this proposal and incorporate it and its feedback into a piece of work that would upgrade the existing Screen Wake Lock API. Context here: w3c/screen-wake-lock#129 (comment) |
It would be really useful. I really support this proposals. 👍 |
Nice! What would you use a screen brightness API for? |
I have a barcode application, people use in patrol stations they got discount when they show the barcode and it would be great increase the brightness when barcode is on the screen. |
@tamascsaba Nice! Do you mind sharing your web app URL? |
Introduction
When displaying scannable images like barcodes or QR codes, readability by software is assisted by temporarily maximising the screen brightness.
Browser based Web apps currently cannot do this which negatively impacts user experience and accuracy should the screen be needed in tandem with the front facing camera to illuminate or scan something.
Native apps have the ability to set screen brightness with relative ease:
iOS (possibly with M1 Macbooks?) has
setBrightness
:Android has this three liner:
More discussion around how Screen Brightness is needed and how it may interact with other sensors and APIs here:
Describe the challenge or problem on the web you are proposing we address.
Use Cases (Recommended)
This ability would benefit:
Goals (Optional)
Non-goals (Optional)
Proposed Solution
Add object to
navigator
calledscreenBrightness
:brightness: Float
returns current brightness percentage in the range of0.0..1.0
override({ brightness, maxDuration }): BrightnessLock
async function, returning aBrightnessLock
when brightness target met, agnostic to implementation (instant or transition).brightness: Float
requested screen brightnessmaxDuration: Number
maximum time the lock will be in effect, if unspecified then defaults to vendor value. TheBrightnessLock
should be released by the requesting userland code before this time elapses, otherwise the vendor must release it.Add
BrightnessLock
implementation:brightness: Float
returns the requested brightnessrelease: Promise<Float>
reverts to the OS controlled brightness, resolving with the new brightness level which may differ from the state prior to theBrightnessLock
expires: DOMHighResTimestamp
the expiry time according tomaxDuration
Add
brightness
to Feature Policy for use in nested browsing contexts.Examples (Recommended)
Alternate Approaches (Optional)
Extending the Wake Lock API with an option for
screenBrightness
:Privacy & Security Considerations
What information might this feature expose to Web sites or other parties, and for what purposes is that exposure necessary?
Possible fingerprinting, although the screen brightness should change over time independently of the user's device, according to device ambient light sensor feedback or user control.
Do features in your specification expose the minimum amount of information necessary to enable their intended uses?
Yes.
How do the features in your specification deal with personal information, personally-identifiable information (PII), or information derived from them?
No PII.
How do the features in your specification deal with sensitive information?
No sensitive information.
Do the features in your specification introduce new state for an origin that persists across browsing sessions?
No, any brightness lock should be implicitly released when a page is hidden or closed.
Do the features in your specification expose information about the underlying platform to origins?
Yes, but to a minimal extent. The presence of an API may infer some hardware information, and the time it takes to transition between brightness values may infer hardware and software information.
Do features in this specification allow an origin access to sensors on a user’s device?
Not directly. An argument could be made that reading the untouched value of the brightness may be used as a proxy value for accessing an ambient light sensor, but this wouldn't be very precise.
What data do the features in this specification expose to an origin? Please also document what data is identical to data exposed by other features, in the same or different contexts.
The device's screen brightness, specifically that of the display hosting the requesting application.
Do feautres in this specification enable new script execution/loading mechanisms?
No.
Do features in this specification allow an origin to access other devices?
No.
Do features in this specification allow an origin some measure of control over a user agent’s native UI?
No.
What temporary identifiers do the features in this specification create or expose to the web?
Presence of a specific screen brightness value. If it is felt that this is significant, this could be mitigated by a maximum lifetime on the brightness lock, enforced by browser vendors.
How does this specification distinguish between behavior in first-party and third-party contexts?
By default this API should be enabled on top level browsing contexts and by feature policy for nested browsing contexts.
How do the features in this specification work in the context of a browser’s Private Browsing or Incognito mode?
Ideally the same, but the brightness getter could reduce precision or return 0.75 by default unless it is overridden with a BrightnessLock.
Does this specification have both "Security Considerations" and "Privacy Considerations" sections?
Yes. Security is an issue due to handing control over a high-battery-usage component to the web, and could be mitigated by browser vendors and operating systems alike, either by denying access for battery reasons, or adding a maximum lock duration.
Do features in your specification enable downgrading default security characteristics?
No.
Let’s Discuss (Optional)
The text was updated successfully, but these errors were encountered: