Using 'Native Window Occlusion', Google Chrome Eats Less Resources When It's Idle

Chrome, the fast and the curious

Google Chrome is very powerful web browser. But that makes it come with a bit of an issue.

And that issue is caused by the browser's extensive use of resources. Regular Chrome users are no stranger to Chrome's appetite as from time to time, many would encounter the moment when their computer starts to lag.

The longer users use Chrome and the more tabs are opened, the browser will keep becoming the resource hog that devours resources whenever it sees any available.

Google knows this too well.

The company designed Chrome to be that way because it doesn't users to have their browsing experience affected, and in order to make all of the browser's features and functionalities available whenever users need them.

The thing is, Chrome's hunger for resources can be an issue to those users who use less-capable computers that are low in memory.

Previously, Google tried to at least reduce the issue by utilizing Microsoft Windows 10's terminate process, and also disabling the operating system's RAM-saving feature.

This time, Google goes a step further, by making the browser eat less resources when it's occluded.

The functionality eessentially makes Chrome less hungry but without affecting its performance.

Previously, Chrome can save computers' resources when they are not opened or being used. When tabs are inactive, Chrome can prevent the tabs from being rendered. This saves up computing power, making Chrome a bit faster.

This time, Chrome uses that same approach, but implements it to the whole browser.

When the browser detects that its windows are occluded or completely covered by other windows, the browser will help the computer to free up resources instead of demanding for more.

But before that can happen, the team had to tackle some issues.

First, operating systems give no direct way for Chrome to know when its window is completely covered by other windows. And second, there are chances that users use multi-monitor setups, virtual desktops, non-opaque windows and cloaked windows.

"In theory, figuring out which windows are occluded is fairly simple. In practice, however, there are lots of complications." explained Chrome developer David Bienvenu. "This needs to be done with great care, because if we decide that a window is occluded when in fact it is visible to the user, then the area where the user expects to see web contents will be white."

"We also don’t want to block the UI thread while doing the occlusion calculation, because that could reduce the responsiveness of Chrome and degrade the user experience."

Native Window Occlusion

After three years of experimentation, Chrome’s developers finally found the solution, and came up with project 'Native Window Occlusion'.

If a window is occluded, Chromium treats foreground tabs as if they were background tabs; rendering stops, and JavaScript is throttled.

Google came up with it because the team doesn't want Chrome to continuously calculate occlusion because it would degrade the performance. Using the Native Window Occlusion, Chrome only needs to know when its window is visible or occluded to save resources.

According to its documentation, its uses an API to track which aura windows are occluded.

In a blog post written by Bienvenu, the company claimed that since implementing the changes, Chrome became 8.5% to 25.8% faster at startup, used 3.1% less GPU memory, had 20.4% fewer renderer frames drawn overall, as well as 4.5% fewer clients experiencing renderer crashes.

Then, there is also a 3.0% improvement in first input delay, as well as a 6.7% improvement in first contentful paint and largest contentful paint.

Published: 
14/12/2021