[orca] Add sanity checks and more debugging for intermittant Firefox-related hang



commit f65c26d465d71d0389aa92d2a0db01f190b3083e
Author: Joanmarie Diggs <jdiggs igalia com>
Date:   Sat Sep 26 16:42:54 2015 -0400

    Add sanity checks and more debugging for intermittant Firefox-related hang

 src/orca/debug.py                         |   19 ++++++++++++-------
 src/orca/event_manager.py                 |    8 +++++++-
 src/orca/script_utilities.py              |    2 +-
 src/orca/scripts/toolkits/Gecko/script.py |   10 ++++++++++
 src/orca/scripts/web/script.py            |   21 +++++++++++++++++++++
 src/orca/scripts/web/script_utilities.py  |    8 +++++++-
 6 files changed, 58 insertions(+), 10 deletions(-)
---
diff --git a/src/orca/debug.py b/src/orca/debug.py
index db1f9b5..9f03a59 100644
--- a/src/orca/debug.py
+++ b/src/orca/debug.py
@@ -312,14 +312,19 @@ def getAccessibleDetails(level, acc, indent="", includeApp=True):
         return ""
 
     if includeApp:
-        app = acc.getApplication()
-        if app:
-            try:
-                string = indent + "app.name='%s' " % app.name
-            except (LookupError, RuntimeError):
-                string = indent + "app.name='<error getting name>' "
+        try:
+            app = acc.getApplication()
+        except:
+            string = indent + "app=(exception getting app) "
+            app = None
         else:
-            string = indent + "app=None "
+            if app:
+                try:
+                    string = indent + "app.name='%s' " % app.name
+                except (LookupError, RuntimeError):
+                    string = indent + "app.name='(exception getting name)' "
+            else:
+                string = indent + "app=None "
     else:
         string = indent
 
diff --git a/src/orca/event_manager.py b/src/orca/event_manager.py
index 042f45a..625e16e 100644
--- a/src/orca/event_manager.py
+++ b/src/orca/event_manager.py
@@ -507,6 +507,7 @@ class EventManager:
             return orca_state.activeScript
 
         script = None
+        app = None
         try:
             app = event.host_application or event.source.getApplication()
             if app and app.getState().contains(pyatspi.STATE_DEFUNCT):
@@ -517,8 +518,12 @@ class EventManager:
             msg = 'WARNING: Exception when getting script for event.'
             debug.println(debug.LEVEL_WARNING, msg)
         else:
+            msg = 'INFO: Getting script for %s from %s' % (event.type, app)
+            debug.println(debug.LEVEL_INFO, msg)
             script = _scriptManager.getScript(app, event.source)
 
+        msg = 'INFO: Script for %s from %s is %s' % (event.type, app, script)
+        debug.println(debug.LEVEL_INFO, msg)
         return script
 
     def _isActivatableEvent(self, event, script=None):
@@ -634,9 +639,10 @@ class EventManager:
 
         script = self._getScriptForEvent(event)
         if not script:
+            msg = 'ERROR: Could not get script for %s' % event
+            debug.println(debug.LEVEL_INFO, msg)
             return
 
-        debug.println(debug.LEVEL_FINEST, "Script for event: %s" % script.name)
         setNewActiveScript, reason = self._isActivatableEvent(event, script)
         if setNewActiveScript:
             try:
diff --git a/src/orca/script_utilities.py b/src/orca/script_utilities.py
index 2458a36..dced366 100644
--- a/src/orca/script_utilities.py
+++ b/src/orca/script_utilities.py
@@ -2898,7 +2898,7 @@ class Utilities:
                          pyatspi.ROLE_EMBEDDED,
                          pyatspi.ROLE_WINDOW,
                          pyatspi.ROLE_FRAME]
-        if obj.getIndexInParent() == -1 and role not in topLevelRoles:
+        if index == -1 and role not in topLevelRoles:
             debug.println(debug.LEVEL_INFO, "ZOMBIE: %s's index is -1" % obj)
             return True
         if state.contains(pyatspi.STATE_DEFUNCT):
