NVDA Crashes in PowerPoint
Reported by netblue on 2014-09-22 16:33 Hi when closing PowerPoint 2013, without saving changes to a document, NVDA, does not respond until it is restarted. I am using Office 2013 32 bits PRO Spanish version on windows 7 32 bits.
Defect in the select all command in Spanish versions of MS Office applications When using the select all text shortcut control+e for Spanish version of MS applications NVDA just announces the current text alignment. And when using control+a NVDA says all selected, but nothing is selected and the open dialog of the application is activated. Using Office 2013 PRO Spanish.
Attachment NVDA PowerPoint Crash.txt added by netblue on 2014-09-22 16:34 Description:
Comment 1 by netblue on 2014-09-29 15:53 Hi when closing PowerPoint 2013, without saving changes to a document, NVDA, does not respond until it is restarted. This does not happen with nvda 2014.2 only 2014.3 and master and next. I am using Office 2013 32 bits PRO Spanish version on windows 7 32 bits. I had to chainge ticket this way because i could not do it any other way.
Comment 2 by netblue on 2014-10-27 13:55 Hi when closing PowerPoint 2013, without saving changes to a document, NVDA, does not respond until it is restarted. I am using Office 2013 32 bits PRO Spanish version on windows 7 32 bits. I have tried the latest snapshot and the problem is the same. This problem does not exist with previos vershions of nvda.
Comment 3 by msedmak on 2015-06-22 23:10 I have also seen this on the latest nvda 2015.2 Today the hang/crash corrupted my nuance volcalizer driver. So this is occasionally worse than just a simple hang.
Copying @tech55541, who reported the duplicate #5816.
it'd be great if those experiencing this can provide more detail, since we've never encountered it. Does NVDA actually crash or does it just "freeze"? If it crashes, it should normally restart itself, but it may not in some cases. A log file with log level set to input/output may be enlightening. See this article for details about how to provide a log file.
I can't reproduce this in Windows 10, but it seems all those who reported this were running Windows 7, so we should try in Windows 7.
I just tried to reproduce the crash, and I succeeded in crashing NVDA again in the exact same way I described in my earlier ticket. The only difference is that I restarted NVDA with add-ons disabled before attempting, so it's definitely a bug somewhere in NVDA core.
I have tried to consolodate the information we have spread across several tickets:
netblue (info from #4479):
Office 2013 32 bits PRO Spanish version windows 7 32 bit
Closing PowerPoint 2013, without saving changes to a document causes crash
What language is windows in?
Laughingthunder (most info from #6331):
Windows 7 Pro SP1 (64-bit)
Open via Run "powerpnt" escape to dismiss the start screen (leaving a blank presentation) Alt+F, X to exit
On #4479: Tried recently (presumably 2016.3??) with add-ons disabled, still crashes
tech55541 (info from #5816):
PowerPoint 2013 Windows 7 Professional
Mentioned it has happened when Firefox is open or when MS Outlook 2013 is open
Trying to reproduce
Setup:
- Installed Windows 7 Home Premium on VMWare
- Installed MS Office 2013
- Installed nvda 2016.3
Attempt 1:
- NVDA running
- Open powerpoint
- dismiss "Activate Office" dialog (click the close button)
- Open "Blank Presentation"
- Click the close button
- Result: No crash
Attempt 2:
- Open via Run "powerpnt"
- escape to dismiss the start screen (leaving a blank presentation)
- Alt+F, X to exit
- Result: No crash
Changed setup:
- Installed FireFox 49.0.1
Attempt 3:
- Tried both previous repro steps with Firefox running.
- Result: No crash
Attempt 4:
- Tried both previous repro steps with Firefox and MS outlook 2013 running
- Result: No crash
Attempt 5:
- Tried adding some information to the blank presentation before closing in order to trigger the "Save changes" dialog.
- Selected "Dont save"
- Result: No crash
Attempt 6:
- Same as "attempt 5", but selected save, and saved the presentation.
- Result: No crash
Tried using another machine:
- Windows 7 Pro 64 bit With SP1
- NVDA 2016.3
- MS Office 2013
Attempt 1:
- Open PowerPoint from start menu
- This copy is registered so no prompt to dismiss
- Select blank presentation
- Type something to trigger save dialog
- Alt+F, x to exit
- Result:
- NVDA stops responding
- After several minutes NVDA restarts
Differences:
- Windows 7 Pro?
- SP1 installed?
- Office is registered?
After inspecting the log it seems like NVDA is not crashing. There are several core freezes that take about 2 min. During this time I noticed the following processes were still running (by watching the task manager process list):
- powerpnt.exe
- nvda.exe
- nvda_eoaProxy.exe
- nvdaHelperRemoteLoader.exe
When nvda started working again powerpnt.exe disappeared from the task manager process list.
NVDA log attached: nvda.log.txt
The log indicates that the issue is caused by the Release method of IUnknown in comtypes\__init__.py.
Since this issue seems to be the result of memory cleanup, attempted to disable the garbage collector. Called gc.disable() from the nvda python console before exiting from PowerPoint, this did not stop the freeze.
To confirm it is objects inside doPreGainFocus() (called from executeEvent()) that are causing the freeze (during their destruction), I added the oldForeground and oldFocus objects to an array on each call to doPreGainFocus(). This stopped the freeze.
To try to get an idea what kind of object is causing the freeze, I added some logging to the beginning of newCpbDel() like so: log.info("Deleting obj %r" % self)
Got:
INFO - comtypesMonkeyPatches.newCpbDel (15:06:53):
Deleting obj <POINTER(IUIAutomationElement) ptr=0x42fca90 at 52c4df0>
This indicates its to do with the UIAHandler. To confirm, run an unmodified NVDA then before exiting PowerPoint entered the following into the nvda python console which stops the freeze:
import UIAHandler
UIAHandler.terminate()
To try to get more information about the object, tried using devInfo on class UIA. Since this will put A LOT of information in the log, I protected this with a global doTheDebugLogging that I could toggle from the nvda python console.
if doTheDebugLogging and isinstance(self, UIAHandler.IUIAutomationElement):
obj=NVDAObjects.UIA.UIA(UIAElement=self)
log.info("\n".join(obj.devInfo))
Despite a large number of errors in the log for objects that dont support the above, the following log snippet might be enough to understand some more:
INFO - comtypesMonkeyPatches.newCpbDel (16:15:23):
name: None
role: ROLE_EDITABLETEXT
states: STATE_FOCUSABLE, STATE_READONLY
isFocusable: True
hasFocus: 0
Python object: <NVDAObjects.Dynamic_UIAEditWindowNVDAObject object at 0x05435870>
Python class mro: (<class 'NVDAObjects.Dynamic_UIAEditWindowNVDAObject'>, <class 'NVDAObjects.UIA.UIA'>, <class 'NVDAObjects.window.edit.Edit'>, <class 'NVDAObjects.behaviors.EditableTextWithAutoSelectDetection'>, <class 'NVDAObjects.behaviors.EditableText'>, <class 'editableText.EditableText'>, <class 'NVDAObjects.window.Window'>, <class 'NVDAObjects.NVDAObject'>, <class 'baseObject.ScriptableObject'>, <class 'baseObject.AutoPropertyObject'>, <type 'object'>)
description: ''
location: (427, 492, 86, 13)
value: u'69'
appModule: <'appModuleHandler' (appName u'taskmgr', process ID 3572) at address 5381890>
appModule.productName: exception: processHandle is 0
appModule.productVersion: exception: processHandle is 0
TextInfo: <class 'NVDAObjects.NVDAObjectTextInfo'>
windowHandle: 656456
windowClassName: u'Edit'
windowControlID: 1038
windowStyle: 1342179458
windowThreadID: 1968
windowText: u'69'
displayText: u''
UIAElement: <POINTER(IUIAutomationElement) ptr=0x433ed20 at 5438e90>
UIA automationID: 1038
UIA frameworkID: Win32
UIA runtimeID: (42, 656456)
UIA providerDescription: [pid:6756,hwnd:0xA0448 Annotation:Microsoft: Annotation Proxy (unmanaged:UIAutomationCore.dll); Main:Microsoft: MSAA Proxy (unmanaged:UIAutomationCore.dll); Hwnd(parent link):Microsoft: HWND Proxy (unmanaged:UIAutomationCore.dll)]
UIA className: Edit
ERROR - stderr (16:15:23):
Exception
ERROR - stderr (16:15:23):
_ctypes
DEBUGWARNING - watchdog._watcher (16:15:23):
Trying to recover from freeze, core stack:
File "nvda.pyw", line 191, in <module>
File "core.pyc", line 385, in main
File "wx\_core.pyc", line 8657, in MainLoop
File "wx\_core.pyc", line 7952, in MainLoop
File "core.pyc", line 356, in Notify
File "queueHandler.pyc", line 83, in pumpAll
File "queueHandler.pyc", line 50, in flushQueue
File "eventHandler.pyc", line 61, in _queueEventCallback
File "eventHandler.pyc", line 138, in executeEvent
File "comtypesMonkeyPatches.pyc", line 60, in newCpbDel
File "baseObject.pyc", line 34, in __get__
File "baseObject.pyc", line 110, in _getPropertyViaCache
File "NVDAObjects\UIA\__init__.pyc", line 675, in _get_devInfo
File "baseObject.pyc", line 34, in __get__
File "baseObject.pyc", line 110, in _getPropertyViaCache
File "NVDAObjects\window\__init__.pyc", line 338, in _get_devInfo
File "baseObject.pyc", line 34, in __get__
File "baseObject.pyc", line 110, in _getPropertyViaCache
File "NVDAObjects\__init__.pyc", line 985, in _get_devInfo
File "baseObject.pyc", line 34, in __get__
File "baseObject.pyc", line 110, in _getPropertyViaCache
File "NVDAObjects\UIA\__init__.pyc", line 706, in _get_name
File "comtypes\__init__.pyc", line 266, in __getattr__
The concerning thing about this info is that this UIA element was part of Task Manager, not PowerPoint. That either means this isn't actually the problematic object (and/or calling devInfo is causing an additional, unrelated freeze) or UIA core is actually freezing for some reason and would freeze for any UIA call we make.
If I return True on the first line of the isBadUIAWindow method in the class AppModule in nvda/source/appModules/powerpnt.py then the freeze goes away.
When the debug logging is in place I'm getting errors from std::error. This does not happen when I remove the logging.
The previous log message indicates that the object is in task manager, it seems unlikely it is that object that is causing the problem. In order to minimize the interactions logging through devInfo might be having swapped to just output the following information. This is in newCpbDel in comtypesMonkeyPatches.py.
import comInterfaces.UIAutomationClient
if doTheDebugLogging and isinstance(self, comInterfaces.UIAutomationClient.IUIAutomationElement):
log.info("newCpbDel: CurrentProcessID: {} CurrentName: {} CurrentControlType{}".format(self.CurrentProcessId, self.CurrentName, self.CurrentControlType))
In the following log powerpoint PID is 4796
IO - speech.speak (13:46:53):
Speaking [LangChangeCommand ('en_GB'), u'Presentation1 - PowerPoint unavailable']
ERROR - stderr (13:46:53):
Exception
ERROR - stderr (13:46:53):
_ctypes
ERROR - stderr (13:46:53):
.
ERROR - stderr (13:46:53):
COMError
ERROR - stderr (13:46:53):
:
ERROR - stderr (13:46:53):
(-2147467259, 'Unspecified error', (None, None, None, 0, None))
ERROR - stderr (13:46:53):
in
ERROR - stderr (13:46:53):
<bound method POINTER(IUIAutomationElement).__del__ of <POINTER(IUIAutomationElement) ptr=0x4377f38 at 54b8670>>
ERROR - stderr (13:46:53):
ignored
INFO - comtypesMonkeyPatches.newCpbDel (13:46:53):
newCpbDel: CurrentProcessID: 4796 CurrentName: CurrentControlType50033
IO - speech.speak (13:46:53):
Speaking [LangChangeCommand ('en_GB'), u'Microsoft PowerPoint dialog']
IO - speech.speak (13:46:53):
Speaking [LangChangeCommand ('en_GB'), u'Microsoft PowerPoint dialog Want to save your changes to Presentation1?']
IO - speech.speak (13:46:53):
Speaking [LangChangeCommand ('en_GB'), u'Save button ALT+S']
INFO - comtypesMonkeyPatches.newCpbDel (13:46:53):
newCpbDel: CurrentProcessID: 4796 CurrentName: Microsoft PowerPoint CurrentControlType50033
INFO - comtypesMonkeyPatches.newCpbDel (13:46:53):
newCpbDel: CurrentProcessID: 4796 CurrentName: None CurrentControlType50037
INFO - comtypesMonkeyPatches.newCpbDel (13:46:53):
newCpbDel: CurrentProcessID: 4796 CurrentName: None CurrentControlType50037
INFO - comtypesMonkeyPatches.newCpbDel (13:46:57):
newCpbDel: CurrentProcessID: 4796 CurrentName: CurrentControlType50033
INFO - comtypesMonkeyPatches.newCpbDel (13:46:57):
newCpbDel: CurrentProcessID: 4796 CurrentName: Don't Save CurrentControlType50000
DEBUGWARNING - IAccessibleHandler.accessibleObjectFromEvent (13:46:57):
oleacc.AccessibleObjectFromEvent with window 590462, objectID 95 and childID 0: [Error -2147467259] Unspecified error
IO - speech.speak (13:46:57):
Speaking [LangChangeCommand ('en_GB'), u"Don't Save button pressed ALT+n"]
INFO - comtypesMonkeyPatches.newCpbDel (13:46:57):
newCpbDel: CurrentProcessID: 568 CurrentName: Desktop CurrentControlType50033
INFO - comtypesMonkeyPatches.newCpbDel (13:47:00):
newCpbDel: CurrentProcessID: 3292 CurrentName: Start CurrentControlType50022
INFO - comtypesMonkeyPatches.newCpbDel (13:47:00):
newCpbDel: CurrentProcessID: 3292 CurrentName: Clock CurrentControlType50033
INFO - comtypesMonkeyPatches.newCpbDel (13:47:00):
newCpbDel: CurrentProcessID: 3292 CurrentName: Clock CurrentControlType50033
INFO - comtypesMonkeyPatches.newCpbDel (13:47:02):
newCpbDel: CurrentProcessID: 3292 CurrentName: Start menu CurrentControlType50033
DEBUGWARNING - watchdog._watcher (13:47:02):
Trying to recover from freeze, core stack:
File "nvda.pyw", line 191, in <module>
File "core.pyc", line 385, in main
File "wx\_core.pyc", line 8657, in MainLoop
File "wx\_core.pyc", line 7952, in MainLoop
File "core.pyc", line 356, in Notify
File "queueHandler.pyc", line 83, in pumpAll
File "queueHandler.pyc", line 50, in flushQueue
File "eventHandler.pyc", line 61, in _queueEventCallback
File "eventHandler.pyc", line 138, in executeEvent
File "comtypesMonkeyPatches.pyc", line 58, in newCpbDel
INFO - comtypesMonkeyPatches.newCpbDel (13:47:03):
newCpbDel: CurrentProcessID: 3292 CurrentName: None CurrentControlType50033
This doesn't seem to help a great deal, the object immediately before the freeze id not from powerpoint yet the issue only occurs when power point exits. One thing to note here is the exception, but this only seems to happen when there is extra logging added?
Managed to get a native stack trace during the freeze (I think). The stack includes newCpbDel and Release
Stack for PowerPoint during the freeze. Its hard to tell if the timing was right: powerpointMainThread.txt
Removing the line that registers for events in powerpnt.py see self._ppEApplicationConnectionPoint=comtypes.client._events._AdviseConnection(self._ppApplication,EApplication,sink) also resolves this issue.
It seems like there is a deadlock between an event coming from power point and releasing objects? This event may be to do with changing window focus as we swap from the save prompt back to the powerpoint window as it is closing.
Some further information, returning early from the following functions in powerpnt.py still resulted in the freeze occurring:
SlideShowNextSlideWindowSelectionChange
I have been trying to get some more info about the parameter values in the previously attached powerpointMainThread.txt file. I haven't been able to reproduce the same stack.
Thinking about this, I suspect what's happening is the following:
- We start handling a focus event. That means we're no longer pumping until we finish handling it.
- Soon after, PowerPoint fires a PowerPoint event on our sink. We're busy, so PowerPoint blocks waiting for us.
- As part of handling the focus event (1), a PowerPoint UIA object gets cleaned up.
- comtypes tries to Release the UIA element. UIA blocks waiting for PowerPoint.
- But PowerPoint is still waiting on our sink (2).
- Deadlock!
I can think of two ways of solving this:
- Try to make all UIA releases occur in a background thread. That would be quite tricky and ugly.
- Create our PowerPoint sink in a background thread and queue necessary stuff to our main thread from there.
I seem to have neglected this issue for too long. Given the costs to fix this, @jcsteh would you agree the priority should be lower? I am think this should be reduced to P2.
How confident are you of the explanation? I wonder if there is some way to prove that is the case. However with the amount of time that has been spent investigating this issue, it might be more pragmatic to attempt the fix rather than investigate.