Skip to content

Send AddTrack before configuring fast publication senders - #1074

Open
xianshijing-lk wants to merge 1 commit into
mainfrom
sxian/ordered-fast-publication
Open

xianshijing-lk wants to merge 1 commit into
mainfrom
sxian/ordered-fast-publication

Conversation

@xianshijing-lk

Copy link
Copy Markdown
Contributor

Android already implements JS-style fast publication. The fast branch currently launches sender setup before scheduling AddTrack registration, allowing negotiation to precede the request. This follows up on livekit/rust-sdks#1704 by guaranteeing the registration phase starts first.

Start the AddTrack child coroutine with CoroutineStart.UNDISPATCHED, then configure the sender in the parent coroutine and await acceptance. RTCEngine.addTrack registers its cancellation-aware response waiter and sends AddTrack before its first suspension. This retains the overlap and structured cancellation while removing the separate negotiation child task. Existing sender ownership and rollback stay in use.

No public API or publication eligibility changes. Fast publication works in both the default dual-PC mode and ConnectOptions(singlePeerConnection = true); SPC does not need to become the default.

Validation:

  • Four new mock E2E cases cover fast/sequential publication in actual single/dual PC mode. They assert AddTrack is sent before sender attachment, hold the acknowledgment to prove fast sender setup overlaps registration, require acceptance before local publication, and verify completion after acknowledgment.
  • 54 Robolectric tests passed: the four new cases, 38 existing local participant cases, and 12 single-PC cases.
  • :livekit-android-sdk:detektRelease passed using the repository baseline.
  • Spotless formatted the changed Kotlin files in a regular checkout of the same revision (the current plugin cannot discover Git repositories from worktrees), and git diff --check passed.
  • detektDebug still reports the repository's existing SDK-wide findings (133 weighted issues); this PR does not broaden the change to resolve them.

Includes a patch changeset. Current main already contains the offer-with-join optimization; the separate local initial-track/connect edits remain untouched. This PR changes ordinary publication only.

@changeset-bot

changeset-bot Bot commented Nov 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 25ad83a

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

@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: 1 flag

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

Devin Review

@github-actions

Copy link
Copy Markdown
Contributor

Diffuse output:

OLD: diffuse-source-file
NEW: livekit-android-sdk-release.aar

 AAR      │ old      │ new      │ diff     
──────────┼──────────┼──────────┼──────────
      jar │  3.1 MiB │  3.1 MiB │ -2.3 KiB 
 manifest │  1.5 KiB │  1.5 KiB │      0 B 
 lint-jar │ 12.7 KiB │ 12.7 KiB │      0 B 
    other │  2.4 KiB │  2.4 KiB │      0 B 
──────────┼──────────┼──────────┼──────────
    total │  3.2 MiB │  3.2 MiB │ -2.3 KiB 

 JAR     │ old   │ new   │ diff        
─────────┼───────┼───────┼─────────────
 classes │  1807 │  1806 │ -1 (+0 -1)  
 methods │ 22720 │ 22715 │ -5 (+1 -6)  
  fields │  6034 │  6025 │ -9 (+1 -10)
AAR
 size    │ diff     │ path          
─────────┼──────────┼───────────────
 3.1 MiB │ -2.3 KiB │ ∆ classes.jar 
─────────┼──────────┼───────────────
 3.1 MiB │ -2.3 KiB │ (total)
JAR
CLASSES:

   old  │ new  │ diff       
  ──────┼──────┼────────────
   1807 │ 1806 │ -1 (+0 -1) 
  
  - io.livekit.android.room.participant.LocalParticipant_publishTrackImpl_4_negotiateJob_1
  

METHODS:

   old   │ new   │ diff       
  ───────┼───────┼────────────
   22720 │ 22715 │ -5 (+1 -6) 
  
  + io.livekit.android.room.participant.LocalParticipant_publishTrackImpl_4 <init>(LocalParticipant, String, Ref_ObjectRef, Track, LivekitRtc_AddTrackRequest_Builder, LocalParticipant_PublishListener, Ref_ObjectRef, Ref_ObjectRef, Track_Source, Ref_ObjectRef, Continuation)
  
  - io.livekit.android.room.participant.LocalParticipant_publishTrackImpl_4 <init>(LocalParticipant, Ref_ObjectRef, Track, Ref_ObjectRef, Ref_ObjectRef, String, Track_Source, Ref_ObjectRef, LocalParticipant_PublishListener, LivekitRtc_AddTrackRequest_Builder, Continuation)
  - io.livekit.android.room.participant.LocalParticipant_publishTrackImpl_4_negotiateJob_1 <init>(LocalParticipant, Ref_ObjectRef, Track, Ref_ObjectRef, Ref_ObjectRef, String, Track_Source, Ref_ObjectRef, LocalParticipant_PublishListener, Continuation)
  - io.livekit.android.room.participant.LocalParticipant_publishTrackImpl_4_negotiateJob_1 create(Object, Continuation) → Continuation
  - io.livekit.android.room.participant.LocalParticipant_publishTrackImpl_4_negotiateJob_1 invoke(Object, Object) → Object
  - io.livekit.android.room.participant.LocalParticipant_publishTrackImpl_4_negotiateJob_1 invoke(CoroutineScope, Continuation) → Object
  - io.livekit.android.room.participant.LocalParticipant_publishTrackImpl_4_negotiateJob_1 invokeSuspend(Object) → Object
  

FIELDS:

   old  │ new  │ diff        
  ──────┼──────┼─────────────
   6034 │ 6025 │ -9 (+1 -10) 
  
  + kotlinx.coroutines.CoroutineStart UNDISPATCHED: CoroutineStart
  
  - io.livekit.android.room.participant.LocalParticipant_publishTrackImpl_4_negotiateJob_1 _cid: String
  - io.livekit.android.room.participant.LocalParticipant_publishTrackImpl_4_negotiateJob_1 _encodings: Ref_ObjectRef
  - io.livekit.android.room.participant.LocalParticipant_publishTrackImpl_4_negotiateJob_1 _options: Ref_ObjectRef
  - io.livekit.android.room.participant.LocalParticipant_publishTrackImpl_4_negotiateJob_1 _previousTrackTransceiver: Ref_ObjectRef
  - io.livekit.android.room.participant.LocalParticipant_publishTrackImpl_4_negotiateJob_1 _publishListener: LocalParticipant_PublishListener
  - io.livekit.android.room.participant.LocalParticipant_publishTrackImpl_4_negotiateJob_1 _senderTransceiver: Ref_ObjectRef
  - io.livekit.android.room.participant.LocalParticipant_publishTrackImpl_4_negotiateJob_1 _track: Track
  - io.livekit.android.room.participant.LocalParticipant_publishTrackImpl_4_negotiateJob_1 _trackSource: Track_Source
  - io.livekit.android.room.participant.LocalParticipant_publishTrackImpl_4_negotiateJob_1 label: int
  - io.livekit.android.room.participant.LocalParticipant_publishTrackImpl_4_negotiateJob_1 this_0: LocalParticipant

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.

2 participants