-
Notifications
You must be signed in to change notification settings - Fork 15
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
Detect power saving mode #9
Comments
Thanks for your suggestion. I assume you mean some sort of It would be great to hear more specific use cases, i.e. how you would use such a feature in real-life web applications. That'd help make a case why the feature is important and should be standardized. You can drop some pseudo code if you like, or give pointers to existing projects that would benefit from this feature. Thanks! |
If i would want some sort of On my android phone i can turn on power saving mode whenever i want. Even if the battery is on 80%. This could be useful if i know i will be gone for a long time and won't be able to charge my phone for a while where i will spend time on my phone to pass my time (like on a airplain across the globe). or when i'm laying in my bed before i go to sleep and spend some time on my phone and it pass below 15% it goes in to battery saving mode. but i can immediately turn it off again cuz i will soon go to sleep (just want to spend 10 more minutes to read my emails) and then charge my phone overnight I would want something more like android's the power saving mode is more user controlled and not based on some |
Thanks for the clarification, that's very helpful. The W3C Working Group will look into this and report back in this issue. |
It seems the use cases I documented a while ago are relevant here, adjusted slightly to map to the power saving mode:
The Web Budget API could be relevant to this discussion, but it is scoped to background operations. |
those are some good use cases only different is my suggestion is based on power saving mode rather then a certain battery level |
I think @jimmywarting's suggestion makes sense— if the user explicitly requested apps on their device to save battery it'd be cool for Web apps to be able to help them do that. (The operating system and user agent already do this by e.g. batching or delaying push message delivery.) I don't see any particular reason to limit the Budget API to background operations, modulo narrowing the scope to get the spec started. I do wonder about it's applicability in this case: the user agent can decide on the cost of an operation such as delivering a push message or giving Background Sync another try, because it's aware of its scope. The request in this issue is different in that it involves action by the developer: decreased WebGL quality, postponing arbitrary JavaScript work, and so on. It'll be difficult to fit the two in the same framework. Instead, a very simple event ( |
@beverloo Thanks for the Budget API explainer! We will look into adding another simple event to the Battery Status API to address this use case. I'll label this as "v2" to indicate this is a new feature under consideration. |
Just a little note to why i changed the title:
I thought maybe what if the device don't have a battery and it still wants to use power saving mode? That's why i thought androids naming was a little better. |
When power save mode is active on Chrome Android, all videos stop playing automatically. Unfortunately, the browser does not provide a play button fallback because |
@lucpotage, that sounds like a bug you should file for Chrome Android at https://crbug.com/new |
Thank you for your suggestion. I got an answer from the team: https://bugs.chromium.org/p/chromium/issues/detail?id=804840 |
I think this is related: https://wicg.github.io/savedata/#save-data-request-header-field |
@Malvoz Not quite
Saving data bandwidth and battery is not the same thing detecting power saving mode is more about saving power/battery. it would be more like: "Okey i should disable animations on the hole page in this offline application" or stop mining bitcoins |
@Malvoz Minimizing cellular-data use saves significant energy. In general, cellular antennae and transceivers are among the most energy-using/wasting hardware components of mobile devices. |
@js-choi, true that. Reducing cellular-data saves some energy. But there are still other things that can draw lots of energy too. The screen is a big factor as well. Adjusting your app for AMOLEDs came to mind now.
"To me power saving mode and data saving are two different things." Opera and Chrome has this thing where you can save data by allowing data to pass throught theres servers that compresses the data beforehand. That has nothing to do with power saving. I could have 95% battery but a crapy data plan or very little data left to use. Having data saving mode on dose not mean i want all my offline apps on my phone beginning to optimizing for power supply. Turning on data saving mode could be like asking for best zip compression from a server but you know it will take longer time to generate and possible extra delay. |
I'd like to see a way to detect low power mode. As others have already noted, the existing data saver mode is related, but not exactly the same. |
Seeing that Apple has rejected battery API due to fingerprinting concerns (https://webkit.org/tracking-prevention/#table-of-contents-toggle:~:text=battery), I wonder if a slimmer version of the API can be thought of, mainly exposing very coarse yet useful information such as "are we currently in power saving mode" which can be used for meaningful optimizations. WDYT? |
FYI the |
Another use case to add to the list is that power saving mode greatly impacts the performance of a device. As such, it's useful information to know if the client is currently in power saving mode when you're collecting measurements from the Performance Timeline. |
Please see the related explainer by @chrishtr: https://github.com/chrishtr/battery-savings/blob/master/explainer.md, the proposal introduces "web page settings to save battery", which also entails detecting reduced framerate based on battery-savings settings. |
I'm wondering whether the recently announced Energy Saver mode in Chrome would warrant reinvigorating this work? I think https://crbug.com/1308741 is related. Battery/Energy Saver mode features are part of many OSes too. All - if there's still interest in this issue, please chime in with your latest use cases if possible and we take it from there. There's already a bunch of good use cases shared in this issue. Thanks to all contributors. Looping in @beaufortfrancois since he did some (not directly related) exploration in #52 recently. |
I coalesced the ideas shared in this issue into an explainer document with some additional background: https://github.com/w3c/battery/blob/gh-pages/energy-saver-mode-explainer.md Many thanks for your valuable feedback and suggestions. |
Thank you! That looks great! Not really familiar with the usual process, but what are the chances that will be approved and eventually made available to the Battery API? |
Thanks for your feedback, @YutaMoriJP. The changes are further increased when web developers like you share their exciting use cases, support, feedback and suggestions in this issue. Thank you for your continued contributions! 🤞 |
some nit pick, while reading this code example: let b = await navigator.getBattery();
if (b.energySaverMode) {
saveEnergy();
}
b.energysavermodechange = () => {
if (this.energySaverMode) saveEnergy();
} I could not help but thinking: Hmm is I don't know how i feel about the I like android / MacOS / iOS naming convention better.
It's a clear indication that it's a boolean. an alternative name could be also this code example: - b.energysavermodechange = () => {
+ battery.onenergysavermodechange = () => {
if (this.energySaverMode) saveEnergy();
} Originally posted by @jimmywarting in #56 (comment) |
@jimmywarting thanks for your feedback! Naming is hard and you provide great insights. All - please keep the feedback coming and one day you may see this API 🚀 |
At edi, we are building a no-code sustainable website builder. We would love to implement our low-mode feature for degradation of UI in a way that it is aware of this OS setting in addition to allowing a user to make their choice within the website. API that is being discussed in this thread would be very helpful for us in that matter! |
@sampittko, thanks for your support and use case! The ethical web principles that inform W3C's work include considerations for sustainability (https://www.w3.org/TR/ethical-web-principles/#sustainable) and your product is well positioned to provide concrete feedback on how to improve existing Web APIs and what new Web APIs should be defined. Any additional feedback welcome. |
Some mobiles and laptop (even without batteries) have a power saving mode where they tune down on unnecessary stuff to save battery or reduce power consumption on stationary computers
I think it could be useful to detect this so we can disable some unnecessary stuff on the website
The text was updated successfully, but these errors were encountered: