10 ms·
How Web Content Can Affect Power Usage
- akersten 7y agoJust some tangential food for thought: A few years ago Google did an Earth Day stunt where they set their homepage background color to black to symbolize saving energy by remembering to turn out the lights. It was tongue-in-cheek, but I've been curious ever since if major websites making a conscientious change to reduce JS execution and transfer bandwidth would have a measurable impact on worldwide power consumption. Kind of branches out to more questions like: how much energy is wasted running poorly optimized code (on the web and otherwise) where the same outcomes could be accomplished with code that executes fewer instructions? Should developers have an obligation or at least a conscience about writing performant code for the environment's sake? Would the impact even be measurable?
- ryacko 7y agoA tablet costs less than $10 in electricity per year. The energy to mine, refine, and assemble the materials for a tablet is much higher. The mindfulness in everyone trying to be more efficient would have a positive impact on its own though.
- Scoundreller 7y agoWhen we move to full OLED, ubiquitous night mode will drive down their device's power usage.
- latexr 7y agoThe most common reason for my computer fans to become audible is JavaScript on a webpage. That is insane, because in most cases it makes no difference to the content. Mind you, this is on Chrome on a Macbook Pro; Safari is indeed better (kudos to the Webkit team). It’s a shame the amount of control Safari gives a user is laughable: content blockers can’t hold a candle to uBlock Origin and there’s no way to disable JavaScript and Cookies on a per-site basis.
- nottorp 7y agoI don't bother disabling js per site so I don't know about that, but I'm pretty sure there is an uBlock Origin build for Safari since I'm using it. https://github.com/el1t/uBlock-Safari https://github.com/el1t/uBlock-Safari
- lorenzhs 7y agoThat isn't maintained any more, the last commit was more than a year ago. It's stuck at version 1.16.
- bonyt 7y agoThere is a search engine (that gets results from Google) with a black background that claims to reduce energy usage on monitors. https://en.wikipedia.org/wiki/Blackle https://en.wikipedia.org/wiki/Blackle
- tobr 7y agoThat doesn’t make sense at all for most types of screens. If anything, I wonder if a darker design might make visitors increase their screen brightness to compensate.
- The_rationalist 7y agoWhy wouldn't is apply to OLED? OLED pixels shut down for black so consume 0 watts theoretically. And OLED is becoming the standard for smartphones which represents the majority of web traffic.
- amiga-workbench 7y agoThis site is really old, back when it was new, CRT's were still very common.
- spartanatreyu 7y agoIt actually uses more energy for most people's display devices to show black. It's because the screens are back-lit and it costs energy to block out the light rather than let it pass through. Blackle was only really useful when CRT screens were around. It could be useful on OLEDs which are not back-lit but they have shorter life spans due to burn-in.
- bla3 7y agoIt depends on the display technology. OLED screens need less power to show black than white. Backlight LCD screen need more power to show black.
- jakub_g 7y agoRe: JavaScript and networking: My random observation tells that sadly most "modern" highly complex websites do it wrong and it can hardly be any worse (this applies to all web products I've been working on for last several years): 1) analytics beacons fired every N seconds (which means the network stack on mobile never goes to idle mode) 2) JS frameworks doing event delegation that capture mousemove events and various other stuff like that + various setTimeout/setInterval (perhaps from third-party code). If you want a sample of 2) just open devtools > debugger on any page and click "pause". You will immediately hit a debugger in some just-now executing JS callback even if you do nothing at all on the page.
- forgotmypw 7y agoThis is why I browse no-JS, except for a few select sites.
- RussianCow 7y agoI tried this for a bit on mobile, but unfortunately it just breaks too much of the internet to be feasible. YMMV, and to each their own, but I'm not willing to sacrifice that much usability when an adblocker covers most use cases.
- snek 7y agoI wonder how much energy would be saved if people stopped using recaptcha v3, which is basically a perfect storm of event handlers and network usage.
- dzhiurgis 7y agoSays company who refuses to implement VP9 (because other company doesn't want to spend on x264 licenses). Result is power waste on the order of small country. p.s. glad Safari finally shows offending Safari tab name in Activity Monitor (lately it's Twitters service worker that rip 100% CPU).
- zerocrates 7y agoI suppose it would be H.265 licenses, not 264, which is quite widely deployed.
- zenexer 7y agoApple is a patent licensor for both and therefore has monetary incentive to discourage free alternatives for either.
- forgotmypw 7y agoThis is why I don't use Twitter much anymore, nor Instagram, nor FB, etc. If a human being pulled this kind of shit on me, I would have reduced my contact with them to a minimum a long time ago, since it would essentially be an abusive or at least one-sided relationship (that might have been great in the past.) So why should it be any different for a website or service?
- martinald 7y agoSure it's not the other way round? Nearly everything has hardware h264 decoding. Google forces VP9 via YouTube which doesn't have hardware decoding on many (most?) devices so massive CPU usage (and virtually impossible to watch in 4K/60fps in software decode mode).
- nwallin 7y agoNo. Virtually all devices since 2015 have hardware accelerated vp9 decoding. iPhones have had it going back to the iPhone 6. Apple is refusing to enable it in software because... TBH I don't know why. It's royalty free. I literally can't think of a reason besides juvenile pettiness.
- judah 7y agoPower saving is great, except when it breaks apps. Unfortunately, Webkit has broken certain web apps by their power saving features. For example, on iOS, I have a Pandora-like web app that plays music. When my app is in the background and the current song ends, it won't play the next song because iOS has suspended Javascript execution in the name of power saving. I'm not doing any active JS, just an event handler for audio.ended event. The event handler never fires when my app is the in background or when the screen is off, thus, I can't play the next song. This effectively makes it impossible to build a functioning audio app/radio station on iOS using web technologies. I've reported this issue to Apple some 2 years ago, but they still haven't fixed it. Bonus: as of iOS 12, it also breaks web apps that are packaged with Cordova and published into the App Store.
- inetknght 7y ago> Power saving is great, except when it breaks apps. That's a problem. > Pandora-like web app that plays music. When my app is in the background and the current song ends, it won't play the next song because iOS has suspended Javascript execution in the name of power saving. I think that's intended. I would argue that you are misusing the web. I would argue that most users don't want websites to run while the browser isn't in the foreground. If you want to elevate your capability to interact with the user while in the background then build and install a native app or leverage existing native apps' functionalities. > When my app is in the background and the current song ends, it won't play the next song because iOS has suspended Javascript execution in the name of power saving. The event handler never fires when my app is the in background or when the screen is off, thus, I can't play the next song. That's good. I don't want garbage in the background to do anything javascript-related at all. > This effectively makes it impossible to build a functioning audio app/radio station on iOS using web technologies. Really? There are plenty of audio/radio apps on iOS using native technologies. You're trying to shoehorn something to do something it wasn't intended and then causing noise because it doesn't do what it wasn't intended. > I've reported this issue to Apple some 2 years ago, but they still haven't fixed it. What bug? You think this is a problem caused by power saving? No, it's not. You've already stated that the song is playing until it ends, but that your javascript doesn't get notified that it ended. You think the problem is that power saving is stopping you from processing the next song to play. I disagree. I think the problem is that you aren't providing a play list to the browser. Frankly, I'm not a web developer so I don't even know if there is a playlist API. But if there isn't, then that is your problem. A playlist would be a hell of a lot cheaper than trying to run arbitrary javascript.
- deedubaya 7y agoI wonder what the Internet's net power consumption is for server side vs client side HTML rendering.
- vdnkh 7y ago> Avoid network polling to obtain periodic updates from a server. Use WebSockets or Fetch with a persistent connection, instead of polling. Oh the irony. Apple’s new low-latency streaming spec is based around polling the server multiple times per second, for the entire duration of a live stream. The FOSS version of low-latency HTTP streaming is based on chunked-transfer encoding via a...persistent fetch connection. Despite chunked-transfer low-latency steaming being widely deployed in production for the past few years (Twitch, Periscope use this), they didn’t think it was the right solution. I wonder what the WebKit team thinks of this.
- deleted 7y ago[deleted]
- jakeogh 7y agothread on email @ https://news.ycombinator.com/item?id=20800439 https://news.ycombinator.com/item?id=20800439
- akling 7y agoHaving worked on WebKit performance in the past, it's great to see more of this knowledge being pushed out to web developers. These are things browser developers have known about for a long time, but we generally always tried to "just make things work" in the browser instead of asking web developers to help out on their end (and making tools to assist with that.) Great post by Benjamin and Simon :)
- TekMol 7y agoAs a first step, browsers should make extensions more powerful again. It's a pain that extensions are so teethless these days. Then we could make a powersaving extension. It would allow a page a cumulative number of ms to use the CPU/GPU and a max number of network requests. After that it would display "This page has exceeded its quota of resources. Should all JS be halted? You can always continue the JS by clicking the little PowerSaver icon". Here is a fun way to tame power intensive tabs (tried it with Firefox and Chromium and it works for both): top Look at the ID of the most busy tab. Let's say it's 1234 kill -STOP 1234 Boom! Immediately the tab is frozen and it's CPU usage drops to zero. kill -CONT 1234 Now it is alive again. To pause all tabs: pkill --signal STOP firefox And to continue: pkill --signal CONT firefox For Chromium, just use "chromium" instead of "firefox". So if we had something like native extensions, we could achieve a "pause button" by simply leveraging the STOP and CONT signal of the OS. If one were to look deeper into how browsers do their work, I wouldn't be surprised if we could target the signals more precisely and keep scrolling alive during the pause. Or we could CONT the process in case of a scroll event and then immediately STOP it again. Another approach could be a "BrowserTamer" application that keeps the browser STOPped as long as there is no mouse/keyboard activity and CONT it for 100ms on scroll/keyboard activity. That could probably be implemented as a seperate program without help from the browsers themselfes.
- de_watcher 7y agoThat's how Ubuntu Phone works for all apps.
- Razengan 7y ago> As a first step, browsers should make extensions more powerful again. That is a solution (though more like a remedy) to the symptom instead of the actual problem: Browsers trying to become operating systems and websites trying to be apps.
- TekMol 7y agoThe browser is a platform that runs applications aka websites. Nothing wrong with that. But I want that the user can configure the platform any way they like. If you look at Linux, it's a bunch of files that you can alter until it behaves exactly the way you want it to. Browsers feel much more monolithic. I would prefer them to be as open and accessible as Linux.
- netheril96 7y agoThe biggest question now is how to incentivize developers to care about battery efficiency. Currently if your website is energy saving, the users cannot feel anything. Why bother spending time optimizing then? Some kind of indicator of how much energy the current tab is consuming would be nice.
- mirimir 7y agoOK, so TFA is for web developers. But it's still funny that it doesn't mention ads. Especially ads that run video. Reducing power usage is an important befit of using ad-blockers.