UtteranceQueue reaches attemptToAnnounce, we call voicingManager.announce. Since we haven't clicked in the simulation yet we get a SpeechSynthesisErrorEvent with error "not-allowed".
This error immediately triggers the end event, and we call handleSpeechSynthesisEnd.
This emits the endSpeakingEmitter.
A listener on this Emitter in VoicingToolbarItem.js calls voicingManager.cancel() which eventually clears the UtteranceQueue.
Then we continue in UtteranceQueue.attemptToAnnounce to try to remove the utterance from the queue even though the queue is empty.
I like the assertion in removeUtterance, but we need to be more graceful after calling attemptToAnnounce.
See https://github.com/phetsims/joist/issues/752#issuecomment-1015639358. To reproduce, fuzz a sim that supports voicing and do not click into the simulation. Description of the stack that causes this:
end
event, and we callhandleSpeechSynthesisEnd
.endSpeakingEmitter
.I like the assertion in
removeUtterance
, but we need to be more graceful after callingattemptToAnnounce
.