Fix SAPI5 Audio Ducking Crash on Slow startup#13699
Conversation
| # If the wx.App has not been initialized, audio ducking callbacks | ||
| # will fail as they rely on wx.CallLater/wx.CallAfter | ||
| _isAudioDuckingSupported &= wx.GetApp() is not None |
There was a problem hiding this comment.
Perhaps this should happen in / also in core.callLater? Here it is a bit removed from the core problem, which might be fine for a quick work-around for this issue / release, but longer term this could happen in other scenarios.
Perhaps as a follow up we should ensure that all usages of wx.Calllater are converted to go via `core.callLater
There was a problem hiding this comment.
What would be the suggested behaviour when we cannot continue in core.callLater? Log an exception?
I support those 2 pieces of work for 2022.2
There was a problem hiding this comment.
Yes, I think log then raise an exception to notify the caller. We'd convert all internal usages of wx.CallLater to use core.callLater and handle the exception. Then later we can consider an implementation that can work without wx.
There was a problem hiding this comment.
I'd avoid raising an exception: wx raising an exception here is causing the crash.
I think this is because the exception is raised before our exception handling is initialized.
Raising an exception here will not be an improvement of behaviour.
There was a problem hiding this comment.
I've created a PR here to start on this: #13701
I'd like to get this into rc as a priority first
My testing does not confirm this. If the message about startup being slow is announced during startup audio ducking remains non functional afterwards. Looking at the code |
This comment was marked as off-topic.
This comment was marked as off-topic.
|
@lukaszgo1 - a simpler and safer approach (that still allow the un-duck to happen) is being used instead now |
feerrenrut
left a comment
There was a problem hiding this comment.
Generally looks good. But I'm not familiar enough with the expectations of the audioDucking system. I see reference counting going on, and there is _ensureDucked and _unensureDucked, private methods that look like they ought to be paired. Exiting _unensureDucked without doing the task seems like it could lead to an imbalanced reference count.
You'll need to verify the logic here.
I notice that callLater is only required if delay is True, perhaps it would be better to do it immediately if delay is impossible.
feerrenrut
left a comment
There was a problem hiding this comment.
Sorry, I misread this. I see now that on exception the unducking continues, just without a delay.
Link to issue number:
Fixes #13694
Summary of the issue:
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.
Using a try build from this PR with audio ducking enabled and SAPI5.
Known issues with pull request:
None
Change log entries:
Fixes an unreleased regression
Code Review Checklist:
e