Repository navigation
Conversation
j-mercker
requested review from
changt,
cloudwebrtc,
hiroshihorie and
xianshijing-lk
as code owners
November 22, 2026 12:51
There was a problem hiding this comment.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
This branch has not been deployed
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 a resume starts while the publisher is still waiting for the answer to an earlier offer, every resume attempt fails the same way and the room disconnects with
reconnectAttemptsExceeded, although the signal connection comes back each time and a full reconnect or a rejoin works at once.Seen on web with 2.13.2 on LiveKit Cloud: 5 users over 2 days, 1 to 13 failed resumes each. Two of the sessions, client time:
In each case a microphone publish had just timed out or its track had just ended.
Cause
A resume asks the publisher for an ICE-restart offer. If the publisher is in
have-local-offer,Transport.createAndSendOfferfirst re-applies the previous remote answer. When the unanswered offer added or removed a track, that answer no longer fits it and the browser rejects it, with "The order of m-lines…" for an added or replaced track and "Incompatible send direction" for a removed one. The publisher stays inhave-local-offer, so the next resume is rejected the same way.attemptReconnectescalates a failed resume to a full reconnect only forWebSocketExceptionandMediaConnectException, so the browser'sInvalidAccessErrorkeeps it on resume until the attempts run out.The JS SDK re-applies the answer the same way (
PCTransport.ts), but itsattemptReconnectescalates every resume failure that is not aSignalReconnectError, so it recovers with a full reconnect.The browser behavior reproduces with two local peer connections and no server: leave a change unanswered, then run the SDK's resume step three times. Chrome 158:
… order of m-lines …have-local-offer… order of m-lines …have-local-offer… Incompatible send directionhave-local-offerhave-local-offerRepro page (open in a browser)
Fix
Transport.createAndSendOfferthrowsNegotiationErrorwhen it cannot restore the previous answer for an ICE restart.attemptReconnectescalates a resume that failed withNegotiationErrorto a full reconnect, as_onPublisherNegotiationErroralready does outside a resume.Only
resumeConnectionasks for an ICE restart, so only the resume path changes. On that path the existingNegotiationErrorfrom a rejected SDP munge (setMungedSDP) now escalates the resume too.Testing
test/core/transport_negotiate_test.dart, "an ICE restart that cannot restore the previous answer throws a NegotiationError" (and sends no offer). It fails onmainand passes here.test/core/resume_negotiation_failure_test.dart, "a resume that fails with a NegotiationError is retried as a full reconnect". It fails onmain(the next attempt is another resume) and passes here.E2EContainertakes an optionalpeerConnectionCreatefor it, and the stale-answer fake is shared intest/mock/peerconnection_mock.dart.Notes
mainbehave the same.createAndSendOfferand keep the re-apply. Match publisher answers to offers by offer id #1262's test "ignores the answer to an offer that an ICE restart replaced" runs this sequence, but its fake peer connection accepts any remote description, so it doesn't hit the rejection.