InvalidStateError: createEncodedStreams called again for a video receiver
- Dominant language
- TypeScript
- Stars
- 761
- Forks
- 474
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 2
Description
### What happened and what did you expect to happen?
We are seeing a high-volume unhandled error with `amazon-chime-sdk-js` `3.31.0`:
```
InvalidStateError: Failed to execute 'createEncodedStreams' on 'RTCRtpReceiver':
Encoded streams already created
```
Chromium sometimes reports `Encoded video streams already created`.
Our application does not call `createEncodedStreams()` directly. Source maps consistently resolve the error to:
```
DefaultEncodedTransformWorkerManager.setupTransform
DefaultEncodedTransformWorkerManager.setupVideoReceiverTransform
RTCPeerConnection.handleTrack
```
Our hypothesis is that a later `track` event calls `setupVideoReceiverTransform()` for a receiver whose legacy encoded streams were already created. The legacy `createEncodedStreams()` path does not appear to set `event.receiver.transform`, which `handleTrack()` uses to decide whether setup is needed.
Expected: SDK-managed renegotiation or repeated track events should not produce an unhandled exception.
We do not have a deterministic reproduction and have not established which SDK version introduced the behavior.
Potentially relevant:
- https://github.com/aws/amazon-chime-sdk-js/pull/3123
- https://github.com/aws/amazon-chime-sdk-js/pull/3131
- https://github.com/aws/amazon-chime-sdk-js/issues/3250 — a different `InvalidStateError`, but also during SDK-driven renegotiation through `DefaultTransceiverController`
### Have you reviewed our existing documentation?
- [x] GitHub [issues](https://github.com/aws/amazon-chime-sdk-js/issues)
- [x] FAQs [page](https://aws.github.io/amazon-chime-sdk-js/modules/faqs.html)
- [x] README [page](https://github.com/aws/amazon-chime-sdk-js#amazon-chime-sdk-for-javascript)
- [x] Feature-specific [guides](https://github.com/aws/amazon-chime-sdk-js#guides)
### Reproduction steps
We cannot reproduce this deterministically. Production occurrences consistently follow this sequence:
1. Join a video meeting using a Chromium version without `RTCRtpScriptTransform`.
2. The SDK performs an `AudioVideoUpdate`/renegotiation.
3. `SetRemoteDescriptionTask` produces a video `track` event.
4. The SDK logs `Applying video receiver transform to track ... not set after addTransceiver`.
5. `RTCRtpReceiver.createEncodedStreams()` throws because encoded streams were already created.
The error can occur shortly after joining or later in an established meeting.
### Amazon Chime SDK for JavaScript version
3.31.0
### What browsers are you seeing the problem on?
Google Chrome
### Browser version
Observed on Chrome 116, 128, and 138
### Meeting and Attendee ID Information.
Recent production examples (UTC):
| Timestamp | Meeting ID | Attendee ID | Chrome |
|---|---|---|---|
| 2026-09-03 14:30:26 | `377b53a1-e4d4-4d7d-b7bf-63c644d36404` | `c793ceb6-579b-f8b3-51c8-85b3dcd47aac` | 138 |
| 2026-09-03 14:12:37 | `4b237b85-64f3-46d9-b820-d3dd67046404` | `6b190b50-5dfb-cd92-8183-8ed2cb2d924c` | 116 |
| 2026-09-03 14:04:17 | `226dd810-375a-4b97-8c8a-eaedd9f36404` | `e6aa3ab7-b448-1d76-6fc7-e42bf8713812` | 116 |
| 2026-09-03 14:03:11 | `4a0b5401-a48d-4730-aa70-b3d7c3886404` | `4379430f-c628-2df3-5571-553c10549749` | 138 |
| 2026-09-03 13:58:25 | `30d4ad11-1eeb-4c00-8c1f-7e6a7a926404` | `71f8eb53-5d8a-cf65-9c2b-409107099842` | 138 |
### Browser console logs
epresentative breadcrumbs from the most recent occurrence (`377b53a1-e4d4-4d7d-b7bf-63c644d36404` / `c793ceb6-579b-f8b3-51c8-85b3dcd47aac`, Chrome 138):
```
2026-09-03T14:30:26.328Z [INFO] MeetingLogs - AudioVideoUpdate/377b53a1-e4d4-4d7d-b7bf-63c644d36404/c793ceb6-579b-f8b3-51c8-85b3dcd47aac/Timeout30000ms/UpdateSession/SetLocalDescriptionTask took 5 ms
2026-09-03T14:30:26.328Z [INFO] MeetingLogs - running task AudioVideoUpdate/377b53a1-e4d4-4d7d-b7bf-63c644d36404/c793ceb6-579b-f8b3-51c8-85b3dcd47aac/Timeout30000ms/UpdateSession/SubscribeAndReceiveSubscribeAckTask
2026-09-03T14:30:26.330Z [INFO] MeetingLogs - sending subscribe: {"attendeeId":"c793ceb6-579b-f8b3-51c8-85b3dcd47aac",...}
2026-09-03T14:30:26.375Z [INFO] MeetingLogs - running task AudioVideoUpdate/377b53a1-e4d4-4d7d-b7bf-63c644d36404/c793ceb6-579b-f8b3-51c8-85b3dcd47aac/Timeout30000ms/UpdateSession/SetRemoteDescriptionTask
2026-09-03T14:30:26.378Z [INFO] MeetingLogs - received track event: kind=video id=b0c6c3eb-3b57-4d5c-80db-a726019468df
2026-09-03T14:30:26.378Z [INFO] MeetingLogs - Applying video receiver transform to track b0c6c3eb-3b57-4d5c-80db-a726019468df not set after addTransceiver
```
Source-mapped stack:
```
DefaultEncodedTransformWorkerManager.setupTransform
src/encodedtransformmanager/DefaultEncodedTransformWorkerManager.ts:127
DefaultEncodedTransformWorkerManager.setupVideoReceiverTransform
src/encodedtransformmanager/DefaultEncodedTransformWorkerManager.ts:94
RTCPeerConnection.handleTrack
src/transceivercontroller/DefaultTransceiverController.ts:139
```
Contributor guide
Research direction
Start by reading src/encodedtransformmanager/DefaultEncodedTransformWorkerManager.ts around lines 94 and 127, then trace the track handling at src/transceivercontroller/DefaultTransceiverController.ts:139 during SetRemoteDescriptionTask and renegotiation. Investigate repeated video receiver setup on Chromium without RTCRtpScriptTransform. Done means SDK-driven renegotiation or repeated track events no longer produce the unhandled InvalidStateError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- audio-video-rtc
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100