aws / aws/aws-sdk-net

Unity WebGL Polly SynthesizeSpeechAsync does not work.

Open
#2,578 14 comments 1 reaction 0 assignees View on GitHub
bug module/unity needs-investigation p2 queued
Dominant language
C#
Stars
140
Forks
891
Avg merge
21h 51m
Merged PRs (30d)
10

Description

### Describe the bug

SynthesizeSpeechAsync method does not work in Unity WebGL builds. And returns a console error about stream being null.

### Expected Behavior

Getting a successful response.

### Current Behavior

```
WebGL.framework.js.gz:3 ArgumentNullException: Value cannot be null.
Parameter name: stream
at System.IO.StreamReader..ctor (System.IO.Stream stream, System.Text.Encoding encoding, System.Boolean detectEncodingFromByteOrderMarks, System.Int32 bufferSize, System.Boolean leaveOpen) [0x00000] in <00000000000000000000000000000000>:0
at System.IO.StreamReader..ctor (System.IO.Stream stream, System.Boolean detectEncodingFromByteOrderMarks) [0x00000] in <00000000000000000000000000000000>:0
at System.IO.StreamReader..ctor (System.IO.Stream stream) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Internal.RegionEndpointProviderV3..ctor () [0x00000] in <00000000000000000000000000000000>:0
at Amazon.RegionEndpoint.get_RegionEndpointProvider () [0x00000] in <00000000000000000000000000000000>:0
at Amazon.RegionEndpoint.get_InternedRegionEndpoint () [0x00000] in <00000000000000000000000000000000>:0
at Amazon.RegionEndpoint.GetEndpointForService (System.String serviceName, Amazon.Internal.GetEndpointForServiceOptions options) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.Auth.AWS4Signer.DetermineSigningRegion (Amazon.Runtime.IClientConfig clientConfig, System.String serviceName, Amazon.RegionEndpoint alternateEndpoint, Amazon.Runtime.Internal.IRequest request) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.Auth.AWS4Signer.SignRequest (Amazon.Runtime.Internal.IRequest request, Amazon.Runtime.IClientConfig clientConfig, Amazon.Runtime.Internal.Util.RequestMetrics metrics, System.String awsAccessKeyId, System.String awsSecretAccessKey) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.Auth.AWS4Signer.Sign (Amazon.Runtime.Internal.IRequest request, Amazon.Runtime.IClientConfig clientConfig, Amazon.Runtime.Internal.Util.RequestMetrics metrics, System.String awsAccessKeyId, System.String awsSecretAccessKey) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.Auth.AWS4Signer.Sign (Amazon.Runtime.Internal.IRequest request, Amazon.Runtime.IClientConfig clientConfig, Amazon.Runtime.Internal.Util.RequestMetrics metrics, Amazon.Runtime.ImmutableCredentials credentials) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.Auth.AbstractAWSSigner.SignAsync (Amazon.Runtime.Internal.IRequest request, Amazon.Runtime.IClientConfig clientConfig, Amazon.Runtime.Internal.Util.RequestMetrics metrics, Amazon.Runtime.ImmutableCredentials credentials, System.Threading.CancellationToken token) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.Signer.SignRequestAsync (Amazon.Runtime.IRequestContext requestContext) [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.Signer.SignRequestAsync (Amazon.Runtime.IRequestContext requestContext) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.Signer.PreInvokeAsync (Amazon.Runtime.IExecutionContext executionContext) [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.Signer.PreInvokeAsync (Amazon.Runtime.IExecutionContext executionContext) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.Signer.InvokeAsync[T] (Amazon.Runtime.IExecutionContext executionContext) [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.Signer.InvokeAsync[T] (Amazon.Runtime.IExecutionContext executionContext) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.PipelineHandler.InvokeAsync[T] (Amazon.Runtime.IExecutionContext executionContext) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.EndpointDiscoveryHandler.<>n__0[T] (Amazon.Runtime.IExecutionContext executionContext) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.EndpointDiscoveryHandler.InvokeAsync[T] (Amazon.Runtime.IExecutionContext executionContext) [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.EndpointDiscoveryHandler.InvokeAsync[T] (Amazon.Runtime.IExecutionContext executionContext) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.PipelineHandler.InvokeAsync[T] (Amazon.Runtime.IExecutionContext executionContext) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.CredentialsRetriever.<>n__0[T] (Amazon.Runtime.IExecutionContext executionContext) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.CredentialsRetriever.InvokeAsync[T] (Amazon.Runtime.IExecutionContext executionContext) [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.CredentialsRetriever.InvokeAsync[T] (Amazon.Runtime.IExecutionContext executionContext) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.PipelineHandler.InvokeAsync[T] (Amazon.Runtime.IExecutionContext executionContext) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.RetryHandler.<>n__0[T] (Amazon.Runtime.IExecutionContext executionContext) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T] (Amazon.Runtime.IExecutionContext executionContext) [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.RetryHandler.InvokeAsync[T] (Amazon.Runtime.IExecutionContext executionContext) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.PipelineHandler.InvokeAsync[T] (Amazon.Runtime.IExecutionContext executionContext) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.CallbackHandler.<>n__0[T] (Amazon.Runtime.IExecutionContext executionContext) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T] (Amazon.Runtime.IExecutionContext executionContext) [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[TResult].Start[TStateMachine] (TStateMachine& stateMachine) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.CallbackHandler.InvokeAsync[T] (Amazon.Runtime.IExecutionContext executionContext) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.PipelineHandler.InvokeAsync[T] (Amazon.Runtime.IExecutionContext executionContext) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.BaseEndpointResolver.InvokeAsync[T] (Amazon.Runtime.IExecutionContext executionContext) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.PipelineHandler.InvokeAsync[T] (Amazon.Runtime.IExecutionContext executionContext) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.Marshaller.InvokeAsync[T] (Amazon.Runtime.IExecutionContext executionContext) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.PipelineHandler.InvokeAsync[T] (Amazon.Runtime.IExecutionContext executionContext) [0x00000] in <00000000000000000000000000000000>:0
at Amazon.Runtime.Internal.CallbackHand
```

### Reproduction Steps

Running the following code in Unity Editor and I can get back the audio result. However, the WebGL build will fail due to stream being null when the request is awaited.

```csharp
var credentials = new BasicAWSCredentials(akey, skey);
var client = new AmazonPollyClient(credentials: credentials, region: RegionEndpoint.EUCentral1);
var request = new SynthesizeSpeechRequest()
{
OutputFormat = OutputFormat.Mp3,
VoiceId = VoiceId.Arthur,
Text = "Testing Polly."
};

var response = await client.SynthesizeSpeechAsync(request);
```

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### AWS .NET SDK and/or Package version used

Unity 2021.3.5f1
AWSSDK.Core.3.7.105.10
AWSSDK.Polly.3.7.106.31

### Targeted .NET Platform

.NET Standard 2.1

### Operating System and version

Windows 11

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue in a Unity 2021.3.5f1 WebGL build using the shown AmazonPollyClient and SynthesizeSpeechAsync example, then compare it with the working Unity Editor run. Start by tracing the Amazon Polly request and the stream initialization around the reported RegionEndpointProvider stack trace; done means the WebGL build returns a successful speech response without the null-stream error.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, csharp, unity
Domain
cloud, game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.