Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Race condition between stopListening() and command handling on Chrome Mobile #187

Open
korneliuszw opened this issue Sep 7, 2023 · 1 comment

Comments

@korneliuszw
Copy link

Hello,
I am using this library to create voice navigation for my app (v3.10.0 from npm). So far it is great.
However, I encountered a race condition when using stopListening() with continuous mode on Chrome Android.
I have a command called "stop" which stops voice recognition using SpeechRecognition.stopListening() (abortListening doesn't help). During this stopListening() call, an onend is called from SpeechRecognition API (because of chrome limitations) and resets listening. In result, despite calling stopListening(), the recognition is still working.

Reproduction (say stop right after start):
https://codesandbox.io/s/upbeat-lucy-sxjlx6?file=/src/App.js

@korneliuszw
Copy link
Author

Workaround for this issue

const recognition = SpeechRecognition.getRecognition()
if (recognition) recognition.continuous = false
SpeechRecognition.stopListening()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant