-
Notifications
You must be signed in to change notification settings - Fork 81
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
Automatic subscription management based on video track visibility #588
Conversation
|
size-limit report 📦
|
Looking good 👍
As far as I can see, there is no change to the public API. So we could merge it and get some real world feedback if it works as expected for the "normal" (not so many participants) use cases. If something comes up, we can iterate/roll back without breaking the API. |
@@ -1,4 +1,4 @@ | |||
import type { Participant } from 'livekit-client'; | |||
import { type Participant } from 'livekit-client'; |
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.
Curious, does this offer any advantages (bundle size, tree shaking) over the other type of import?
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.
no, it's just what VSCode does when auto importing 🤷
import { isLocal } from '@livekit/components-core'; | ||
import { Track } from 'livekit-client'; | ||
import { RemoteTrackPublication, Track } from 'livekit-client'; | ||
import * as React from 'react'; | ||
import { useTracks } from '../hooks'; | ||
import { AudioTrack } from './participant/AudioTrack'; |
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.
import { isLocal } from '@livekit/components-core'; | |
import { Track } from 'livekit-client'; | |
import { RemoteTrackPublication, Track } from 'livekit-client'; | |
import * as React from 'react'; | |
import { useTracks } from '../hooks'; | |
import { AudioTrack } from './participant/AudioTrack'; | |
import { isLocal } from '@livekit/components-core'; | |
import type { RemoteTrackPublication } from 'livekit-client'; | |
import { Track } from 'livekit-client'; | |
import * as React from 'react'; | |
import { useTracks } from '../hooks'; | |
import { AudioTrack } from './participant/AudioTrack'; |
Co-authored-by: Jonas Schell <[email protected]>
I think we can default to false, but enable in our sample apps for now. then once it's gotten some real-world testing, we can enable? |
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.
lgtm
@@ -19,7 +20,13 @@ import { AudioTrack } from './participant/AudioTrack'; | |||
export function RoomAudioRenderer() { | |||
const tracks = useTracks([Track.Source.Microphone, Track.Source.ScreenShareAudio], { |
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.
can we also make a change here to subscribe to all audio tracks, even ones tagged as unknown?
we've seen users getting confused when they couldn't playback tracks that are not tagged correctly.
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 there's no way to filter track references based on kind
.
an unknown
source could also be a video track. We would probably have to add kind
to the track reference definition to make that happen.
React.useEffect(() => { | ||
tracks.forEach((track) => (track.publication as RemoteTrackPublication).setSubscribed(true)); | ||
}, [tracks]); | ||
|
||
return ( | ||
<div style={{ display: 'none' }}> | ||
{tracks.map((trackRef) => ( |
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.
I guess this handles unsubscribed tracks automatically? that's cool
Co-authored-by: Jonas Schell <[email protected]>
This adds automatic subscription management based on visibility of the
VideoTrack
component.It allows for meetings with a lot of users, where subscription limits might become a constraint.
setSubscribed(true)
is immediate once the element comes into viewsetSubscribed(false)
is debounced with 3s right now (happy to change that around and/or make it configurable?)adaptiveStream
doesn't provide any benefit any more (afaict)Open questions:
manageSubscription
- true or false?