4 ms·
I guess the way I think of it... if I am visiting a site or web app, I am actively opting to expend the energy required to render the page. Obviously if the pag
by zaroth 10y ago
I guess the way I think of it... if I am visiting a site or web app, I am actively opting to expend the energy required to render the page. Obviously if the page is not visible, and not doing a background task like playing audio, then I expect its CPU consumption to be negligible. So, first and foremost, use the page visibility API.
If I'm low on battery and choose to open that webpage, and now the WebGL charts are static bitmaps, my first reaction is going to be WTF. Now I want a button synonymous with 'Show Desktop Site' -- I guess we could label it the 'Stop Fucking With Me' button.
All code should be aware of the CPU that it is consuming. More efficient code is not just better for battery, but also likely more responsive and better for multitasking. So the question becomes, not how do we reduce CPU and possibly even improve UX, but in what cases would we make the CPU requirement dynamic, and when/where might the trade-offs be made to ultimately improve the user experience.
So first is Page Visibility, as discussed. The very next area where I would consider making CPU usage dynamic is not a battery state, but rather it's an overall device performance adjustment. If someone visits with an iPhone 4 versus a 6s, they have dramatically different amounts of compute available. I would consider investing in dynamic CPU consumption based on a device performance flag a lot sooner than I would do it based on remaining charge, because I think it would improve the UX for a large percentage of users every time they used the site. It's also a static setting from the perspective of the device owner, so they are not seeing changing UX on their device potentially from one moment to the next.
> None of the above need to significantly increase development or testing costs.
I can only offer my opinion based on my experience, but trying to alter functionality to reduce CPU load based on dynamically changing battery metrics across a pool of devices which may behave inconsistently... this is really not simple to code and test and maintain over time. We have a hard enough time just trying to efficiently serve device-specific assets (like lower res images to mobile) and that's based on a static/fixed user-agent string, not a dynamic header, and sites get it wrong so often that user-agents added a special button to try to turn it off!
- josho 10y agoI agree with your sentiment. However, I also appreciate the web maturing and giving developers similar API abilities as a native app. The API may not have a use for you, but surely across the global audience of web apps there will be more than a few valid use cases.
- zaroth 10y agoThis is a great point, and I too tend to think in terms of the Web API having parity with native can only be a Good Thing. The problem is the web is not a very nice place, and (like the ad networks mentioned by the OP) third parties beyond my control often get to run fully-scoped Javascript on my browser. OTOH, at least I get to choose which apps are installed on my home screen. So I wonder if instead of all the prompts we have today; Would you like to allow this page to see your location? Would you like to allow this page to use your microphone? Would you like to allow this page to use your camera? Would you like to allow this page to send notifications? Would you like to allow this page to view your battery status? We need something more holistic. I joked above about NoScript vs. LowScript. I was chuckling to myself imagining a 3-way toggle -- NoScript, LowScript, and YoScript. There certainly could be use cases for having a comprehensive Web API for charging status, battery capacity, remaining charge, and time till charged. Someone will find this useful. But simply adding it and having it on-by-default is not without tradeoffs... As Web API matures, there is a plethora of APIs which have privacy concerns, some slight, some grave. We need to communicate to users these trade-offs in some usable way, and give them some control over them. Some APIs definitely need their own unique Yes/No prompt, like turning on my camera/mic, but I wonder if there's a middle-ground of a group of APIs which should be restricted all behind a single setting, akin to favoriting or 'staring' the site gives just that first-party domain access to those APIs. Maybe we even call it "Native Mode", then we put choice back in the hands of the user and we can expose APIs with impunity.