Bug 1268177 - Disable background tab zombifications during tests. r=margaret
During tests that open additional tabs, the main test tab controlling the test is at risk of being zombified if a memory pressure event arrives, which breaks the test and leads to the test timing out. Therefore, we now disable background tab zombifications during tests.
This means that there's a slightly increased risk of being OOM killed instead, however
- the tabs opened by the tests themselves are normally relatively short-lived anyway
- we're no worse off than if the tab containing the test harness code had been zombified.
MozReview-Commit-ID: 1Ntvn4yjWlZ
--- a/mobile/android/app/mobile.js
+++ b/mobile/android/app/mobile.js
@@ -26,16 +26,21 @@ pref("toolkit.browser.contentViewExpire"
pref("toolkit.defaultChromeURI", "chrome://browser/content/browser.xul");
pref("browser.chromeURL", "chrome://browser/content/");
// If a tab has not been active for this long (seconds), then it may be
// turned into a zombie tab to preemptively free up memory. -1 disables time-based
// expiration (but low-memory conditions may still require the tab to be zombified).
pref("browser.tabs.expireTime", 900);
+// Disables zombification of background tabs under memory pressure.
+// Intended for use in testing, where we don't want the tab running the
+// test harness code to be zombified.
+pref("browser.tabs.disableBackgroundZombification", false);
+
// Control whether tab content should try to load from disk cache when network
// is offline.
// Controlled by Switchboard experiment "offline-cache".
pref("browser.tabs.useCache", false);
// From libpref/src/init/all.js, extended to allow a slightly wider zoom range.
pref("zoom.minPercent", 20);
pref("zoom.maxPercent", 400);
--- a/mobile/android/chrome/content/MemoryObserver.js
+++ b/mobile/android/chrome/content/MemoryObserver.js
@@ -15,21 +15,23 @@ var MemoryObserver = {
this.gc();
} else if (aTopic == "Memory:Dump") {
this.dumpMemoryStats(aData);
}
},
handleLowMemory: function() {
// do things to reduce memory usage here
- let tabs = BrowserApp.tabs;
- let selected = BrowserApp.selectedTab;
- for (let i = 0; i < tabs.length; i++) {
- if (tabs[i] != selected && !tabs[i].playingAudio) {
- this.zombify(tabs[i]);
+ if (!Services.prefs.getBoolPref("browser.tabs.disableBackgroundZombification")) {
+ let tabs = BrowserApp.tabs;
+ let selected = BrowserApp.selectedTab;
+ for (let i = 0; i < tabs.length; i++) {
+ if (tabs[i] != selected && !tabs[i].playingAudio) {
+ this.zombify(tabs[i]);
+ }
}
}
// Change some preferences temporarily for only this session
let defaults = Services.prefs.getDefaultBranch(null);
// Reduce the amount of decoded image data we keep around
defaults.setIntPref("image.mem.max_decoded_image_kb", 0);
--- a/testing/profiles/prefs_general.js
+++ b/testing/profiles/prefs_general.js
@@ -53,16 +53,20 @@ user_pref("font.size.inflation.emPerLine
user_pref("font.size.inflation.minTwips", 0);
// AddonManager tests require that the experiments provider be present.
user_pref("experiments.supported", true);
// Point the manifest at something local so we don't risk it hitting production
// data and installing experiments that may vary over time.
user_pref("experiments.manifest.uri", "http://%(server)s/experiments-dummy/manifest");
+// Don't allow background tabs to be zombified, otherwise for tests that
+// open additional tabs, the test harness tab itself might get unloaded.
+user_pref("browser.tabs.disableBackgroundZombification", true);
+
// Only load extensions from the application and user profile
// AddonManager.SCOPE_PROFILE + AddonManager.SCOPE_APPLICATION
user_pref("extensions.enabledScopes", 5);
user_pref("extensions.autoDisableScopes", 0);
// Disable metadata caching for installed add-ons by default
user_pref("extensions.getAddons.cache.enabled", false);
// Disable intalling any distribution add-ons
user_pref("extensions.installDistroAddons", false);