Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Why browsers are bloated

Name: Anonymous 2014-07-27 0:20

https://github.com/WebKit/webkit/blob/master/Source/WebCore/platform/Scrollbar.cpp
https://github.com/WebKit/webkit/blob/master/Source/WebCore/platform/win/ScrollbarThemeWin.cpp
Let's reinvent the fucking scrollbar, which every goddamn platform with a UI already has, and make it behave subtly different from the native one!

Right-click a native scrollbar in some other app:
- Scroll Here
- Top
- Bottom
- Page Up
- Page Down
- Scroll Up
- Scroll Down

Right-click a scrollbar in Chrome:
- Back
- Forward
- Reload
- Save As...
...

Right-click a scrollbar in Firefox and Opera:
Absolutely fucking nothing happens!

What the fuck!? How did these terminally retarded idiots get involved in creating one of the most important pieces of software to the average user?

Name: Anonymous 2014-07-27 9:03

SOFT_LINK(uxtheme, DrawThemeBackground, HRESULT, WINAPI, (HANDLE hTheme, HDC hdc, int iPartId, int iStateId, const RECT* pRect, const RECT* pClipRect), (hTheme, hdc, iPartId, iStateId, pRect, pClipRect))
MICROSOFT QUALITY

Either way, the web standards are too bad and bloated to make a good browser. All you can do is wait until everything died its slow death and is replaced by the glorious decentralized Lisp Web.

Name: Anonymous 2014-07-27 9:11

>>2
Decentralisation is part of the cancer

Name: Anonymous 2014-07-27 9:20

>>3
Enjoy your NSA. What are you going to do if the /prog/ server goes down indefinitely tomorrow? If it was decentralized, you'd do nothing because it would have barely any effect.

Name: Anonymous 2014-07-27 9:22

>>4
I would take a back-up
Every decentralised model has failed and will continue to do so

Name: Anonymous 2014-07-27 9:25

>>5
And who would host it? Who would find it? What if the next administrator is lel-kunt?

Name: Anonymous 2014-07-27 11:28

>>3
Misspelling the "-ization" suffix is part of the cancer.

Name: Anonymous 2014-07-27 11:31

>>7
Fuck off murrifag, burger fucker

Name: Anonymous 2014-07-27 14:55

>>6

What if the currtent admin is lel-kunt!?!?

Name: Anonymous 2014-07-29 17:41

Name: Anonymous 2014-07-29 23:03

>>10
uzbl?

Uses WebkitGtk+ for rendering

Now look at the links in the OP again... all these stupid "minimalist" browsers are just a different UI with the same existing bloated rendering engine.

Name: Anonymous 2014-07-29 23:50

>>11-kun speaks the truth
luakit is better, but still a shit
We need something new

Name: Anonymous 2014-07-30 1:14

>>12
luakit
webkit based browser framework

Name: Anonymous 2014-07-30 4:01

>>11,12
What's so bloated about the rendering engine? Did you want a HTML engine that only supported HTML4 and CSS2?

Name: Anonymous 2014-07-30 4:08

HTML and CSS are bloated.

Name: Anonymous 2014-07-30 6:30

>>14
I want a rendering engine that doesn't reinvent scrollbars, for one thing.

Name: Anonymous 2014-07-30 8:07

Why do these idiots blabber about how a rendering engine is so terribly complex and monstrously huge? Why is rendering a web page any harder than rendering an app GUI? It's all just text and rectangles. OK, there also SVG and Flash, but there are plugins for that. Why can't anyone just take GTK or Qt and make a browser out of it?

Name: /lounge/ 2014-07-30 8:51

>>17
The rendering engine needs to interpret every piece of element within the HTML page. It also has to keep track of every element within each web page. This means your rendering engine has to keep track of a lot of information as well as render that information. If you want an example of the complexity of rendering documents with many individual elements, try looking at the source code of Scribus and have a look at the data of a Scribus document.

Name: Anonymous 2014-07-30 11:56

