News for hackers. Stuff that matters.
Re:Firefox 70 by jacurtis on Tuesday October 22, 2019 @12:13PM (#21325380)
> this means that my battery is going to last 4-5x longer with Safari

Well it might last 4-5x longer if you run safari in the background, since that is what you tested. But wouldn't the real test be running both browsers as the active window and comparing those results?

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. This is really good when running on battery because it is a shame to dedicate resources to things that aren't even visible on screen. But this could make the results far more dramatic through your test.

I would hypothesize that Safari still wins your performance test (if you were to re-test using them both as "active" windows), but probably not as dramatically as in the inactive window test.

Re:Firefox 70 by freediver on Tuesday October 22, 2019 @12:26PM (#21325544)
I used that use case because I usually have multiple windows with multiple tabs in the background.

I measured it with active windows now.

Screenshots:

- Both in background

- Safari Actie

- Firefox Active

https://imgur.com/a/4L64ShP

Conclusion: it gets even worse for Firefox.

Edit: At the time of test Safari had 7 more windows open with probably 70+ tabs from my previous session that I didn't close.

Re:Firefox 70 by devit on Wednesday October 23, 2019 @10:37AM (#21335038)
You are not running uBlock Origin, so ads might be taking up all the CPU cycles they can get their hands on.
Re:Firefox 70 by tomaskafka on Tuesday October 22, 2019 @01:52PM (#21326651)
> 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...)

Re:Firefox 70 by freddie_mercury on Tuesday October 22, 2019 @10:54PM (#21330626)
Classic 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."

Re:Firefox 70 by theonemind on Wednesday October 23, 2019 @12:22AM (#21331011)
Perhaps 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.

Re:Firefox 70 by icebraining on Wednesday October 23, 2019 @04:24AM (#21332442)
Of 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_Visibi...

Re:Firefox 70 by paulintrognon on Wednesday October 23, 2019 @09:23AM (#21334341)
Reminds 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...

Re:Firefox 70 by littlestymaar on Wednesday October 23, 2019 @03:22AM (#21332011)
> 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.

Re:Firefox 70 by squiggleblaz on Wednesday October 23, 2019 @08:28AM (#21333847)
"- 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.

Re:Firefox 70 by littlestymaar on Wednesday October 23, 2019 @11:24AM (#21335566)
Pretty surprising. I don't use Google maps though, but it works fine with all the websites I go daily.
Re:Firefox 70 by pmontra on Tuesday October 22, 2019 @02:11PM (#21326862)
YouTube 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.
Re:Firefox 70 by GrayShade on Tuesday October 22, 2019 @04:12PM (#21328064)
Firefox does stop rendering videos in background tabs (or used to, at least). You can see it take a couple of frames to restart.
Re:Firefox 70 by dwaite on Tuesday October 22, 2019 @03:00PM (#21327331)
The 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
Re:Firefox 70 by roca on Tuesday October 22, 2019 @08:50PM (#21330012)
Youtube 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.
Re:Firefox 70 by dwaite on Wednesday October 23, 2019 @05:29AM (#21332826)
Yes, and this is likely why Youtube now periodically pauses in the background on current macOS/Safari.
Re:Firefox 70 by ripdog on Tuesday October 22, 2019 @11:45PM (#21330867)
My 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.

Re:Firefox 70 by tass on Tuesday October 22, 2019 @07:25PM (#21329506)
Does 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?

Re:Firefox 70 by vrodic on Tuesday October 22, 2019 @10:48PM (#21330596)
Chrome 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.
Re:Firefox 70 by tass on Tuesday October 22, 2019 @11:24PM (#21330762)
That 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.

Re:Firefox 70 by baby on Tuesday October 22, 2019 @06:33PM (#21329132)
What about a timer running in a different tab?
Re:Firefox 70 by mrob on Tuesday October 22, 2019 @08:58PM (#21330048)
How can the browser distinguish between useful background Javascript (e.g. web based chat) and harmful background Javascript (e.g. advertising)?
Re:Firefox 70 by vrodic on Tuesday October 22, 2019 @10:46PM (#21330589)
It might not be perfect, but allowing only web workers (if you agree on getting push notifications from a page) might be the solution.
Re:Firefox 70 by ebg13 on Tuesday October 22, 2019 @12:32PM (#21325614)
> But wouldn't the real test be running both browsers as the active window and comparing those results?

No matter what you're doing, all but one of your tabs will be in the background at any given moment.

Re:Firefox 70 by jdironman on Tuesday October 22, 2019 @07:19PM (#21329460)
What about 4 windows, 2 for safari, 2 for FF in windowed mode? But I guess only window can be active at a time.
Re:Firefox 70 by HunOL on Wednesday October 23, 2019 @03:18AM (#21331987)
> 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. This is really good when running on battery because it is a shame to dedicate resources to things that aren't even visible on screen. But this could make the results far more dramatic through your test.

Does it mean that page in background isn't updated in Safari?