Repository navigation
Description
Describe the bug
A subscriber lowers the requested frame rate of a VP8 simulcast track with RemoteTrackPublication.setVideoFPS(5) and later raises it with setVideoFPS(30). After the raise it keeps receiving only the base temporal layer, a quarter of the frames. The full frame rate comes back only when a key frame arrives, for example when the subscriber switches to another spatial layer. Without a spatial switch it stayed at 5 fps for as long as we waited: 30 s in the minimal test below, 84 s in an application test.
A VP9 SVC track (L3T3_KEY) from the same publisher recovers in 1–2 seconds and needs no key frame.
Versions
- livekit-server v1.13.9, Docker image
livekit/livekit-server:v1.13.9, single node - livekit-client 2.22.3,
adaptiveStream: false,dynacast: true - Publisher and subscriber: Chrome 154 on macOS. In application-level tests a Chromium 148 publisher on Linux behaves the same.
- Publisher:
publishTrack(track, { videoCodec: 'vp8', simulcast: true }), camera 1280×720 at 20 fps. This gives the default three rids (q/h/f) with three temporal layers each. Thedependency-descriptorheader extension is negotiated on the publisher's sender.
To reproduce
Plain SDK, no application code:
- The publisher joins and publishes a VP8 simulcast camera track.
- The subscriber joins and, on
TrackSubscribed, callspublication.setVideoQuality(VideoQuality.LOW). - At 15 s:
publication.setVideoFPS(5). - At 35 s:
publication.setVideoFPS(30). - At 65 s:
publication.setVideoQuality(VideoQuality.MEDIUM). - Every second, log the deltas of
framesDecodedandkeyFramesDecodedfrom the receiver'sinbound-rtpstats.
Observed
Decoded frames per second. K marks a second in which a key frame was decoded.
VP8 simulcast, two runs with the same result:
20 20 20 20 20K 20 20 20 20 20 20 20 20
| 15s setVideoFPS(5) | 20 8 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
| 35s setVideoFPS(30) | 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
| 65s setVideoQuality(MEDIUM) | 5 21K 20 20 20 20 21 19 21 20 20 20 20 20 20 20
VP9 L3T3_KEY, same script with { videoCodec: 'vp9', scalabilityMode: 'L3T3_KEY' }:
20 20 19 20 20 21 20 20 19 21 19 21 19
| 15s setVideoFPS(5) | 21 6 5 5 5 6 5 5 5 5 5 5 5 5 5 5 5 5 5 5
| 35s setVideoFPS(30) | 5 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 21 19 21 19 21 20 20 20 20 20 20 20 20 20
| 65s setVideoQuality(MEDIUM) | 20 20K 20 20 20 20 21 20 20 20 20 20 20 20 20 20
Expected
After setVideoFPS(30) the VP8 subscriber gets the full frame rate back within about a second, as the VP9 subscriber does.
What we checked
pkg/sfu/videolayerselector/temporallayerselector/vp8.goat v1.13.9, changed by fix: switch VP8 temporal layer up only at a layer sync frame #4947 in v1.13.8. An up-switch needs a key frame, or a frame of layercurrent + 1with bothSandYset.- Chrome does encode such frames. We read frame dependencies with an encoded transform on the sender (VP8, three temporal layers, same Chrome build). They repeat as
T0, T2*, T1*, T2, T0, T2, T1, T2, where*means the frame depends only on T0. So a T1 frame that depends only on the base layer occurs once every 8 frames, every 0.4 s at 20 fps. The pattern is the same withmaxFramerate: 10and at 40–120 kbit/s. We therefore expected the selector to step T0 → T1 → T2 within about a second. - We could not inspect the
Ybit on the wire. We do not know whether it is missing from the packets or not seen by the selector. The dependency descriptor extension is present on these packets, in case that path matters. - We have not run this script against v1.13.7. We upgraded from v1.13.7 to v1.13.9 two days ago. In an application-level test the night before the upgrade, a subscriber that raised its fps request did start receiving the higher temporal layer.
Impact
A client that uses setVideoFPS to shed load cannot undo it for VP8 publishers unless the spatial layer changes. In our service these are phones, laptops with fewer than 8 cores, Safari and Firefox, about 30 % of participants. In a grid where tiles stay on the lowest layer, the video stays at a quarter of the frame rate. When the publisher is on a constrained uplink and encodes about 7 fps, the subscriber is left with under 2 fps.
Possible directions
- Request a key frame from the publisher when a temporal up-switch has been pending longer than some bound.
- Fall back to the pre-fix: switch VP8 temporal layer up only at a layer sync frame #4947 behaviour when no sync frame has been seen for N frames.
Subscriber part of the test page
const room = new LivekitClient.Room({ adaptiveStream: false, dynacast: true });
let pub = null, t0 = 0;
room.on(LivekitClient.RoomEvent.TrackSubscribed, (track, publication) => {
if (track.kind !== 'video' || pub) return;
pub = publication; track.attach(document.getElementById('v')); t0 = performance.now();
pub.setVideoQuality(LivekitClient.VideoQuality.LOW);
setTimeout(() => pub.setVideoFPS(5), 15_000);
setTimeout(() => pub.setVideoFPS(30), 35_000);
setTimeout(() => pub.setVideoQuality(LivekitClient.VideoQuality.MEDIUM), 65_000);
let prev = null;
const tick = async () => {
const stats = await track.receiver.getStats(); let cur = null;
stats.forEach(r => { if (r.type === 'inbound-rtp' && r.kind === 'video') cur = r; });
if (cur && prev) console.log(Math.round((performance.now() - t0) / 1000),
cur.framesDecoded - prev.framesDecoded, cur.keyFramesDecoded - prev.keyFramesDecoded, cur.frameHeight);
prev = cur;
if (performance.now() - t0 < 80_000) setTimeout(tick, 1000);
};
setTimeout(tick, 1000);
});
await room.connect(url, token, { autoSubscribe: true });Publisher: createLocalVideoTrack({ resolution: { width: 1280, height: 720, frameRate: 20 } }), then publishTrack(track, { videoCodec: 'vp8', simulcast: true }).
Activity
sfu: switch VP8 temporal layers up with the dependency descriptor (li…