Skip to content

Commit

Permalink
Only wait for publications that are pending already (#1339)
Browse files Browse the repository at this point in the history
* Only wait for publications that are pending already

* fix options shallow cloning

* Create quick-onions-live.md
  • Loading branch information
lukasIO authored Dec 3, 2024
1 parent ae729b3 commit 8da0135
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/quick-onions-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-client": patch
---

Only wait for publications that are pending already
14 changes: 11 additions & 3 deletions src/room/participant/LocalParticipant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,10 @@ export default class LocalParticipant extends Participant {
if (this.pendingPublishing.has(source)) {
const pendingTrack = await this.waitForPendingPublicationOfSource(source);
if (!pendingTrack) {
this.log.info('skipping duplicate published source', { ...this.logContext, source });
this.log.info('waiting for pending publication promise timed out', {
...this.logContext,
source,
});
}
await pendingTrack?.unmute();
return pendingTrack;
Expand Down Expand Up @@ -508,9 +511,15 @@ export default class LocalParticipant extends Participant {
}
}
} else {
if (!track?.track) {
if (!track?.track && this.pendingPublishing.has(source)) {
// if there's no track available yet first wait for pending publishing promises of that source to see if it becomes available
track = await this.waitForPendingPublicationOfSource(source);
if (!track) {
this.log.info('waiting for pending publication promise timed out', {
...this.logContext,
source,
});
}
}
if (track && track.track) {
// screenshare cannot be muted, unpublish instead
Expand Down Expand Up @@ -2029,6 +2038,5 @@ export default class LocalParticipant extends Participant {
}
await sleep(20);
}
throw new Error('waiting for pending publication promise timed out');
}
}
4 changes: 2 additions & 2 deletions src/room/track/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,11 @@ export function extractProcessorsFromOptions(options: CreateLocalTracksOptions)

if (typeof newOptions.audio === 'object' && newOptions.audio.processor) {
audioProcessor = newOptions.audio.processor;
newOptions.audio.processor = undefined;
newOptions.audio = { ...newOptions.audio, processor: undefined };
}
if (typeof newOptions.video === 'object' && newOptions.video.processor) {
videoProcessor = newOptions.video.processor;
newOptions.video.processor = undefined;
newOptions.video = { ...newOptions.video, processor: undefined };
}

return { audioProcessor, videoProcessor, optionsWithoutProcessor: newOptions };
Expand Down

0 comments on commit 8da0135

Please sign in to comment.