Bug 1198459 - Add support for disabling e10s if a11y was run in the previous session, or run in a session over the previous week. r=felipe

This commit is contained in:
Jim Mathies 2015-12-09 08:35:06 -05:00
parent cbfa845299
commit d53f3a57ee
2 changed files with 61 additions and 3 deletions

View File

@ -49,6 +49,7 @@
#include "prprf.h"
#include "prproces.h"
#include "prenv.h"
#include "prtime.h"
#include "nsIAppShellService.h"
#include "nsIAppStartup.h"
@ -4594,6 +4595,17 @@ enum {
kE10sDisabledForMacGfx = 5,
};
const char* kAccessibilityLastRunDatePref = "accessibility.lastLoadDate";
const char* kAccessibilityLoadedLastSessionPref = "accessibility.loadedInLastSession";
const char* kForceEnableE10sPref = "browser.tabs.remote.force-enable";
static inline uint32_t
PRTimeToSeconds(PRTime t_usec)
{
PRTime usec_per_sec = PR_USEC_PER_SEC;
return uint32_t(t_usec /= usec_per_sec);
}
bool
mozilla::BrowserTabsRemoteAutostart()
{
@ -4601,6 +4613,37 @@ mozilla::BrowserTabsRemoteAutostart()
return gBrowserTabsRemoteAutostart;
}
gBrowserTabsRemoteAutostartInitialized = true;
bool disabledForA11y = false;
#ifdef XP_WIN
/**
* Avoids enabling e10s if accessibility has recently loaded. Performs the
* following checks:
* 1) Checks a pref indicating if a11y loaded in the last session. This pref
* is set in nsBrowserGlue.js. If a11y was loaded in the last session we
* do not enable e10s in this session.
* 2) Accessibility stores a last run date (PR_IntervalNow) when it is
* initialized (see nsBaseWidget.cpp). We check if this pref exists and
* compare it to now. If a11y hasn't run in an extended period of time or
* if the date pref does not exist we load e10s.
*/
disabledForA11y = Preferences::GetBool(kAccessibilityLoadedLastSessionPref, false);
if (!disabledForA11y &&
Preferences::HasUserValue(kAccessibilityLastRunDatePref)) {
#define ONE_WEEK_IN_SECONDS (60*60*24*7)
uint32_t a11yRunDate = Preferences::GetInt(kAccessibilityLastRunDatePref, 0);
MOZ_ASSERT(0 != a11yRunDate);
// If a11y hasn't run for a period of time, clear the pref and load e10s
uint32_t now = PRTimeToSeconds(PR_Now());
uint32_t difference = now - a11yRunDate;
if (difference > ONE_WEEK_IN_SECONDS || !a11yRunDate) {
Preferences::ClearUser(kAccessibilityLastRunDatePref);
} else {
disabledForA11y = true;
}
}
#endif
bool optInPref = Preferences::GetBool("browser.tabs.remote.autostart", false);
bool trialPref = Preferences::GetBool("browser.tabs.remote.autostart.2", false);
bool prefEnabled = optInPref || trialPref;
@ -4623,15 +4666,13 @@ mozilla::BrowserTabsRemoteAutostart()
gfxPrefs::GetSingleton().LayersOffMainThreadCompositionTestingEnabled();
#endif
// Check for some conditions that might disable e10s.
bool disabledForA11y = Preferences::GetBool("browser.tabs.remote.disabled-for-a11y", false);
// Disable for VR
bool disabledForVR = Preferences::GetBool("dom.vr.enabled", false);
if (e10sAllowed && prefEnabled) {
if (disabledForA11y) {
status = kE10sDisabledForAccessibility;
LogE10sBlockedReason("An accessibility tool is or was active. See bug 1115956.");
LogE10sBlockedReason("An accessibility tool is or was active. See bug 1198459.");
} else if (disabledForVR) {
LogE10sBlockedReason("Experimental VR interfaces are enabled");
} else {
@ -4678,6 +4719,11 @@ mozilla::BrowserTabsRemoteAutostart()
}
#endif // defined(XP_MACOSX)
// Uber override pref for manual testing purposes
if (Preferences::GetBool(kForceEnableE10sPref, false)) {
gBrowserTabsRemoteAutostart = true;
}
mozilla::Telemetry::Accumulate(mozilla::Telemetry::E10S_AUTOSTART, gBrowserTabsRemoteAutostart);
mozilla::Telemetry::Accumulate(mozilla::Telemetry::E10S_AUTOSTART_STATUS, status);
if (Preferences::GetBool("browser.enabledE10SFromPrompt", false)) {

View File

@ -1768,6 +1768,16 @@ nsBaseWidget::GetTextEventDispatcher()
#ifdef ACCESSIBILITY
// defined in nsAppRunner.cpp
extern const char* kAccessibilityLastRunDatePref;
static inline uint32_t
PRTimeToSeconds(PRTime t_usec)
{
PRTime usec_per_sec = PR_USEC_PER_SEC;
return uint32_t(t_usec /= usec_per_sec);
}
a11y::Accessible*
nsBaseWidget::GetRootAccessible()
{
@ -1786,6 +1796,8 @@ nsBaseWidget::GetRootAccessible()
nsCOMPtr<nsIAccessibilityService> accService =
services::GetAccessibilityService();
if (accService) {
uint32_t now = PRTimeToSeconds(PR_Now());
Preferences::SetInt(kAccessibilityLastRunDatePref, now);
return accService->GetRootDocumentAccessible(presShell, nsContentUtils::IsSafeToRunScript());
}