diff --git a/.changeset/cuddly-ties-tease.md b/.changeset/cuddly-ties-tease.md new file mode 100644 index 0000000000..851c8b40e8 --- /dev/null +++ b/.changeset/cuddly-ties-tease.md @@ -0,0 +1,5 @@ +--- +"livekit-client": patch +--- + +Wait for dc buffer status low for all published packets diff --git a/src/room/RTCEngine.ts b/src/room/RTCEngine.ts index a00e472341..25e136744b 100644 --- a/src/room/RTCEngine.ts +++ b/src/room/RTCEngine.ts @@ -1238,7 +1238,6 @@ export default class RTCEngine extends (EventEmitter as new () => TypedEventEmit }), }, }); - await this.sendDataPacket(packet, DataPacket_Kind.RELIABLE); } @@ -1269,6 +1268,8 @@ export default class RTCEngine extends (EventEmitter as new () => TypedEventEmit const msg = packet.toBinary(); + await this.waitForBufferStatusLow(kind); + const dc = this.dataChannelForKind(kind); if (dc) { if (kind === DataPacket_Kind.RELIABLE) { diff --git a/src/room/data-stream/outgoing/OutgoingDataStreamManager.ts b/src/room/data-stream/outgoing/OutgoingDataStreamManager.ts index 8258a97484..ecf31604b9 100644 --- a/src/room/data-stream/outgoing/OutgoingDataStreamManager.ts +++ b/src/room/data-stream/outgoing/OutgoingDataStreamManager.ts @@ -146,7 +146,6 @@ export default class OutgoingDataStreamManager { // Implement the sink async write(text) { for (const textByteChunk of splitUtf8(text, STREAM_CHUNK_SIZE)) { - await engine.waitForBufferStatusLow(DataPacket_Kind.RELIABLE); const chunk = new DataStream_Chunk({ content: textByteChunk, streamId, @@ -278,7 +277,6 @@ export default class OutgoingDataStreamManager { try { while (byteOffset < chunk.byteLength) { const subChunk = chunk.slice(byteOffset, byteOffset + STREAM_CHUNK_SIZE); - await engine.waitForBufferStatusLow(DataPacket_Kind.RELIABLE); const chunkPacket = new DataPacket({ destinationIdentities, value: {