Describe the bug
LocalParticipant.sendText method sets totalSize = text.codeUnits.length, but writer.write(text) encodes via splitUtf8() which produces UTF-8 bytes. For non-ASCII text, these counts differ: one emoji = 2 UTF-16 code units but 4 UTF-8 bytes.
validateBytesReceived() (introduced in v2.6.x) throws DataStreamError(LengthExceeded) on the receiver when received bytes exceed totalSize. The throw happens before onData?.call(data), so the chunk is silently dropped, and the stream never emits data to the application layer.
The sender is unaffected; they display their message via a local stream rather than the LiveKit-delivered one.
To Reproduce
- Two participants in a room using livekit_client >= 2.6.0
- Send a message with any non-ASCII character (emoji, Cyrillic, Chinese…)
- On the receiver side, the
TextStreamReader stream emits no data
- Receiver's Flutter console shows:
DataStreamError: DataStreamErrorReason.LengthExceeded,
Extra chunk(s) received - expected 6 bytes of data total, received 12 bytes
at validateBytesReceived (stream_reader.dart:43:7)
at handleChunkReceived (stream_reader.dart:103:5)
Example: "😀😀😀" → codeUnits.length = 6, utf8.encode(...).length = 12.
Expected behavior
The receiver reads the full text stream. totalSize should equal the UTF-8 byte count that writer.write(text) actually transmits.
Suggested fix
In sendText, replace:
final textInBytes = text.codeUnits;
with:
final textInBytes = utf8.encode(text);
Platform information
Flutter version:
[✓] Flutter (Channel stable, 3.41.6, on macOS 15.1 24B83 darwin-arm64, locale
en-UA) [498ms]
• Flutter version 3.41.6 on channel stable at /Users/[reducted]/fvm/versions/3.41.6
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision db50e20168 (3 weeks ago), 2026-03-25 16:21:00 -0700
• Engine revision 425cfb54d0
• Dart version 3.11.4
• DevTools version 2.54.2
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop,
enable-windows-desktop, enable-android, enable-ios, cli-animations,
enable-native-assets, omit-legacy-version-file, enable-lldb-debugging,
enable-uiscene-migration
[✓] Android toolchain - develop for Android devices (Android SDK version
36.1.0-rc1) [2.5s]
• Android SDK at /Users/[reducted]/Library/Android/sdk
• Emulator version 36.3.10.0 (build_id 14472402) (CL:N/A)
• Platform android-36, build-tools 36.1.0-rc1
• Java binary at: /opt/homebrew/opt/openjdk@17/bin/java
This JDK is specified in your Flutter configuration.
To change the current JDK, run: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment Homebrew (build 17.0.15+0)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 16.1) [1,165ms]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16B40
• CocoaPods version 1.16.2
[✓] Chrome - develop for the web [5ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Connected device (3 available) [7.2s]
• iPhone 16 Pro Max (mobile) • F513E3EB-B7FB-4D44-93DA-DA5FE6A2413F •
ios • com.apple.CoreSimulator.SimRuntime.iOS-18-1 (simulator)
• macOS (desktop) • macos •
darwin-arm64 • macOS 15.1 24B83 darwin-arm64
• Chrome (web) • chrome •
web-javascript • Google Chrome 147.0.7727.56
[✓] Network resources [397ms]
• All expected network resources are available.
• No issues found!
Plugin version: livekit_client 2.6.3
Flutter target OS: Web
Flutter target OS version:
Flutter console log: see above
Describe the bug
LocalParticipant.sendTextmethod setstotalSize = text.codeUnits.length, butwriter.write(text)encodes viasplitUtf8()which produces UTF-8 bytes. For non-ASCII text, these counts differ: one emoji = 2 UTF-16 code units but 4 UTF-8 bytes.validateBytesReceived()(introduced in v2.6.x) throwsDataStreamError(LengthExceeded)on the receiver when received bytes exceedtotalSize. The throw happens beforeonData?.call(data), so the chunk is silently dropped, and the stream never emits data to the application layer.The sender is unaffected; they display their message via a local stream rather than the LiveKit-delivered one.
To Reproduce
TextStreamReaderstream emits no dataExample: "😀😀😀" →
codeUnits.length = 6,utf8.encode(...).length = 12.Expected behavior
The receiver reads the full text stream.
totalSizeshould equal the UTF-8 byte count thatwriter.write(text)actually transmits.Suggested fix
In
sendText, replace:with:
Platform information
Flutter version:
Plugin version: livekit_client 2.6.3
Flutter target OS: Web
Flutter target OS version:
Flutter console log: see above