Chrome is even worse - the minimise/maximise/close buttons are actually bitmap images! (http://src.chromium.org/viewvc/chrome/trunk/src/ui/resources/ )

They've also been reinventing the scrollbars too; it looks like WebKit uses the native drawing routine for scrollbars, but Chrome wants to reimplemnt that itself: http://my-chrome.ru/2014/01/about-scrollbars/ (from right to left: natively drawn scrollbar, Chrome-drawn half-broken scrollbar, Chrome-drawn slightly-less-broken scrollbar.)

>>17,18
They're complex because the monkeys who write them are doing it wrong. I've been (slowly) working on a CSS box renderer and the code is actually quite simple and straightforward once the algorithms have been figured out.

The big rendering engines are written by large teams with deadlines so there's necessarily the whole OOP bloat (all the ways to make software easier to write for large loose teams but creates ridiculously inefficient enterprisey designs: "separation of concerns", "information hiding", etc.) and less time spent thinking about the simplest way to do something, which also adds to the complexity.

On the other hand I'm working alone and not trying to make any deadlines, so I can spend as much time as I like thinking about how to design this thing and have it as monolithic as it needs to be. For example, the document is tree-structured so it seems to suggest a lot of algorithms are going to be recursive; I also thought at first this would be how the line layout (including wordwrap) should be done, but then realised just how much state would need to be passed around and that doing it recursively seemed far too complex.

If I was someone working as part of a team on a project with a deadline, I might've just accepted the complexity at this point, maybe even tried to hide it behind a design pattern (which just makes things worse overall!) or made several classes, and wrote the code. This is how most of the existing rendering engines (and the bulk of software) was written.

Instead I thought about it more and realised that recursion is not the best way to do it - the boxes do form a tree structure, but recursion isn't needed to traverse them and calculate linebreaks since that requires a more linear view of the data. I ended up with an extremely elegant and simple algorithm based on a few loops and pointer following. It can't be written without using goto either, so a more traditional programmer probably would've never figured it out. The implementation of the core traversal and linebreaking decision is only a few dozen machine instructions.

Rendering a document is overall a complex task, but if you can consider all that complexity in large pieces, and condense them into a simple algorithm, then the code does not need to be complex. In contrast with the traditional notion of breaking problems into simpler pieces and then combining them together to create a more complex whole, I'm taking complex pieces of the problem and combining them together to create a simple whole. It's somewhat like procedural generation in the demoscene.

Let's make this thread the continuation of http://dis.4chan.org/read/prog/1321853871/

Name: Anonymous 2014-07-30 13:12

>>19
Can you post the code? I'm interested in your solution and a low-resource browser.

Name: Anonymous 2014-07-30 13:19

>>18
How is this thread for /lounge/?

Name: Alexander Dubček 2014-07-30 14:03

<style type="text/css">
dubs {
check: always;
}
</style>

Name: Anonymous 2014-07-30 23:08

>>21
Sorry, I forgot to deal with my thread redirection service.

Name: Cudder !MhMRSATORI 2014-07-31 12:00

>>19
That was me. Name field somehow disappeared...

>>20
Here's most of the interesting part (non-recursive CSS box tree traversal.) Linebreaking is just looping through the text, updating the break positions and width as you go, and splitting upwards when the line becomes too wide. There are some special cases like font-family: monospace and white-space: pre/nowrap/pre-wrap that probably don't need examining every single character. The upward-splitting code is also non-recursive, it's another big loop. Then the x/y is adjusted appropriately to the next line and the algorithm continues exactly where it left off - no "backtracking" or wasted work.

; esi = cur_y edi = cur_x
; ecx = avail_width
; edx = last_bkpt linebreaking info
; ebp = containing block box
mov ebx, ebp
xor esi, esi
line_loop:
call set_widths ; sets edi and ecx
mov ebx, [ebx+cssbox.first_child]
or ebx, ebx
jz done
loop1:
mov al, [eax+cssbox.type]
cmp al, CSB_TEXT
jnz not_text
; <code omitted>
not_text:
cmp al, CSB_INBK
jnz not_inbk
call cssbox_extw
add edi, eax
cmp edi, ecx
jb check_sib
cmp [ebx+cssbox.prev_sibling], dord 0
jz check_sib
; <code omitted>
jmp loop1
not_inbk: ; CSB_INLN
call cssbox_lncaw
add edi, eax
mov eax, [ebx+cssbox.first_child]
or eax, eax
jz exit_box
mov ebx, eax
jmp loop1
exit_box:
call cssbox_rncaw
exit_loop:
add edi, eax
check_sib:
mov eax, [ebx+cssbox.next_sibling]
or eax, eax
jz go_up
mov ebx, eax
jmp loop1
go_up:
mov ebx, [ebx+cssbox.parent]
cmp ebx, ebp
jnz exit_box
done:


For comparison, the wordwrapping and box traversal algorithm in WebKit is, I think, somewhere in here... or maybe spread across many of the other several dozen files in the directory: http://trac.webkit.org/browser/trunk/Source/WebCore/rendering/InlineFlowBox.cpp

And for your amusement, here is a WTF I found in the HTML parser:
https://github.com/WebKit/webkit/blob/master/Source/WebCore/html/parser/NestingLevelIncrementer.h

Name: Cudder !MhMRSATORI 2014-07-31 12:05

Also noticed WK uses floating point for positions!

Who thought that was better than fixed-point? No one needs webpages several billion pixels high...

Name: Cudder !MhMRSATORI 2014-07-31 12:07

s/mov al, [eax+cssbox.type]/mov al, [ebx+cssbox.type]/

Name: Anonymous 2014-07-31 12:15

>>19
If I was someone working as part of a team on a project with a deadline, I might've just accepted the complexity at this point, maybe even tried to hide it behind a design pattern (which just makes things worse overall!) or made several classes, and wrote the code. This is how most of the existing rendering engines (and the bulk of software) was written.

While it's fantastic that you've found an elegant solution to parsing and rendering HTML pages, the rest of the world generally doesn't have the time to work as you do. This is why open source corporate projects (like any other corporate software project) take the worse is better approach to programming - "if it runs well enough then we can ship it". Maybe if you write a web log detailing your solution together with your analysis of the Gecko engine, you could send a notice to the Mozilla engineers who might pick up a few ideas to put into Gecko.

Name: Anonymous 2014-07-31 13:02

Name: Anonymous 2014-07-31 15:24

>>26
Shalom!

Name: Anonymous 2014-07-31 17:10

>>28
It's not open source quality, it's Apple quality. With closed source it would be the same except you wouldn't be able to see and appreciate the beauty of ENTERPRISE SOLUTIONS.

Name: Anonymous 2014-07-31 18:41

>>27
In a corporate environment, it's much easier to appear productive when you're furiously banging away at a keyboard and producing lots of code. The guy who just sits there thinking doesn't look like he's doing anything. That's why you get shit like classes containing a single variable and two trivial methods, because "I wrote ten classes today" sounds like you're getting a lot of things done while "I added a few variables and functions" doesn't. I don't work for Apple but a lot of other places love to use metrics like SLoC to measure productivity, which ends up encouraging this WTF-ery.

>>28
adjustmentForChildrenWithSameLineHeightAndBaseline
It's like I'm really reading Java!

Name: Anonymous 2014-07-31 21:06

>>31
It's clear and descriptive of its purpose. There is no better way to clearly describe such a complex idea short of inventing a new word to describe it.

Name: Anonymous 2014-07-31 22:35

>>31
The guy who just sits there thinking doesn't look like he's doing anything.
"I wrote ten classes today" sounds like you're getting a lot of things done
The volume of code output doesn't matter so much as progressing through the list of specifications in the world of business paid programming. A 50 line procedure that is functionally equivalent to a 200 line procedure doesn't matter to anybody but programmers. If the 200 line procedure was quicker to reason and write, that's what's getting shipped.

A thoughtful programmer who spends all day to remove 30 lines of code from the codebase (in order to make the logic cleaner) is less productive than a workhorse programmer who spends all day going through sections of the specification with masses of code - the brute force programmer is actually making progress and software stakeholders value this more than clean code. This doesn't mean that all progress is good progress. Progression without a reasonable amount care can lead to various software and development problems in the future.

The world of programmers for hire is a balancing act that leans towards people who achieves the most within the smallest amount of time.

Name: Anonymous 2014-08-01 2:57

>>33
If the 200 line procedure was quicker to reason and write, that's what's getting shipped.
Your arguments is fallacious, because larger codebase impedes maintainability in the long run. I.e. saving $1 today can easily cost you $10 tomorrow. It is like debt, with only difference is that you can borrow more to repay current debt.

Name: Anonymous 2014-08-01 6:06

>>34
debt
Shalom!

Name: Anonymous 2014-08-01 7:27

A web browser could easily be implemented with just few lines of bash/awk/sed/curl. There's no way to justify the millions of lines of code that are in modern web browsers.

Name: Anonymous 2014-08-01 8:51

to justify is to be an ~idiot~

Name: Anonymous 2014-08-01 10:40

6 000 000 source lines of code

Name: Cudder !MhMRSATORI 2014-08-01 12:18

>>27
The amount of time I've spent on this algorithm in total probably does not exceed a day at most; I'm normally very busy with other things. I don't think "worse is better" applies here, since that usually leads to much simpler designs which don't handle particular edge-cases well (e.g. Unix), instead of grotesque complexity.

>>31,32
If you ever find yourself needing to describe such a complex idea, you should probably reconsider your approach. From a quick glance it appears to be for moving boxes up/down depending on vertical alignment, something which the code manages to make extremely bloated despite it being a very simple idea:

1. Collect the maximum height of all the boxes on one line, while laying them out; this will be the line height.
2.a Top-aligned boxes don't need to be moved.
2.b Centre-aligned boxes have (maxHeight - height)/2 added to their y-position
2.c Bottom-aligned boxes have maxHeight - height added to their y-position

The WK code expresses this too, but it's far more obfuscated and probably traverses the box list many more times than necessary - there's a function to do the first step mentioned above, but it traverses the whole box list. If layout has to traverse the box list already, why not compute the maximum height at the same time? The monkeys will spout things like "modularity" and "encapsulation", because they were so brain-damaged by their religious adherence to OOP dogma that they don't realise it's extra work both for them to write extra code, and the machine to execute it. They might also cry "premature optimisation", but this isn't any clever optimisation, it's common sense. To think otherwise is like driving to the store and back for each individual item you buy - absolutely retarded! Anyone sane wouldn't ever think of doing such a thing, yet put them in front of a computer, indoctrinate them with OOP religion, and this is what they'll do.

>>33
I don't see how using excessively verbose code with tons of needless indirection/abstraction and mind-numbingly-long variable names is in any way more productive. The same goes for reimplementing basic UI functionality and creating trivial classes - it's busy work, useless time-sinks to give the impression of being productive.

http://en.wikipedia.org/wiki/Muda_(Japanese_term)

Name: Anonymous 2014-08-01 13:07

>>39
Shalom!

Newer Posts