Bug 239816 - [iOS] Web Speech API doesn't work in WKWebView, but webkitSpeechRecognition is still exposed
Summary: [iOS] Web Speech API doesn't work in WKWebView, but webkitSpeechRecognition i...
Status: RESOLVED WORKSFORME
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit API (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-04-27 11:53 PDT by Ali Juma
Modified: 2022-08-02 07:16 PDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ali Juma 2022-04-27 11:53:02 PDT
The Web Speech API is available in Safari on iOS, but is not enabled for other WKWebView embedders. This means that sites that use the Web Speech API work in Safari on iOS but not in other browsers.

Please consider enabling this API more generally so that these sites work in all iOS browsers.

I've also filed FB9998082 for this request.
Comment 1 Alexey Proskuryakov 2022-04-29 16:07:55 PDT
rdar://92408768
Comment 2 Ali Juma 2022-06-21 08:38:33 PDT
The current state in WKWebView is very confusing for web developers using feature detection, since webkitSpeechRecognition is exposed on window, but doesn't work (the permission prompt never appears). Here's a test page that works in Safari on iOS, but not on any other browser on iOS: https://www.google.com/intl/en/chrome/demos/speech.html
Comment 3 Sihui Liu 2022-08-01 23:01:43 PDT
Hi Ali,

WebKit uses Speech framework for recognition, so your app might need to add NSSpeechRecognitionUsageDescription: https://developer.apple.com/documentation/speech/asking_permission_to_use_speech_recognition?language=objc.

Did you already do that?
Comment 4 Sihui Liu 2022-08-01 23:10:56 PDT
or if you are a website developer... I think we will throw error when the app cannot prompt (e.g. due to missing the keyword), do you see the error? Or it's just nothing?

The API should work in WebKit app.
Comment 5 Ali Juma 2022-08-02 07:16:46 PDT
(In reply to Sihui Liu from comment #3)
> Hi Ali,
> 
> WebKit uses Speech framework for recognition, so your app might need to add
> NSSpeechRecognitionUsageDescription:
> https://developer.apple.com/documentation/speech/
> asking_permission_to_use_speech_recognition?language=objc.
> 
> Did you already do that?

Thanks! That explains why it isn't working.

> or if you are a website developer... I think we will throw error when the
> app cannot prompt (e.g. due to missing the keyword), do you see the error?
> Or it's just nothing?

Yes, we get a service-not-allowed error when trying to use the API.