num_participants in room updates counts hidden participants
Participants that join with hidden: true are correctly left out of the participant list other clients receive, but they are still counted in the num_participants that every client gets in room updates (surfaced as room.numParticipants in the client SDKs). So a hidden participant's presence is invisible, while the room size including hidden participants is not.
Reproduce (v1.13.7, livekit-server --dev): join one visible participant, then three participants with hidden: true and subscribe-only grants, then a further hidden client that logs every SignalResponse. Its join lists only the visible participant(s), and no update ever names a hidden one, but each room_update carries num_participants counting all of them (5 with 2 visible, 6 after another hidden participant joined).
Code (same on master): updateProto() in pkg/rtc/room.go counts every participant that is not dependent:
for _, p := range r.GetParticipants() {
if !p.IsDependent() {
room.NumParticipants++
}while the removal path only decrements for non-hidden participants:
if !p.Hidden() {
r.protoRoom.NumParticipants--
}Question: is counting hidden participants intended? The removal path suggests they are meant to be excluded. If it is intended, would an option to exclude hidden participants from num_participants be acceptable? The use case is large subscribe-only audiences where viewers should not learn the audience size.
Source: livekit/livekit