Fix SAPI5 Audio Ducking Crash on Slow startup (#13699)
Fixes #13694
Summary of the issue:
NVDA start up is slow.
Speech is announced during start up to warn the user that start up is slow.
If using SAPI5 and audioducking is enabled, SAPI5 will try to duck the audio using wx callbacks
The wxWidgets App has not beeing initialized, so the callback fails and NVDA crashes.
Description of how this pull request fixes the issue:
Throw a known exception if NVDA is not ready when callLater is called.
If this exception occurs when audio ducking, force audio ducking to unduck immediately instead of delay
Testing strategy:
Manual testing:
Using NVDA 2022.1rc1 with audio ducking enabled and SAPI5.
emulate a slow start up and reproduce the crash.
Using a try build from this PR with audio ducking enabled and SAPI5.
emulate a slow start up.
Note that the warning message that announces that NVDA start up is slow doesn't duck audio
Note that NVDA starts successfully
Confirm that audio ducking works as expected once NVDA has started
Note the following log
WARNING - mathPres.initialize (12:46:35.192) - MainThread (6344):
MathPlayer 4 not available
DEBUGWARNING - core.main (12:46:40.207) - MainThread (6344):
Slow starting core (6.88 sec)
IO - speech.speech.speak (12:46:40.207) - MainThread (6344):
Speaking [LangChangeCommand ('en_US'), 'Loading NVDA. Please wait...']
DEBUGWARNING - characterProcessing._getSpeechSymbolsForLocale (12:46:40.208) - MainThread (6344):
No CLDR data for locale en_US
DEBUGWARNING - synthDrivers.sapi5.SynthDriver.speak (12:46:40.344) - MainThread (6344):
Unsupported speech command: LangChangeCommand ('en_US')
DEBUGWARNING - audioDucking._unensureDucked (12:46:40.349) - MainThread (6344):
wx App not initialized, cannot delay audio un-duck
INFO - core.main (12:46:40.349) - MainThread (6344):
Using wx version 4.1.1 msw (phoenix) wxWidgets 3.1.5 with six version 1.16.0