How does the 'tab unloading feature' in Firefox 93 work?



Released on October 5, 2021,

Firefox 93 adds the ability to automatically unload tabs to free up memory space when your system is low on available memory. Mozilla software engineer Haik Aftandilian explains the details of this feature.

Tab Unloading in Firefox 93 --Mozilla Hacks --the Web developer blog
https://hacks.mozilla.org/2021/10/tab-unloading-in-firefox-93/

◆ Overview of tab unload function
The tab unload function is a function that prevents Firefox from crashing by determining 'tabs that the user is not using' and unloading them when the available memory of the system is low. According to Aftandilian, this feature is 'users with systems with low memory', 'users running software that consumes a lot of memory such as games in addition to Firefox', and 'web pages that consume a lot of memory'. It is useful for 'users who open' and 'users who open a large number of tabs at the same time'.

Also, as of Firefox 93 release, tab unloading is available for Windows. 'On Windows, the main cause of Firefox crashes is out of memory. The tab unload feature allows Firefox to reduce out-of-memory crashes and avoid interrupting web browsing,' said Aftandilian.



◆ Background to implementation for Windows
The Firefox development team has previously tested the tab unloading feature for Windows. However, since it makes the user wait when reloading the unloaded tab, it is officially stated as 'it is difficult to balance reducing the memory usage of the browser and deteriorating the user's usability'. Hiring was postponed. The tab unload function implemented in Firefox 93 this time is equipped with an 'algorithm that determines tabs that the user is not using', and limits the operation when the remaining memory is low and the browser is likely to crash. As a result, we have succeeded in suppressing Firefox crashes without compromising usability.

In testing with the Nightly version of Firefox for a month, Firefox with the tab unload feature enabled has significantly fewer Firefox crashes and longer continuous operation times than other Firefox. It was said that. On the other hand, it was also confirmed that the ratio of crashes due to lack of memory to the total number of crashes increased, and the average memory usage increased.

Aftandilian argued that the reason for the increased memory usage was that the unload feature properly avoided crashes, allowing Firefox to continue to use memory usage that would crash in the past. I explain that. In addition, the reason why the rate of crashes due to insufficient memory increased is thought to be 'tab unload timing' 'compatibility with Windows memory management function', but the detailed cause is unknown. Even so, we decided to install a tab unload function, saying that the reduction in crashes clearly improved the usability.

◆ When is the tab unloaded?
Windows notifies running applications of out of memory when the free memory is less than about 6%. When Firefox receives this notification, it uses the Windows memory monitoring API to monitor the system's remaining memory and unloads tabs when the remaining memory falls below the threshold set in 'browser.low_commit_space_threshold_mb'. To do.



According to Aftandilian, if there is a page file of sufficient size even if the remaining memory is insufficient, the operation will be slow but the crash can be avoided. So Aftandilian said, 'Some people think that you don't need to create swap space if you have a lot of memory, but that's not a good idea!' And recommends creating a page file. increase.

◆ What are the selection criteria for tabs to unload?
Firefox 93 preferentially unloads recently unused tabs. Also, tabs that play sound, tabs that run picture-in-picture , pinned tabs, and tabs used for video conferences and voice chats are excluded from unloading.

'We will continue to experiment and tune the algorithm to maintain Firefox performance and reduce crashes while keeping it out of the way of users,' said Aftandilian. In addition, Firefox 94 will implement a setting screen 'about: unloads' for manually managing the unload function of tabs.



◆ Coexistence with extensions that provide tab unloading
Some Firefox extensions have the ability to unload tabs. These extensions

operate based on the API 'tabs.discard () ' and are expected to coexist with the tab unload function installed in Firefox 93. Also, since the tab unload function included in Firefox 93 works only when the system has very little memory remaining, it may be possible to secure more memory than the standard function by using the extension function. Aftandilian points out that there is.

At the time of Firefox 93 release, the tab unload function was provided for Windows, and it is planned to support macOS and Linux in the future. You can also see other new features and changes in Firefox 93 in the following articles:

'Firefox 93' official release, AVIF support & tab automatic unload function added to reduce memory usage --GIGAZINE

in Software, Posted by log1o_hf