-
Notifications
You must be signed in to change notification settings - Fork 216
Fast track publication #1228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fast track publication #1228
Conversation
Add fastPublish option to establish publisher peerconnection when joining. Neogtiate new track without AddTrackRequest response
🦋 Changeset detectedLatest commit: 65d1dd6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
src/room/PCTransport.ts
Outdated
onError(e as Error); | ||
} else { | ||
throw e; | ||
async negotiate(onError?: (e: Error) => void) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
negotiate immediately if time elapsed since last negotiation > debounce interval (100ms)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this optimization will then only work for a single track. If someone were to publish cam + mic at the same time, one of these would get delayed.
Wondering if we can take a different approach that would allow multiple tracks to be negotiated together without having to necessarily wait for the 100ms debounce timeout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
currently, the publishTrack
method doesn't know if there is another track publishing together, I think we can provide a publishTracks
method for this case and make enableMicAndCamera
and setTrackEnabled(sceenshare)
to call the new method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, I should have checked for this earlier, but turns out the debounce
lib we're using has this functionality built in already: https://github.com/chodorowicz/ts-debounce?tab=readme-ov-file#function-arguments
we can just pass {isImmediate: true}
as an option. Then we don't have to do the conditional execution handling and can get rid of the doNegotiate
declaration again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pushed a commit to make use of the built-in version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
provide a publishTracks method for this case and make enableMicAndCamera and setTrackEnabled(sceenshare)
I think in practice the problem here will be that a lot of the client time is spent on actually acquiring the devices, so we're missing out on a lot of potential speed improvement.
I was thinking whether we could optimistically publish empty tracks for these APIs immediately when called and then replaceTrack
once the getUserMedia promise has resolved. Not sure how to handle initial trackinfo in that regard though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The publisher's offer is limited so it is ok to do frequency negotiations, maybe worth to remove the negotiation debounce totally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The setLocalDescription
failed after removing the debounce and publishing two tracks at once, looks like a condition race issue. we can address the issue in a separate PR since it is a client side change, just reduce the debounce interval to 20ms in this PR.
src/room/PCTransport.ts
Outdated
onError(e as Error); | ||
} else { | ||
throw e; | ||
async negotiate(onError?: (e: Error) => void) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this optimization will then only work for a single track. If someone were to publish cam + mic at the same time, one of these would get delayed.
Wondering if we can take a different approach that would allow multiple tracks to be negotiated together without having to necessarily wait for the 100ms debounce timeout
Co-authored-by: lukasIO <mail@lukasseiler.de>
Also reduce the negotiate debounce interval
size-limit report 📦
|
When enabled by server, we don't need to wait for AddTrackRequest to return so we can negotiate concurrently. Reference: livekit/client-sdk-android#612 livekit/client-sdk-js#1228 livekit/client-sdk-js#1231
* Speed up track publication Add fastPublish option to establish publisher peerconnection when joining. Neogtiate new track without AddTrackRequest response * changeset * don't do parallel negotiate if no enabled codecs return * Update src/options.ts Co-authored-by: lukasIO <mail@lukasseiler.de> * negotiate error * use isImmediate option of ts-debounce * Use fastPublish option in JoinResponse Also reduce the negotiate debounce interval * Update protocol dependency --------- Co-authored-by: lukasIO <mail@lukasseiler.de>
Add fastPublish option to establish publisher peerconnection when
joining.
Neogtiate new track without AddTrackRequest response