diff --git a/browser/base/content/tabbrowser.css b/browser/base/content/tabbrowser.css index 871f727f37b1..2dd6a05297c8 100644 --- a/browser/base/content/tabbrowser.css +++ b/browser/base/content/tabbrowser.css @@ -53,3 +53,13 @@ tabpanels { .tabbrowser-tabs:not(:hover) > .tabbrowser-arrowscrollbox > .closing-tabs-spacer { transition: width .15s ease-out; } + +/** + * Optimization for tabs that are restored lazily. We can save a good amount of + * memory that to-be-restored tabs would otherwise consume simply by setting + * their browsers to 'display: none' as that will prevent them from having to + * create a presentation and the like. + */ +browser[pending] { + display: none; +} diff --git a/browser/components/sessionstore/src/SessionStore.jsm b/browser/components/sessionstore/src/SessionStore.jsm index 7763fb6efe34..1950823b6ae1 100644 --- a/browser/components/sessionstore/src/SessionStore.jsm +++ b/browser/components/sessionstore/src/SessionStore.jsm @@ -2987,6 +2987,7 @@ let SessionStoreInternal = { // a tab gets closed before it's been properly restored browser.__SS_data = tabData; browser.__SS_restoreState = TAB_STATE_NEEDS_RESTORE; + browser.setAttribute("pending", "true"); tab.setAttribute("pending", "true"); // Make sure that set/getTabValue will set/read the correct data by @@ -3171,6 +3172,7 @@ let SessionStoreInternal = { // Set this tab's state to restoring browser.__SS_restoreState = TAB_STATE_RESTORING; + browser.removeAttribute("pending"); aTab.removeAttribute("pending"); // Remove the history listener, since we no longer need it once we start restoring @@ -4335,6 +4337,9 @@ let SessionStoreInternal = { // The browser is no longer in any sort of restoring state. delete browser.__SS_restoreState; + aTab.removeAttribute("pending"); + browser.removeAttribute("pending"); + // We want to decrement window.__SS_tabsToRestore here so that we always // decrement it AFTER a tab is done restoring or when a tab gets "reset". window.__SS_tabsToRestore--;