Live data from Hacker News

Engineering code quality in Firefox

hacks.mozilla.org

11–20 of 155 posts

Re: Engineering code quality in Firefox

#11
post #4

I was thinking about Firefox development quality while trying to figure out why the f does Firefox CPU usage fluctuate between 1 and 5% with one background tab open and only one plugin installed (containers). The same URL when opened in safari goes to 0.1% or 0.0. I tried to look up dom timeout config settings and tried to set aggressive timeouts, but in the end I gave up. There must be something fundamentally wrong…

Chrome has the same issue. The thing is, Safari is deeply connected to OS X and its internals to save as much energy as possible. Apple can do this and tie the code to the specific hardware, kernel, and what else matters that Safari runs on as they control everything. Chrome and Firefox cannot. I would not be surprised if someone tells me that parts of Safari hook into private APIs in the kernel, the graphics driver…

Doesn't Safari also lag in implementing new or battery-hungry features? I suspect that could be a big factor too.

Re: Engineering code quality in Firefox

#12
post #4

I was thinking about Firefox development quality while trying to figure out why the f does Firefox CPU usage fluctuate between 1 and 5% with one background tab open and only one plugin installed (containers). The same URL when opened in safari goes to 0.1% or 0.0. I tried to look up dom timeout config settings and tried to set aggressive timeouts, but in the end I gave up. There must be something fundamentally wrong…

the f does Firefox ... same URL when opened in safari

It would be interesting to compare the safari budget/manpower. Even given that, I would imagine safari only has to support one-ish OS, and probably has help from the OS group.

Re: Engineering code quality in Firefox

#13
post #4

I was thinking about Firefox development quality while trying to figure out why the f does Firefox CPU usage fluctuate between 1 and 5% with one background tab open and only one plugin installed (containers). The same URL when opened in safari goes to 0.1% or 0.0. I tried to look up dom timeout config settings and tried to set aggressive timeouts, but in the end I gave up. There must be something fundamentally wrong…

Besides the devtools profiler, which may not capture everything there's a whole-application profiler for firefox, that might provide some insight: https://profiler.firefox.com/ But try the devtools one first, it's easier to use.

Re: Engineering code quality in Firefox

#14
post #9

> Our next major challenge: We are dealing with 21 million lines of code. I think I just fail to understand the true complexity of a browser, but how is Firefox 21 million lines of code? How can a browser be 21 million lines of code? That just seems so large for what a browser does.

I think you’re underestimating what browsers do. They have an incredibly performant and highly-tuned VM, an extremely flexible and powerful layout engine, a comprehensive set of media players, and that’s not even talking about networking, security, and UI.

This seems to scream "separate me!". Why is it acceptable to put all this responsibility into one giant ugly ball? We desperately need separate layout engines, parsers, renderers, etc. Assemble-your-own-browser.

Re: Engineering code quality in Firefox

#15

> Our next major challenge: We are dealing with 21 million lines of code. I think I just fail to understand the true complexity of a browser, but how is Firefox 21 million lines of code? How can a browser be 21 million lines of code? That just seems so large for what a browser does.

What doesn't a browser do these days.

Email! For now ;) http://catb.org/jargon/html/Z/Zawinskis-Law.html

Re: Engineering code quality in Firefox

#16
post #4

I was thinking about Firefox development quality while trying to figure out why the f does Firefox CPU usage fluctuate between 1 and 5% with one background tab open and only one plugin installed (containers). The same URL when opened in safari goes to 0.1% or 0.0. I tried to look up dom timeout config settings and tried to set aggressive timeouts, but in the end I gave up. There must be something fundamentally wrong…

Chrome has the same issue. The thing is, Safari is deeply connected to OS X and its internals to save as much energy as possible. Apple can do this and tie the code to the specific hardware, kernel, and what else matters that Safari runs on as they control everything. Chrome and Firefox cannot. I would not be surprised if someone tells me that parts of Safari hook into private APIs in the kernel, the graphics driver…

