Closed jessegreenberg closed 1 year ago
Work in progress but many manualInput unit tests are failing. We ran out of time to investigate fully.
Alright, the only reason the unit tests were failing is because we needed to remove the references to the currentlySpeakingUtterance
. I cleaned up the patch and pushed. Once I got the tests passing in the browser I saw them fail in precommit hooks a few times but then they started to pass and I don't know why. Not sure what to do about it but thought I would mention.
@zepumph would you like to review the final commit?
Perfect! Thank you. I do not think this needs cherry picking over in https://github.com/phetsims/ratio-and-proportion/issues/533, but this is definitely an improvement. Closing
Oops, it looks like we have a bug. Click the audio enabled button twice in a row. I think we need to mess with speakIgnoringEnabled
from this change.
Assertion Failed: Wrapper should be null, we should have received an end event to clear it before the next one.
I discussed with @jessegreenberg and we feel good. Closing
There seems to be one more race condition that we don't have a handle yet. I cannot reproduce, but it seems to be directly related to this issue.
I think I caused it like so:
The race condition is that the addToBack of "keyboard shortcuts" occurs before the startListener of preferences
, so it is cancelled, and then the startListener asserts out because it no longer has a speakingSpeechSynthesisUtteranceWrapper.
Here is some data from my runtime before I refresh and lose it:
From the console: synth is speaking, next utterance in the queue is the "keyboard" but speakingSpeechSynthesisUtteranceWrapper is null because we have already called cancel (clearing before we get the startListener callback).
Should we just be graceful in the startlistener? Or do we want to try to code around this case?
I just hit this while trying to fix https://github.com/phetsims/friction/issues/314. Here is the patch where this happens consistently. Just open and close the Preferences dialog a few times with a keyboard. Doing it quickly is important so that we get the cancel before we get the start listener.
Index: js/Sim.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/Sim.ts b/js/Sim.ts
--- a/js/Sim.ts (revision 1c4aa3e3661068b54d1e623a1c33cf134aa1188d)
+++ b/js/Sim.ts (date 1672849988249)
@@ -820,8 +820,10 @@
// pdom - modal dialogs should be the only readable content in the sim
this.setPDOMViewsVisible( false );
- // voicing - responses from Nodes hidden by the modal dialog should not voice.
+ // voicing - Responses from Nodes hidden by the modal dialog should not voice. Contents of the popup
+ // should voice if "Sim Voicing" is enabled.
this.setNonModalVoicingVisible( false );
+ this.topLayer.voicingVisibleProperty.value = voicingManager.voicingFullyEnabledProperty.value;
}
if ( popup.layout ) {
popup.layout( this.screenBoundsProperty.value! );
@@ -842,8 +844,9 @@
if ( this.modalNodeStack.length === 0 ) {
// After hiding all popups, Voicing becomes enabled for components in the simulation window only if
- // "Sim Voicing" switch is on.
+ // "Sim Voicing" switch is on. C
this.setNonModalVoicingVisible( voicingManager.voicingFullyEnabledProperty.value );
+ this.topLayer.voicingVisibleProperty.value = false;
// pdom - when the dialog is hidden, make all ScreenView content visible to assistive technology
this.setPDOMViewsVisible( true );
synth is speaking, next utterance in the queue is the "keyboard" but speakingSpeechSynthesisUtteranceWrapper is null because we have already called cancel (clearing before we get the startListener callback).
Thank you for investigating this, that makes sense. It looks like we aren't removing the startListener on cancel (if it hasn't fired yet), I think we should be doing that.
I believe that the above commit fixes this. I am not committing to the joist change above but used it to verify that the problem is gone. @zepumph can you please review this change?
Looks really good! I also cherry picked this into RAP 1.2 and confirmed it was fixed. Thanks!
We have a
pendingSpeechSynthesisUtteranceWrapper
- with a reference to an Utterance that was just used to speak, but we are waiting for the browser to actually speak it. And thecurrentlySpeakingUtterance
, a reference to the Utterance that is actually being spoken by the SpeechSynthesisAnnouncer.@zepumph and I think that we only need a reference to one at a time, and that managing both is really complicating things. See https://github.com/phetsims/ratio-and-proportion/issues/533 and the changes in that issue that would be so much simpler if there were only one Utterance to worry about.