Hacker News new | ask | show | jobs
by forrestthewoods 701 days ago
> They don't draw every single object on the screen every frame, that could easily cause lag on a large complex page.

Games draw every single object on the screen every frame. They don't lag, quite the opposite in fact!

3 comments

I think the above was a simplification. GUI rendering is a good example of jack of all trades, master of none. It doesn't use tight render loops like game engines but it much more flexible in terms of UI possibilities.

There is also the issue that GPU's are oddly terrible at generating 2D elements of which a desktop has thousands of them. There are things like Glyph caching but they can only go so far.

Having the CPU doing the majority of the work with a few rasterization tasks to the GPU makes sense.

> There is also the issue that GPU's are oddly terrible at generating 2D elements

I never knew this and honestly I’m a bit baffled - 2D seems simpler on its face, is it just that GPUs have been made with gaming in mind (typically) and most “hardcore gamers” are playing 3D games?

I can't find it right now, but I recall reading an article years ago where a newer, more powerful generation of GPUs turned out to have much less hardware for 2D operations/calls, and a fraction of the 2D performance, but the performance in 3D games went up so nobody really noticed.
In fact that exact line of thinking was behind an effort to rewrite Firefox's rendering to be more like a game engine, a few years ago.

Not sure where that went in the end.

It's called WebRender and it shipped in Firefox.
That sounds like something from the shuttered Servo team. At least they rose like a phoenix - https://servo.org/
Yes, that sounds about right! I remember a series of very interesting blog posts by them.
Games are expected to have sole access to your machine, so if they use all the CPU/GPU resources, nobody cares. If my web browser was burning up my battery re-rendering the page 90 times a second, I'd be livid.
I think “consumes too much resources” is a valid concern. But I think “could cause lag because too many objects” is totally bogus. Rendering a web page isn’t that complicated.
I wouldn’t have thought so either, and then I learned the order in which CSS rules are applied and I’m convinced browsers have some of the most complex rendering engines out there.
> Games are expected to have sole access to your machine, so if they use all the CPU/GPU resources, nobody cares. If my web browser was burning up my battery re-rendering the page 90 times a second, I'd be livid.

Games 20 years ago had sole access to machines that were much less powerful than even partial access to today's machines.

And eg Nintendo Switch games (or games on the Steam deck, or just mobile phone games) still deal with power limitations; people are very aware when their games burn through their batteries.