170 points · by randomname2 · 10y ago · 98 comments
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?
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.
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!Doesn't the client (laptop, phone, etc) does this already?
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.
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).
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.)
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.
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.
Again, there's a litany of things a device can do to reduce power usage itself. Native apps and websites alike should absolutely consider their power profile and reduce it if possible.
The idea which I think is terrible is making this part of unrestricted Web API as 14m possible states. But even as a binary state I think very few apps have the resources to design, develop, and test across multiple devices for dynamically adjusting power consumption.
1. Simple example - any app that does polling for any reason can reduce the polling interval.
2. Interactive WebGL charts could be replaced with static bitmaps
3. Background spell or syntax checking could be disabled and made 'on demand'
4. Chatty network features could be disabled or cut back.
None of the above need to significantly increase development or testing costs. They are quick examples I pulled out of thin air. If we discussed specific applications I'm sure I could suggest more.
Non-browser apps already can do all this and often do. (and I wish they would do it more often)
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.
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).
The benefit is that the user doesn't need an additional setting for each potential web app to set the threshold for a low power mode, it's all done once at the OS level.
It is is similar in any other case of low resources. There probably is not much of a difference for a website if user is low in power than if it is low in memory. There should be then just one flag/event really: low resources (catch-all for battery, memory, CPU time, storage etc.).
I searched Chrome settings for "battery" and found nothing. I did find this article with instructions for turning it off in Firefox: https://www.hackread.com/smartphone-laptop-battery-invading-...
I'm not opposed to the concept of a battery API, but as others have commented, it would be just as useful with a lot less granularity.
I hope some day soon your mobile OS let's you choose to restrict the device information available to sites and apps. It really ought to be a user's choice whether to make the tradeoff between providing more info in exchange for supposedly better functionality or not.
Plus ad blocking and "social button" blocking, as a preventive measure for this kind of issue.
The Web is the new Wild West.
You might argue that this sort of stuff should only be available to native applications, that browsers should not attempt to replace native apps or even recreate an OS within themselves (something Chrome is often criticized for). The thing is, my battery monitor has native apps and yet users have been asking for web-based clients, be it browser extensions or plain web pages. And with some platforms loading a website or installing an extension has much less friction than installing a native app.
Sure, extensions can have access to a lot of stuff webpages don't have. But I would rather use standardized APIs that work across all browsers and are well documented in more than one website, than have to rewrite my extension for each browser and not have it work on plain old pages.
If the battery API was made to work like the location one I think everyone would be happy - users are informed and in control, developers can still offer features based on it, and it raises red flags when it needs to ("why is this advert asking about my battery status?").
navigator.getBattery().then(function(a) {console.log(a);})
https://developer.mozilla.org/en/docs/Web/API/Battery_Status...> “Some companies may be analysing the possibility of monetising the access to battery levels,” he writes. “When battery is running low, people might be prone to some – otherwise different – decisions. In such circumstances, users will agree to pay more for a service.”
This lets sites who want to do "real things" with battery levels have access, without it being available "for free" (prompt is annoying).
My guess is this is just another part of the attempt to move desktop features to the web browsers so that people don't have to write actual applications. Personally, I don't like this trend.
Web applications served over HTTP, on the other hand...
Mozilla have it as part of their mission to make technology open and accessible (insert DRM debate here). Native apps have been thrown behind the app store “walled garden.” So, they want to make it possible to create rich apps over HTTP.
Thus, you find things like this available to web pages.
Here's my result:
Your browser fingerprint appears to be unique among the 119,205 tested so far.
Privacy is great...
Why should we allow companies recording other features that can identify us?
(btw, I don't think this should be a technical debate)