fix: keep the pre-connect audio buffer through a region failover on connect - #1215
Draft
hiroshihorie wants to merge 2 commits into
Draft
hiroshihorie wants to merge 2 commits into
hiroshihorie wants to merge 2 commits into
Conversation
…onnect When the first connect attempt fails, the engine reports a disconnect before Room.connect retries another region. The Room handled that disconnect like any other and reset the pre-connect audio buffer, so the retry connected without a recording buffer and the join response found nothing to publish. The participant ended up in the room with no microphone until they toggled it, even though they had joined unmuted. Track whether Room.connect is running and leave the buffer alone when the disconnect belongs to a connect attempt. A connect that fails for good still ends with the caller's own cleanup, and a disconnect outside of a connect attempt still resets the buffer. Tests: a failover where the first socket connect fails and the validate call answers 403 now keeps the buffer recording, and a server initiated leave still resets it. Adds small test hooks for the region provider, the buffer's recording state, the HTTP client and a fail-once websocket mock.
|
Warning No changeset found If this PR includes user-facing changes, please add a changeset file in Format: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When the first connect attempt fails, the engine reports a disconnect before
Room.connectretries another Cloud region. The Room handled that disconnect like any other and reset the pre-connect audio buffer. The retry then connected with a buffer that was no longer recording, so the join response found no microphone track to publish. The participant ended up in the room, joined unmuted, with no microphone until they toggled it.Since 2.13.0 a 403 rejection also fails over instead of failing the connect, so a first attempt that used to fail visibly now connects silently without the microphone.
Fix
Room.connectrecords that a connect attempt is running._cleanUp, which skips the pre-connect buffer reset when the disconnect belongs to a connect attempt.withPreConnectAudiostops and resets the buffer on error), and a disconnect outside of a connect attempt still resets it.Tests
test/core/preconnect_failover_test.dart:main, passes here.Test-only additions:
Room.regionUrlProviderForTesting,PreConnectAudioBuffer.markRecordingForTesting,sdkHttpClientFactoryForTesting, and aconnectErrorOnceswitch on the websocket mock so a first attempt fails and the retry gets through.flutter analyzeclean,test/core,test/preconnectandtest/supportgreen (171 tests).