Skip to content

Fix: Start ByteStreamWriter chunk index at 0 #430 #431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2025

Conversation

5Hyeons
Copy link
Contributor

@5Hyeons 5Hyeons commented May 2, 2025

This PR fixes a bug in ByteStreamWriter where the first data chunk was incorrectly sent with chunk_index = 1 instead of the expected 0.

Problem:
As described in Issue #430 , the _next_chunk_index was incremented before being used in the write method, causing incompatibility with clients (like the Unity SDK's ByteStreamReader) that expect stream chunk indices to start at 0.
This differs from the behavior of TextStreamWriter, which correctly starts at index 0.

Changes:
The ByteStreamWriter.write method has been modified to:
Use the current value of _next_chunk_index (which starts at 0 in BaseStreamWriter) for the chunk_index.
Increment _next_chunk_index after the chunk message has been sent via _send_chunk.
This aligns the behavior with TextStreamWriter and ensures correct 0-based indexing for byte streams, resolving client-side errors related to chunk index expectation.

@CLAassistant
Copy link

CLAassistant commented May 2, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@lukasIO lukasIO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for catching that!

@lukasIO lukasIO merged commit ac9f3fa into livekit:main May 7, 2025
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants