Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.
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

Description

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

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions