Bug 220436 - Make SpeechRecognition permission error more informative
Summary: Make SpeechRecognition permission error more informative
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Sihui Liu
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-01-07 14:19 PST by Sihui Liu
Modified: 2021-01-11 14:30 PST (History)
2 users (show)

See Also:


Attachments
Patch (23.33 KB, patch)
2021-01-07 14:25 PST, Sihui Liu
no flags Details | Formatted Diff | Diff
Patch for landing (23.88 KB, patch)
2021-01-11 13:52 PST, Sihui Liu
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Sihui Liu 2021-01-07 14:19:08 PST
...
Comment 1 Sihui Liu 2021-01-07 14:25:21 PST
Created attachment 417211 [details]
Patch
Comment 2 youenn fablet 2021-01-08 00:29:06 PST
Comment on attachment 417211 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=417211&action=review

> Source/WebKit/ChangeLog:9
> +        boolean value.

For debug purposes, it might be good to add release logging for each error case so that we get the information in sysdiagnose.

> Source/WebKit/UIProcess/SpeechRecognitionPermissionManager.cpp:78
> +void SpeechRecognitionPermissionManager::request(const String& lang, const WebCore::ClientOrigin& origin, CompletionHandler<void(Optional<WebCore::SpeechRecognitionError>)>&& completiontHandler)

Optional<WebCore::SpeechRecognitionError>&& here and elsewhere

> Source/WebKit/UIProcess/SpeechRecognitionPermissionManager.cpp:110
>          m_speechRecognitionServiceCheck = CheckResult::Granted;

We do not need to compute m_microphoneCheck and m_speechRecognitionServiceCheck if mockCaptureDevicesEnabled is true.
We could write it as:
if (mockCaptureDevicesEnabled) {
    m_microphoneCheck = CheckResult::Granted;
    ...
} else {
    m_microphoneCheck = computeMicrophoneAccess();
    if (m_microphoneCheck == CheckResult::Denied) { 
        ...
        return;
    }
    ...
}

> Source/WebKit/UIProcess/SpeechRecognitionPermissionManager.cpp:124
>      if (!mockCaptureDevicesEnabled && m_speechRecognitionServiceCheck != CheckResult::Denied) {

We no longer need m_speechRecognitionServiceCheck != CheckResult::Denied

> Source/WebKit/UIProcess/SpeechRecognitionServer.cpp:77
>              sendUpdate(identifier, WebCore::SpeechRecognitionUpdateType::Error, error);

WTFMove(error)

> Source/WebKit/UIProcess/SpeechRecognitionServer.h:48
> +using SpeechRecognitionPermissionChecker = Function<void(const String&, const WebCore::ClientOrigin&, CompletionHandler<void(Optional<WebCore::SpeechRecognitionError>)>&&)>;

Optional<WebCore::SpeechRecognitionError>&&
Comment 3 Sihui Liu 2021-01-11 13:52:47 PST
Created attachment 417409 [details]
Patch for landing
Comment 4 EWS 2021-01-11 14:29:27 PST
Committed r271381: <https://trac.webkit.org/changeset/271381>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 417409 [details].
Comment 5 Radar WebKit Bug Importer 2021-01-11 14:30:15 PST
<rdar://problem/73014001>