Skip to content

fix: allow publisher-only ICE recovery - #1075

Open
ajma wants to merge 1 commit into
livekit:mainfrom
ajma:fix/publisher-only-reconnect
Open

ajma wants to merge 1 commit into
livekit:mainfrom
ajma:fix/publisher-only-reconnect

Conversation

@ajma

@ajma ajma commented Nov 23, 2026

Copy link
Copy Markdown

Summary

For a publisher-primary participant whose permissions explicitly deny subscribing, the server can leave the subscriber peer idle. During a reconnect, the Android SDK waits for both peers and checks that both are connected. That can trigger a full rejoin about 20 seconds into a soft reconnect even when publisher ICE and video delivery have recovered.

Use the local participant's subscribe permission from the join response and subsequent participant updates. When the publisher is in use and the subscriber peer is optional, wait for the publisher and use its state to judge completion. Subscriber-primary rooms and rooms whose subscribe permission is granted or unknown retain the subscriber check.

Evidence

  • On SDK 2.30.0, a Galaxy S25 publisher recovered video during soft reconnect, then attempted a full rejoin after 20.6 seconds. With an equivalent downstream transport check and a 300 kbps uplink after interruption, received video resumed and the soft reconnect held for the 40-second observation.
  • This source patch passed 67 tests across DualPeerConnectionTransportTest and RTCEngineMockE2ETest, plus both modules' spotlessKotlinCheck tasks. The added tests cover the idle subscriber, the required publisher, and changes to subscribe permission.

Merge Danger

Door Reversible SDK change.

Blast radius Reconnects in dual-peer publisher-primary rooms whose publishing participants lack subscribe permission.

Use the local participant’s subscribe permission for the dual-peer reconnect wait and completion checks.
@changeset-bot

changeset-bot Bot commented Nov 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ed44a59

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
client-sdk-android Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ajma
ajma marked this pull request as ready for review November 23, 2026 03:55

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

Comment on lines +129 to +131
if (requiresSubscriber(includePublisher)) {
launch { subscriberState.waitUntilConnected() }
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 Premature rejoin after subscribe grant

If permission is granted during a publisher-only resume, waitUntilConnected still returns as soon as the publisher connects. isConnected then requires the subscriber. If subscriber ICE is still starting, the engine abandons the resume and starts a full rejoin.

Learn more

The subscriber is the connection that receives remote media. The soft reconnect path starts collecting signaling responses asynchronously through onReadyForResponses. A participant update can therefore change the local subscribe permission while the reconnect waits for ICE. The wait uses the permission at entry, but the final connection check uses it at completion. If these decisions disagree, the reconnect loop moves on to a full rejoin even though the ICE deadline has not expired. onFullReconnecting then tears down remote participant state.

Example: A publisher starts resuming with subscribe permission denied and an idle subscriber peer. A server update grants permission while publisher ICE is still recovering. The publisher connects first and the subscriber is still connecting. The resume fails immediately instead of waiting for the subscriber within the remaining ICE budget.

Recommended fix: Make reconnect readiness observe both permission and peer state until the existing ICE deadline. If the final check observes that the subscriber has just become required, continue waiting within that deadline instead of falling through to a full rejoin. Add a test that grants permission after the wait starts and connects the subscriber after the publisher.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks, I confirmed this race in the reconnect path. waitUntilConnected() decides whether to wait for the subscriber when it starts, while isConnected() reads the latest permission. If a grant arrives before publisher ICE connects, the final check can reject the resume while the subscriber is still connecting and there’s time left in the ICE timeout.

The fix should use one readiness check that observes permission and peer state within the existing ICE timeout. A regression test should grant subscribe permission after the wait starts, connect the publisher first, and verify that the resume completes only after the subscriber connects.

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.

1 participant