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

How should we handle when SpeechSynthesis is not available? #73

Open
jessegreenberg opened this issue Apr 1, 2022 · 1 comment
Open
Assignees

Comments

@jessegreenberg
Copy link
Contributor

I found that it felt sketchy to have a getSynth() that could return null on a platform that doesn't support speech synthesis. We have some support for that case, but I think we rely on assertions a lot to guard against null pointer exceptions. In the wild, we wouldn't have assertions so we may want to be graceful. I added a couple of spots that checked if we had a synth before calling operations on it. Does this seem correct to you? I'd hate for the sim to break just because the platform doesn't have speech synthesis. For example, in the app, right?

Currently the only platform that does not support SpeechSynthesis is Android in a WebView. So correct, this could come up in the Android app, and it has! phetsims/qa#608

I think this should hard crash and that it is up to us to not make SpeechSynthesis requests unless we are confident the platform can handle it. I almost want to replace the assertion in getSynth with an Error, I want it to let us know loudly on platforms where we expect the synth to be available but is not.

I can see both sides of the argument though. Lets talk more if you still prefer it to be graceful.

@jessegreenberg jessegreenberg changed the title How should we handle platforms where SpeechSynthesis is not available? How should we handle when SpeechSynthesis is not available? Apr 1, 2022
@zepumph
Copy link
Member

zepumph commented Apr 7, 2022

This makes sense. I would prefer an Error to an assertion given your thoughts, but I still worry about getting this in production, in a case that QA hasn't tested or we don't support. Is it worth such a hard fail if we forget about a device?

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

No branches or pull requests

2 participants