Commit 17e2aac
committed
fix: resolve track subscription race condition on participant rejoin
Fixes race condition where tracks arriving before participant metadata
were permanently dropped from the pending queue after timeout, causing
10-60 second delays or complete failures when participants rejoin.
Changes:
1. Retry transient failures: Modified _flushPendingTracks() to differentiate
between transient (notTrackMetadataFound) and permanent failures. Transient
failures now keep tracks in queue for retry instead of removing them.
2. Additional flush trigger: Added listener to flush pending tracks when
SignalParticipantUpdateEvent contains track publications, ensuring tracks
are subscribed once metadata becomes available.
3. Improved logging: Transient failures logged at fine level to reduce noise,
permanent failures at severe level for visibility.
The fix maintains the existing timeout configuration from connectOptions
while enabling retry logic that resolves the race condition where:
- WebRTC track arrives first → queued
- ParticipantInfo arrives → participant created → flush fails (no publications)
- TrackPublishedResponse arrives later → second flush succeeds
This reduces track subscription latency after rejoin from 10-60s to <1s
and improves reliability on slower devices where the race condition was
more pronounced.
Related: livekit#9281 parent b0081d4 commit 17e2aac
2 files changed
+36
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
332 | 332 | | |
333 | 333 | | |
334 | 334 | | |
335 | | - | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
336 | 355 | | |
337 | 356 | | |
338 | 357 | | |
| |||
787 | 806 | | |
788 | 807 | | |
789 | 808 | | |
790 | | - | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
791 | 821 | | |
792 | 822 | | |
793 | 823 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
452 | 452 | | |
453 | 453 | | |
454 | 454 | | |
455 | | - | |
| 455 | + | |
456 | 456 | | |
457 | 457 | | |
458 | | - | |
| 458 | + | |
459 | 459 | | |
460 | 460 | | |
461 | 461 | | |
| |||
721 | 721 | | |
722 | 722 | | |
723 | 723 | | |
724 | | - | |
| 724 | + | |
725 | 725 | | |
726 | 726 | | |
727 | | - | |
| 727 | + | |
728 | 728 | | |
729 | 729 | | |
730 | 730 | | |
| |||
0 commit comments