Skip to content

Commit

Permalink
[Merge M101]: Fix crash when stopping speech recognition before it ha…
Browse files Browse the repository at this point in the history
…s initialized

To reproduce the crash:
1. Turn on Dictation
2. Focus a text field
3. Press search + D in rapid succession over and over

The reason for the crash is that we are calling
CrosSpeechRecognitionRecognizerImpl::MarkDone [1] when
`cros_soda_client_->IsInitialized()` is false. To fix this issue, let's
return early if `cros_soda_client_->IsInitialized()` returns false.

(cherry picked from commit 5d7f89a)

AX-Relnotes: N/A
Bug: 1311847
Change-Id: I372fd71f9a86564bebbd19d61a973cc11ad7b76d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3564961
Reviewed-by: Rob Schonberger <robsc@chromium.org>
Commit-Queue: Akihiro Ota <akihiroota@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#989200}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3582856
Reviewed-by: Evan Liu <evliu@google.com>
Cr-Commit-Position: refs/branch-heads/4951@{#854}
Cr-Branched-From: 27de622-refs/heads/main@{#982481}
  • Loading branch information
akihiroota87 authored and Chromium LUCI CQ committed Apr 18, 2022
1 parent df72299 commit bb9333d
Showing 1 changed file with 8 additions and 3 deletions.
Expand Up @@ -112,13 +112,18 @@ void CrosSpeechRecognitionRecognizerImpl::
}

void CrosSpeechRecognitionRecognizerImpl::MarkDone() {
if (cros_soda_client_ == nullptr || !cros_soda_client_->IsInitialized()) {
LOG(DFATAL)
<< "No soda client or soda client is not initialized, stopping.";
if (cros_soda_client_ == nullptr) {
LOG(DFATAL) << "No soda client, stopping.";
mojo::ReportBadMessage(kNoClientError);
return;
}

if (!cros_soda_client_->IsInitialized()) {
// Speech recognition was stopped before it could initialize. Return early
// in this case.
return;
}

cros_soda_client_->MarkDone();
}

Expand Down

0 comments on commit bb9333d

Please sign in to comment.