The rendering engine is open source. You’re welcome to audit it here: https://webkit.org/getting-the-code/

Re: Engineering code quality in Firefox

#17

> Our next major challenge: We are dealing with 21 million lines of code. I think I just fail to understand the true complexity of a browser, but how is Firefox 21 million lines of code? How can a browser be 21 million lines of code? That just seems so large for what a browser does.

A browser lays out text and graphics (for any script in any locale), does GPU accelerated 3D rendering, handles network communication, plays video, plays audio, provides accessibility, parses a bunch of languages, compiles a couple of languages to machine code run in a security sandbox (and has a separate optimizing compiler), provides database storage, implements a plugin system, provides support for 25 years of legacy standards. And a bunch of more things.

Re: Engineering code quality in Firefox

#18
post #12
post #4

I was thinking about Firefox development quality while trying to figure out why the f does Firefox CPU usage fluctuate between 1 and 5% with one background tab open and only one plugin installed (containers). The same URL when opened in safari goes to 0.1% or 0.0. I tried to look up dom timeout config settings and tried to set aggressive timeouts, but in the end I gave up. There must be something fundamentally wrong…

the f does Firefox ... same URL when opened in safari It would be interesting to compare the safari budget/manpower. Even given that, I would imagine safari only has to support one-ish OS, and probably has help from the OS group.

The WebKit team is smaller than the corresponding team at Mozilla, even if you look at the subset of of identical roles across both organizations (and e.g. ignore those working on the Firefox network stack).

That said, it's worthwhile remembering that WebKit does very much maintain all the abstractions to be cross-platform (and Apple do still maintain a Windows port), even if it does try and leverage plenty of OS libraries in a way neither Firefox nor Chrome do.

Re: Engineering code quality in Firefox

#19
post #15

Earlier quoted context omitted.

What doesn't a browser do these days.

Email! For now ;) http://catb.org/jargon/html/Z/Zawinskis-Law.html

remember Opera and Seamonkey (and Lotus Notes) back when the all-in-one email/browser/cal/notes application concept was still kicking

Re: Engineering code quality in Firefox

#20
post #4

I was thinking about Firefox development quality while trying to figure out why the f does Firefox CPU usage fluctuate between 1 and 5% with one background tab open and only one plugin installed (containers). The same URL when opened in safari goes to 0.1% or 0.0. I tried to look up dom timeout config settings and tried to set aggressive timeouts, but in the end I gave up. There must be something fundamentally wrong…

Chrome has the same issue. The thing is, Safari is deeply connected to OS X and its internals to save as much energy as possible. Apple can do this and tie the code to the specific hardware, kernel, and what else matters that Safari runs on as they control everything. Chrome and Firefox cannot. I would not be surprised if someone tells me that parts of Safari hook into private APIs in the kernel, the graphics driver…

You think Apple should be punished for creating a vertically integrated stack?

Setting aside private APIs as I have no idea what Safari does or doesn't use (although vast portions of it are open source, enough that you can compile modern versions of WebKit and "upgrade" the ancient WebKit on PowerPC Macs), another browser could be just as closely integrated as Safari. Obviously, the cost/benefit ratio is awful for Mozilla and Google, so they won't, but why should Apple cripple their own software? Safari's development costs, as part of MacOS, are funded by profits from Mac sales. Safari is deeply integrated with MacOS which is in turn deeply integrated with the Mac.

In my opinion the whole point of the Mac is this vertical integration, and the main value-add of Apple's sphere. If you don't value that, there are cheaper options where cheaper and more flexible software is available.

To me, an anti-trust suit would make sense for Safari on iOS, where Apple has locked all competitors out (in practice). Saying Apple should be fined for Safari because it's more integrated and efficient and that's not fair to Chrome and Firefox seems a bit silly, especially given (desktop) Safari's relatively small usage numbers. All IMO of course.

Post reply on HN