IEvangelist / blazorators

This project converts TypeScript type declarations into C# representations, and use C# source generators to expose automatic JavaScript interop functionality.

Home Page:https://ievangelist.github.io/blazorators

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SpeechRecognition fails on firefox and crashed blazor application

taori opened this issue · comments

Unhandled exception rendering component: webkitSpeechRecognition is not defined

FireFox doesn't appear to support Speech Recognition at all. This is a limitation of that browser.

It might be a good idea to add this automated Can I Use URL to each API. Would that have been more helpful?

I tested this in FireFox and confirmed it doesn't work. I even tried navigating to about:config and search for recognition:

  • media.webspeech.recognition.enable
  • media.webspeech.recognition.force_enable

I set both of these to true, but it errors out.

I would check for undefined on webkitSpeechRecognition to begin with. Falling back to SpeechRecognition is fine, but the code is faulty and should crash in safari too, where SpeechRecognition is supported. One way or another using the library should produce an error instead of a js crash

You attempted to fallback to SpeechRecognition in a way that i recall used to work (a || b) but that crashes now. So the implementation in js would have to be slightly changed to check both webkitSpeechRecognition and SpeechRecognition on undefined and report a not supported error, similar to Geolocation providing feedback that the user has canceled the dialog.

I can look at this later and try submit a PR but busy with work atm.

Sounds good! Yes, I do think that we should report the error more accurately and not crash. Thanks for the feedback, and looking forward to reviewing a PR.

@all-contributors please add @taori for bug

How do i get the solution to build? I'm getting errors like this:

grafik

Hmmm, interesting. I have not witnessed errors like this before. What version of Visual Studio are you using? Are you doing a Debug build?

Microsoft Visual Studio Community 2022
Version 17.1.3
VisualStudio.17.Release/17.1.3+32328.378
Microsoft .NET Framework
Version 4.8.04084

Just trying to run Debug build on sample to verify my PR, yes

Could you create a PR, and let the build system here see if it runs into the same error?

That's really weird! I'm not sure why that is happening, maybe you could remove the MinVer packages from the projects for local testing?

Oddly enough i had to checkout again (fresh machine) and then debugging worked fine. Working on PR now.

Do my changes look wrong to you? It's not hitting the breakpoint(in blazor c# method, not js) for the error method or displaying errors.

https://github.com/IEvangelist/blazorators/compare/main...taori:bugfix-speech-recognition-crash-fix?expand=1

Do my changes look wrong to you? It's not hitting the breakpoint(in blazor c# method, not js) for the error method or displaying errors.

https://github.com/IEvangelist/blazorators/compare/main...taori:bugfix-speech-recognition-crash-fix?expand=1

Did you test it in the demo app on FireFox? I don't think that will work, as the callback is expecting an SpeechRecognitionErrorEvent object, not two string parameters.

I think you had the right idea to use the OnError callback, just create an object manually.

{ "error": "...", "message": "..." }