Skip to content

Commit cf4e4d9

Browse files
authored
Fixes disconnect issue (#656)
If the track has already been disposed, the associated MediaStreamTrack is also disposed, causing unpublishTrack to throw an IllegalStateException ("MediaStreamTrack has been disposed."). To prevent this issue, dispose of the defaultTracks only after the track has been unpublished.
1 parent 1eef3e6 commit cf4e4d9

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

.changeset/good-dancers-jam.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"client-sdk-android": patch
3+
---
4+
5+
Fixes disconnect issue

livekit-android-sdk/src/main/java/io/livekit/android/room/participant/LocalParticipant.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,10 +1550,6 @@ internal constructor(
15501550
* @suppress
15511551
*/
15521552
fun cleanup() {
1553-
defaultAudioTrack?.dispose()
1554-
defaultAudioTrack = null
1555-
defaultVideoTrack?.dispose()
1556-
defaultVideoTrack = null
15571553
for (pub in trackPublications.values) {
15581554
val track = pub.track
15591555

@@ -1569,6 +1565,10 @@ internal constructor(
15691565
}
15701566
}
15711567
}
1568+
defaultAudioTrack?.dispose()
1569+
defaultAudioTrack = null
1570+
defaultVideoTrack?.dispose()
1571+
defaultVideoTrack = null
15721572
}
15731573

15741574
/**

0 commit comments

Comments
 (0)