Bug 1443871 - ensure eXPCOM consumer flag is always set if the service still exists. r=surkov
authorYura Zenevich <yura.zenevich@gmail.com>
Thu, 08 Mar 2018 12:22:22 -0500
changeset 462339 9ed1661d198ea5eaad861d171c75a79004e3ca36
parent 462338 f263f5dceef3c6de8c742a8fb1196160a6e1c251
child 462340 75ccc12de3267a8876946fc96f22189b7ef5ba32
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs1443871
milestone60.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 1443871 - ensure eXPCOM consumer flag is always set if the service still exists. r=surkov MozReview-Commit-ID: 8BYRPqH7jvq
accessible/base/nsAccessibilityService.cpp
accessible/base/nsAccessibilityService.h
--- a/accessible/base/nsAccessibilityService.cpp
+++ b/accessible/base/nsAccessibilityService.cpp
@@ -1676,23 +1676,25 @@ nsAccessibilityService::HasAccessible(ns
 
   return document->HasAccessible(node);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsAccessibilityService private (DON'T put methods here)
 
 void
-nsAccessibilityService::SetConsumers(uint32_t aConsumers) {
+nsAccessibilityService::SetConsumers(uint32_t aConsumers, bool aNotify) {
   if (gConsumers & aConsumers) {
     return;
   }
 
   gConsumers |= aConsumers;
-  NotifyOfConsumersChange();
+  if (aNotify) {
+    NotifyOfConsumersChange();
+  }
 }
 
 void
 nsAccessibilityService::UnsetConsumers(uint32_t aConsumers) {
   if (!(gConsumers & aConsumers)) {
     return;
   }
 
@@ -1756,20 +1758,26 @@ MaybeShutdownAccService(uint32_t aFormer
 {
   nsAccessibilityService* accService =
     nsAccessibilityService::gAccessibilityService;
 
   if (!accService || accService->IsShutdown()) {
     return;
   }
 
+  // Still used by XPCOM
   if (nsCoreUtils::AccEventObserversExist() ||
       xpcAccessibilityService::IsInUse() ||
       accService->HasXPCDocuments()) {
-    // Still used by XPCOM
+    // In case the XPCOM flag was unset (possibly because of the shutdown
+    // timer in the xpcAccessibilityService) ensure it is still present. Note:
+    // this should be fixed when all the consumer logic is taken out as a
+    // separate class.
+    accService->SetConsumers(nsAccessibilityService::eXPCOM, false);
+
     if (aFormerConsumer != nsAccessibilityService::eXPCOM) {
       // Only unset non-XPCOM consumers.
       accService->UnsetConsumers(aFormerConsumer);
     }
     return;
   }
 
   if (nsAccessibilityService::gConsumers & ~aFormerConsumer) {
--- a/accessible/base/nsAccessibilityService.h
+++ b/accessible/base/nsAccessibilityService.h
@@ -306,17 +306,17 @@ private:
   /**
    * Get a JSON string representing the accessibility service consumers.
    */
   void GetConsumers(nsAString& aString);
 
   /**
    * Set accessibility service consumers.
    */
-  void SetConsumers(uint32_t aConsumers);
+  void SetConsumers(uint32_t aConsumers, bool aNotify = true);
 
   /**
    * Unset accessibility service consumers.
    */
   void UnsetConsumers(uint32_t aConsumers);
 
   /**
    * Reference for accessibility service instance.