diff --git a/src/orca/scripts/toolkits/Gecko/script.py b/src/orca/scripts/toolkits/Gecko/script.py
index b97429d..6497a18 100644
--- a/src/orca/scripts/toolkits/Gecko/script.py
+++ b/src/orca/scripts/toolkits/Gecko/script.py
@@ -268,6 +268,16 @@ class Script(web.Script):
         debug.println(debug.LEVEL_INFO, msg)
         default.Script.onTextSelectionChanged(self, event)
 
+    def onWindowActivated(self, event):
+        """Callback for window:activate accessibility events."""
+
+        if super().onWindowActivated(event):
+            return
+
+        msg = "GECKO: Passing along event to default script"
+        debug.println(debug.LEVEL_INFO, msg)
+        default.Script.onWindowActivated(self, event)
+
     def onWindowDeactivated(self, event):
         """Callback for window:deactivate accessibility events."""
 
diff --git a/src/orca/scripts/web/script.py b/src/orca/scripts/web/script.py
index 52569a2..de89ea6 100644
--- a/src/orca/scripts/web/script.py
+++ b/src/orca/scripts/web/script.py
@@ -967,6 +967,8 @@ class Script(default.Script):
             return False
 
         if oldFocus and self.utilities.isZombie(oldFocus):
+            msg = "WEB: Old focus is Zombie: %s. Clearing oldFocus." % oldFocus
+            debug.println(debug.LEVEL_INFO, msg)
             oldFocus = None
 
         caretOffset = 0
@@ -1257,6 +1259,10 @@ class Script(default.Script):
             msg = "WEB: Clearing structural navigation cache for %s" % document
             debug.println(debug.LEVEL_INFO, msg)
             self.structuralNavigation.clearCache(document)
+        else:
+            msg = "WEB: Event source is not in document content"
+            debug.println(debug.LEVEL_INFO, msg)
+            return False
 
         if self.utilities.handleAsLiveRegion(event):
             msg = "WEB: Event to be handled as live region"
@@ -1462,6 +1468,11 @@ class Script(default.Script):
     def onTextDeleted(self, event):
         """Callback for object:text-changed:delete accessibility events."""
 
+        if self.utilities.isZombie(event.source):
+            msg = "WEB: Event source is Zombie"
+            debug.println(debug.LEVEL_INFO, msg)
+            return True
+
         if self.utilities.eventIsStatusBarNoise(event):
             msg = "WEB: Ignoring event believed to be status bar noise"
             debug.println(debug.LEVEL_INFO, msg)
@@ -1508,6 +1519,11 @@ class Script(default.Script):
     def onTextInserted(self, event):
         """Callback for object:text-changed:insert accessibility events."""
 
+        if self.utilities.isZombie(event.source):
+            msg = "WEB: Event source is Zombie"
+            debug.println(debug.LEVEL_INFO, msg)
+            return True
+
         if self.utilities.eventIsStatusBarNoise(event):
             msg = "WEB: Ignoring event believed to be status bar noise"
             debug.println(debug.LEVEL_INFO, msg)
@@ -1616,6 +1632,11 @@ class Script(default.Script):
 
         return False
 
+    def onWindowActivated(self, event):
+        """Callback for window:activate accessibility events."""
+
+        return False
+
     def onWindowDeactivated(self, event):
         """Callback for window:deactivate accessibility events."""
 
diff --git a/src/orca/scripts/web/script_utilities.py b/src/orca/scripts/web/script_utilities.py
index 529bb15..fb74b80 100644
--- a/src/orca/scripts/web/script_utilities.py
+++ b/src/orca/scripts/web/script_utilities.py
@@ -2111,7 +2111,13 @@ class Utilities(script_utilities.Utilities):
 
         eType = event.type
         if eType.startswith("object:text-") or eType.endswith("accessible-name"):
-            return event.source.getRole() == pyatspi.ROLE_STATUS_BAR
+            try:
+                role = event.source.getRole()
+            except:
+                msg = "WEB: Exception getting role for %s" % event.source
+                debug.println(debug.LEVEL_INFO, msg)
+            else:
+                return role == pyatspi.ROLE_STATUS_BAR
 
         return False
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]