5 ms·
> One thing that Safari is incredibly good at (and its' engineers are proud of) is the ability to reduce resource consumption for non-active tabs and windows to
by tomaskafka 7y ago
> One thing that Safari is incredibly good at (and its' engineers are proud of) is the ability to reduce resource consumption for non-active tabs and windows to nearly zero.
I understand this is rare, but I just have a very very hard time understanding what is so hard about this.
Page not visible? Just stop it. Stop the layout engine, stop the javascript VM. If there was a transfer in progress, let it finish, a page might get the callback when it's active again ...
(I know there are some tricky cases, a lot of them, but there just isn't any reason why a browser with 30 tabs should be consuming over 1 % cpu...)
- pmontra 7y agoYouTube music video running in another tab. Should it stop render the video and keep playing the audio? Maybe feasible but it should keep receiving both the video and audio data. Stop all of it? Not what I wish to happen.
- dwaite 7y agoThe javascript engine and rendering engines are what are generally affected by being backgrounded. So yes, generally the media library will continue receiving the combined video/audio stream and not bother rendering the video frames
- baby 7y agoWhat about a timer running in a different tab?
- tass 7y agoDoes HTML video need to catch up based on the most recent keyframe? If they don't render while backgrounded, how do they do that without being noticeable?
- vrodic 7y agoChrome does this for a long time now and I don't consider it an issue. You see a frozen version of the last decoded keyframe until the next one is decoded. Elegant solution IMO.
- tass 7y agoThat makes sense, it seems I haven’t looked closely enough to notice. I couldn’t find info on how often a keyframe is expected from YouTube, but I’m recalling the bad old divx days where you sometimes had a frame per scene and skipping was very slow.
- roca 7y agoYoutube uses the Media Source Extensions API, which means that JS is responsible for fetching compressed video data and feeding it into the decoder, so it can implement adaptive streaming. Pause JS for more than a few seconds and the video will stop playing.
- dwaite 7y agoYes, and this is likely why Youtube now periodically pauses in the background on current macOS/Safari.
- ripdog 7y agoMy understanding is that most video websites like Youtube use Media Source Extensions, a standard which allows javascript to download and assemble video streams in non-standard ways. This work is done by page JS and passed to the browser to decode and render. AFAIK youtube uses this to implement DASH streaming. Presumably there is no easy way to disable page JS but keep your youtube video downloading.
- GrayShade 7y agoFirefox does stop rendering videos in background tabs (or used to, at least). You can see it take a couple of frames to restart.
- mrob 7y agoHow can the browser distinguish between useful background Javascript (e.g. web based chat) and harmful background Javascript (e.g. advertising)?
- vrodic 7y agoIt might not be perfect, but allowing only web workers (if you agree on getting push notifications from a page) might be the solution.
- freddie_mercury 7y agoClassic HackerNews " This is so easy and I, a software developer with no actual experience in that area, know the obvious solution that eludes that hundreds of developers with actual experience in the area. Meanwhile, I take umbrage when my product manager tells me that implementing the next feature will be easy and I'm exaggerating how complicated it is."
- theonemind 7y agoPerhaps so. But, if (not_visible) { suspend_wait_and_stop_consuming_resources } I can imagine that it gets massively more complicated. However, as, say, an executive, this probably indicates that you can lean on your sw dev staff to approach the asymptotic ideal that looks so simple if you really care about the goal.
- icebraining 7y agoOf course, and all major browsers have background tab throttling features[1]. But there are multiple goals and limited dev time. [1] E.g. Firefox added some in version 58: https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API#Policies_in_place_to_aid_background_page_performance https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibi...
- paulintrognon 7y agoReminds me an old boss I had who, when I reported a complicated problem, always came up with: "why don't you just write if (problem) { solution(); } ? Should'nt take long, should it? Well, the difficult part is not writing an if statement...
- littlestymaar 7y ago> Page not visible? Just stop it. Stop the layout engine, stop the javascript VM. If there was a transfer in progress, let it finish, a page might get the callback when it's active again Contrats, you just broke the web for anyone doing one of the following: - listening to music in the browser. - having a webRTC chat with someone while browsing. - keep reading another tab while waiting for a page to load. And I'm probably missing a dozen of other totally legit use-cases.
- squiggleblaz 7y ago"- keep reading another tab while waiting for a page to load." Oh tell me about it. That's just about dead now. I mean, wasn't the point of multi tab browsing that I could do precisely that? Now I load Google Maps on my lethargic internet connection, go do something else for ten minutes, and come back and ... it starts loading when I open. This is on Firefox. Super sad.
- littlestymaar 7y agoPretty surprising. I don't use Google maps though, but it works fine with all the websites I go daily.