Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changes/screen-share-survives-reconnect
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
patch type="fixed" "Screen sharing no longer fails to resume after a full reconnect: the capture source (iOS broadcast extension IPC, ReplayKit) is kept alive while the track is reattached to the new publisher"
15 changes: 15 additions & 0 deletions Sources/LiveKit/Participant/LocalParticipant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,21 @@ extension LocalParticipant {
func republishAllTracks() async throws {
let mediaTracks = _state.trackPublications.values.map { $0.track as? LocalTrack }.compactMap(\.self)

// Detach screen share tracks without stopping their capturers — the
// underlying sources (iOS broadcast extension IPC, ReplayKit) cannot
// be restarted programmatically.
let screenShareTracks = mediaTracks.filter { $0.source == .screenShareVideo }
for track in screenShareTracks {
let sidsToRemove = _state.trackPublications.filter { $0.value.track === track }.map(\.key)
_state.mutate {
for sid in sidsToRemove {
$0.trackPublications.removeValue(forKey: sid)
}
}
await track.set(transport: nil, rtpSender: nil)
track._state.mutate { $0.rtpSenderForCodec.removeAll() }
}

await unpublishAll()

for mediaTrack in mediaTracks {
Expand Down
Loading