Bug 957346 - Extend grace period for perceivable background processes. r=fabrice, a=1.3+
authorBen Kelly <ben@wanderview.com>
Wed, 15 Jan 2014 18:17:59 -0500
changeset 175820 9a006d9a6e1df1aa3c0e9cbed07346bdcd7e8d6f
parent 175819 b3b07adaf7cd1ebea04cf76a04bdffa779632da9
child 175821 b72da8376ea82558af8e24f7f47178f496025826
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfabrice, 1
bugs957346
milestone28.0a2
Bug 957346 - Extend grace period for perceivable background processes. r=fabrice, a=1.3+
b2g/app/b2g.js
dom/ipc/ProcessPriorityManager.cpp
--- a/b2g/app/b2g.js
+++ b/b2g/app/b2g.js
@@ -604,19 +604,21 @@ pref("javascript.options.mem.gc_allocati
 pref("javascript.options.mem.gc_decommit_threshold_mb", 1);
 
 // Show/Hide scrollbars when active/inactive
 pref("ui.showHideScrollbars", 1);
 pref("ui.useOverlayScrollbars", 1);
 
 // Enable the ProcessPriorityManager, and give processes with no visible
 // documents a 1s grace period before they're eligible to be marked as
-// background.
+// background. Background processes that are perceivable due to playing
+// media are given a longer grace period to accomodate changing tracks, etc.
 pref("dom.ipc.processPriorityManager.enabled", true);
 pref("dom.ipc.processPriorityManager.backgroundGracePeriodMS", 1000);
+pref("dom.ipc.processPriorityManager.backgroundPerceivableGracePeriodMS", 5000);
 pref("dom.ipc.processPriorityManager.temporaryPriorityLockMS", 5000);
 
 // Number of different background levels for background processes.  We use
 // these different levels to force the low-memory killer to kill processes in
 // a LRU order.
 pref("dom.ipc.processPriorityManager.backgroundLRUPoolLevels", 5);
 
 // Kernel parameters for process priorities.  These affect how processes are
--- a/dom/ipc/ProcessPriorityManager.cpp
+++ b/dom/ipc/ProcessPriorityManager.cpp
@@ -803,17 +803,26 @@ ParticularProcessPriorityManager::OnFram
 }
 
 void
 ParticularProcessPriorityManager::ResetPriority()
 {
   ProcessPriority processPriority = ComputePriority();
   if (mPriority == PROCESS_PRIORITY_UNKNOWN ||
       mPriority > processPriority) {
-    ScheduleResetPriority("backgroundGracePeriodMS");
+    // Apps set at a perceivable background priority are often playing media.
+    // Most media will have short gaps while changing tracks between songs,
+    // switching videos, etc.  Give these apps a longer grace period so they
+    // can get their next track started, if there is one, before getting
+    // downgraded.
+    if (mPriority == PROCESS_PRIORITY_BACKGROUND_PERCEIVABLE) {
+      ScheduleResetPriority("backgroundPerceivableGracePeriodMS");
+    } else {
+      ScheduleResetPriority("backgroundGracePeriodMS");
+    }
     return;
   }
 
   SetPriorityNow(processPriority);
 }
 
 void
 ParticularProcessPriorityManager::ResetPriorityNow()