11 ms·
This was a terrible idea from the start. In the best case scenario, what is supposed to happen? The sites I visit suddenly start being served as shells of their
by zaroth 10y ago
This was a terrible idea from the start. In the best case scenario, what is supposed to happen? The sites I visit suddenly start being served as shells of their former selves in order to save the compute cost of rendering them? Web designers are supposed to figure out an entirely new design mode for the whole site to cater to visitors with low batteries?
Now back to the real world, where many sites I visit peg my desktop CPU trying to serve so many ads and so much tracking to squeeze every possible cent of profitability from my visit. If there's a war against ad-blockers, did we think these sites would relent and say, oh, OK, I see you might be low on battery, I'll serve just the content you want this time?!
No, this is a purely client-side concern, with plenty of purely client-side mitigation which can be put into place. That the protocol actually specified 14m degrees of granularity -- from what at the very least ought to have been a binary setting -- makes me wonder if the point wasn't user tracking all along.
Missing from the article: Do all user agents actually provide this information in request headers? Is there a way to shut it off?
- DougWebb 10y agoAs a web application developer, one idea that comes to mind is that, if I were writing an app that supports offline usage, I'd probably want to be aware of a low battery situation so that I can save my state and warn the user that the app needs to shut down to avoid data loss. I might also switch from online mode to offline mode, again letting the user know (and letting them override the choice, maybe.) I can't see any reason to make use of the battery status server-side. But, there's also no way to prevent the information from being sent, once you make it available to javascript code on the device. If the standard api didn't send it, then you'd just see ad-hoc apis gathering the data locally and sending it.
- DashRattlesnake 10y agoHowever, I don't think the battery state needs to be as granular as it is to support those use-cases. A simple boolean hasLowBattery or a much coarser 0%-25%-50%-75%-100% enumeration seems like it would have been sufficient.
- zaroth 10y agoIf anything, I would propose the mode should be a user-controlled bit called simply: "LOW" Maybe I request low mode because... I hope you serve me less crappy ads I haven't bought a new phone in 3 years I am running other apps which need more CPU I find too much interactivity distracting or confusing I just want to read black text on a white background I hate your website, but need to visit it for some reason anyway ... I have full battery, but I need to conserve it I have low battery EDIT: Fuck, I just realized, this already exists, and it's called NOSCRIPT. Wait, we could call this LOWSCRIPT!
- deleted 10y ago[deleted]
- vmateixeira 10y agoSo much truth in here... this proposal would be very welcome!
- bentruyman 10y agoGood luck defining "low". Also, coarse percentages of charge provide no indication of the amount of time left of a battery based on current activity. Which is something you would need in the above offline/save example.
- DougWebb 10y agoMaybe a boolean would work. I don't think 0%-25% would work for the scenario I described; 0% is too late to do anything about the low battery situation, and 25% is too soon to worry about it.
- joshkpeterson 10y agoSaid this in another comment, but - maybe an integer between 1 and 100 would be fine. Some granularity, but not enough to identify.
- vmateixeira 10y ago...warn the user that the app needs to shut down to avoid data loss.. Doesn't the client (laptop, phone, etc) does this already?
- DougWebb 10y agoI've seen my devices give notifications about the battery level to me, but I don't think they notify the apps I'm running, and if I ignore the notifications until the battery dies the device just shuts down. The apps have no chance to save their state. Often, that's probably just fine. But if I'm developing an app and I have a requirement to save state before my app gets shut down due to power failure, this api will allow me to do that. It's the equivalent to a drive flushing any writes before shutting down; normally they'd get flushed sooner or later, but if you have to shut down NOW, you'd better flush now too while you can.
- vmateixeira 10y agoI mean, but if the device notifies you that it's running low on battery... maybe you should close the app? Shouldn't this be enough? You would avoid loosing data, and regarding user experience, also avoid a slower performance of your app (and perhaps complaining about it?), and also seeing your device shutting down itself with your app screen running in background (which is pretty lame).
- DougWebb 10y agoAs a user, maybe that should be enough. Maybe not. It depends on the app and how critical the data/state is, I guess. As a developer, trying to implement requirements set by a product designer/owner who thinks saving the data is critical even if the user doesn't cooperate, the api is useful to have.
- vmateixeira 10y agoMaybe a critical app shouldn't be web based? If you're really worried about your battery running low and working with critical data, removing the browser overhead which is draining you battery should be one of the first things to do.
- aeorgnoieang 10y ago> But, there's also no way to prevent the information from being sent, once you make it available to javascript code on the device. Surely it's possible for JavaScript engines to either (a) optionally prevent code from accessing this; or (b) return random nonsense, or even just a single fixed static value (for every instance of the engine anywhere).
- DougWebb 10y agoNope; either the information is not available to Javascript code at all, or the Javascript code can do whatever it wants with the info. A security permission, or config setting, can/should be used to prevent access to the api that returns the battery level. But once access is enabled, there's no way to prevent the code from getting the level (which is just a number) and sending it to a server (which is just calling an ajax request with a numeric argument.)
- Mister_Snuggles 10y agoI would think that if you architect your app to handle disappearing network connections gracefully, it will probably handle the user shutting down the phone gracefully too. If the battery is critically low, the user will get popups from the operating system at various points and can make a decision whether or not to keep using your application. You could also expose an offline-only option somewhere in your application. A user might want to do this if they are in an area with marginal coverage (e.g., there is a connection, but it's basically useless) or roaming, etc.
- DougWebb 10y agoA disappearing network connection is a different case, because the app continues running. Imminent power failure is different because the app is about to be terminated, probably not gracefully. This is also different from the user shutting down the app manually, because that's probably a graceful shutdown which will give you a chance to save some state before termination.
- mikeash 10y agoThe user can close your page at any moment, so you need to design your web app to save data continuously and automatically anyway.
- brlewis 10y agoE.g. weather app that automatically fetches new weather data periodically, but stops when battery is low. That said, you're right that the only data you need for such purposes is binary. The current API provides too much info.
- zaroth 10y agoIf it's a native app, then it can already do this. If it's a web app, then hopefully it's only fetching updates if the tab is visible, right? I absolutely think web apps should be checking if their tab is foreground and behaving differently based on that.
- brlewis 10y agoWhat if I want a notification that rain is coming? https://developer.mozilla.org/en-US/docs/Web/API/Notifications_API/Using_the_Notifications_API#Browser_compatibility https://developer.mozilla.org/en-US/docs/Web/API/Notificatio...
- zaroth 10y agoSo what you're saying is that on top of having to deal with low battery, now you're also getting caught in the rain? :-) Don't tell Steve, but if I want to save battery, I swipe closed the browser. If I sign up for rain notifications, I better get my darn rain notification!
- brlewis 10y agoNo, I'm not talking about low battery. You suggested that the app stop checking for weather updates when its tab is not in the foreground. If I do that then I get caught in the rain even with a full battery.
- x1798DE 10y agoHopefully browser tabs don't have any way of triggering system notifications, in which case how would it matter if a webapp stopped automatically updating when the window loses focus?
- andybak 10y ago> Web designers are supposed to figure out an entirely new design mode for the whole site to cater to visitors with low batteries? You're constructing an obvious straw-man here. It's easy to imagine scenarios where a 'low power mode' would be in the interest of the site and it's visitors. Especially when we're talking 'apps' rather than 'content sites' - there's plenty of desirable but non-essential functionality that could be disabled and for web apps intended for mobile use this could potentially be a great differentiator.
- majewsky 10y agoThe most obvious thing is animations. Android has a powersave mode where all animations are disabled. (It's a bit unsettling, actually, but really helps with conserving the few remaining electrons.)
- m_eiman 10y agoSounds like something for the browser to handle automatically, without the site's javascript ever knowing about it.
- andybak 10y agoHow does a browser distinguish between essential and non-essential animations? (If your answer is 'there are no non-essential animations' then you haven't thought about it for long enough)
- nommm-nommm 10y agoWhat's an example of an essential animation?
- zaroth 10y agoI think it's way past the point of diminishing returns, but the answer to your question is: with more markup.
- zaroth 10y ago
- dspillett 10y ago> In the best case scenario, what is supposed to happen? I assume it is intended for mobile apps written in-browser that are intended to run in some sort of kiosk mode so obscure the OS's default battery display.
- drzaiusapelord 10y ago>This was a terrible idea from the start. In the best case scenario, what is supposed to happen? I see two scenarios here: 1. The usual cock-up of the API guys not being the privacy/security guys and managers being unable to find common ground between the two. 2. The pressure to make HTML5 be an "app killer" and making sure devs have everything they need to write HTML5 web apps that can compete with native apps. Security/privacy becomes a browser problem, and if the browser guys screw up (see 1.) then too bad. Seems to me, a simple middle ground of reporting a less granular battery value would have made sense. Very Low, Low, Medium, High, Very High would probably take care of it. You can probably just shoe-horn this in right now by just assigning a number to each condition and never telling websites the real number (or randomizing it a bit).