Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

[Bug] Android TextToSpeech.SpeakAsync() hangs if cancelled immediately #1894

Closed
borigas opened this issue Oct 6, 2021 · 0 comments · Fixed by #1895
Closed

[Bug] Android TextToSpeech.SpeakAsync() hangs if cancelled immediately #1894

borigas opened this issue Oct 6, 2021 · 0 comments · Fixed by #1895
Labels
bug Something isn't working
Milestone

Comments

@borigas
Copy link
Contributor

borigas commented Oct 6, 2021

Description

On Android, if you cancel the CancellationToken provided to SpeakAsync after Initialize but the speech actually starts (~0.5s window on my slow test device), SpeakAsync will correctly not speak, but will never return

Steps to Reproduce

var cts = new CancellationTokenSource();

var cancelTask = Task.Run(() =>
{
    // Have to wait long enough for Initialize to complete, but not long enough for it to start speaking
    Thread.Sleep(100);
    cts2.Cancel();
});

try
{
    // Hangs here
    await TextToSpeech.SpeakAsync(Text, options, cts2.Token);
}
catch (Exception ex)
{
    Console.WriteLine(ex.ToString());
}
Console.WriteLine("Never gets here");

Expected Behavior

It shouldn't hang

Actual Behavior

It hangs

Basic Information

  • Version with issue: Reproed with latest from main
  • Last known good version:
  • IDE: VS 2019 16.10.3
  • Platform Target Frameworks:
    • Android: 30
@borigas borigas added the bug Something isn't working label Oct 6, 2021
@jamesmontemagno jamesmontemagno added this to the 1.7.1 milestone Oct 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants