Bug 1253278 - Don't zombify tabs that are playing audio. r=margaret
authorPaul Adenot <paul@paul.cx>
Fri, 04 Mar 2016 18:09:01 +0100
changeset 324936 f637f149610bb15fdbbda534417d6743877738f5
parent 324935 c254f951e0ad68f047763f8e2c2fa9385b74a798
child 324937 83d12204f30d4f57833c0512a5c29851d09bc8ff
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmargaret
bugs1253278
milestone47.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1253278 - Don't zombify tabs that are playing audio. r=margaret
mobile/android/chrome/content/browser.js
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -3350,16 +3350,17 @@ function Tab(aURL, aParams) {
   this.userScrollPos = { x: 0, y: 0 };
   this.contentDocumentIsDisplayed = true;
   this.pluginDoorhangerTimeout = null;
   this.shouldShowPluginDoorhanger = true;
   this.clickToPlayPluginsActivated = false;
   this.desktopMode = false;
   this.originalURI = null;
   this.hasTouchListener = false;
+  this.playingAudio = false;
 
   this.create(aURL, aParams);
 }
 
 /*
  * Sanity limit for URIs passed to UI code.
  *
  * 2000 is the typical industry limit, largely due to older IE versions.
@@ -4137,20 +4138,22 @@ Tab.prototype = {
           return;
         }
 
         let browser = aEvent.originalTarget;
         if (browser != this.browser) {
           return;
         }
 
+        this.playingAudio = aEvent.type === "DOMAudioPlaybackStarted";
+
         Messaging.sendRequest({
           type: "Tab:AudioPlayingChange",
           tabID: this.id,
-          isAudioPlaying: aEvent.type === "DOMAudioPlaybackStarted"
+          isAudioPlaying: this.playingAudio
         });
         return;
       }
 
       case "DOMWindowClose": {
         if (!aEvent.isTrusted)
           return;
 
@@ -7276,18 +7279,21 @@ var Tabs = {
       // This behaviour is disabled.
       return false;
     }
     let tabs = BrowserApp.tabs;
     let selected = BrowserApp.selectedTab;
     let lruTab = null;
     // Find the least recently used non-zombie tab.
     for (let i = 0; i < tabs.length; i++) {
-      if (tabs[i] == selected || tabs[i].browser.__SS_restore) {
-        // This tab is selected or already a zombie, skip it.
+      if (tabs[i] == selected ||
+          tabs[i].browser.__SS_restore ||
+          tabs[i].playingAudio) {
+        // This tab is selected, is already a zombie, or is currently playing
+        // audio, skip it.
         continue;
       }
       if (lruTab == null || tabs[i].lastTouchedAt < lruTab.lastTouchedAt) {
         lruTab = tabs[i];
       }
     }
     // If the tab was last touched more than browser.tabs.expireTime seconds ago,
     // zombify it.