Skip to content

DownTrack: arm key frame requester timer only while a layer lock is pending - #4980

Merged
boks1971 merged 1 commit into
masterfrom
raja/keyframe-requester-arm-on-demand
Oct 11, 2026
Merged

boks1971 merged 1 commit into
masterfrom
raja/keyframe-requester-arm-on-demand

Conversation

@boks1971

Copy link
Copy Markdown
Contributor

Every video down track runs a key frame requester. It re-armed its timer on every loop. So each video subscription woke up every 200 ms to 1 s (2x RTT, clamped) for its whole life. Most of those wake-ups found the layer already locked and did nothing.

This change re-arms the timer only while there is something to wait for:

  • the requested layer is not locked yet, or
  • an initial-acquisition grace is armed, so it may still need to expire, or
  • layers are selected with the dependency descriptor (AV1, VP9 SVC). That selector can lose the lock while forwarding packets, on a key frame mismatch or a broken frame chain, and nothing posts an event. So those tracks keep the periodic check, as before.

Once the layer is locked on VP8, H.264 or simulcast, the requester sleeps until the next event.

Some paths change the lock without an allocation, so they now post the event: resync, mute, a new max published layer (it can arm the grace), and a layer switch on the packet path (for example the simulcast step-down from an overshoot layer).

The timer may now be idle when an event arrives. So draining the timer channel after a failed Stop is now non-blocking. A blocking receive would hang.

AV1 and VP9 SVC tracks get no saving from this change. A follow-up could have the dependency descriptor selector report when it loses the lock.

Tests:

  • A real VP8 down track over vnet sends repeated PLIs while the lock is pending. Once a key frame locks the layer, the requester does not wake up at all, checked with a wake-up counter. After a resync it sends PLIs again. The test fails if the timer is always re-armed.
  • A forwarder test checks when periodic polling is needed: grace armed, or AV1 with the dependency descriptor. It is not needed for VP8, even with the dependency descriptor, which VP8 uses only for temporal layers.

🤖 Generated with Claude Code

…ending

The key frame requester re-armed its timer on every loop, so every video down
track woke up every 200 ms to 1 s for its whole life, even when the layer was
locked and there was nothing to do.

Re-arm the timer only while the requested layer is not locked, or while the
lock can change without an event: an acquisition grace is armed, or layers are
selected with the dependency descriptor, which can lose the lock on the packet
path. Post the event on resync, mute, max published layer change and packet
path layer switch, since those can change the lock without an allocation.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Devin Review: 1 flag

Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

@boks1971
boks1971 merged commit c2de273 into master Oct 11, 2026
6 checks passed
@boks1971
boks1971 deleted the raja/keyframe-requester-arm-on-demand branch October 11, 2026 05:55
eleboucher pushed a commit to eleboucher/homelab that referenced this pull request Oct 14, 2026
…9 ➔ v1.13.10) (#2338)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [docker.io/livekit/livekit-server](https://github.com/livekit/livekit) | patch | `v1.13.9` → `v1.13.10` |

---

### Release Notes

<details>
<summary>livekit/livekit (docker.io/livekit/livekit-server)</summary>

### [`v1.13.10`](https://github.com/livekit/livekit/releases/tag/v1.13.10)

[Compare Source](livekit/livekit@v1.13.9...v1.13.10)

##### Changed

- sfu: forward the dependency descriptor for VP8 simulcast ([#&#8203;4987](livekit/livekit#4987))
- sfu: keep VP8 descriptor frame numbers across migration ([#&#8203;4989](livekit/livekit#4989))
- sfu: filter VP9 and AV1 simulcast temporal layers with the dependency descriptor ([#&#8203;4991](livekit/livekit#4991))
- sfu: filter VP8 temporal layers by frame when the dependency descriptor is sent ([#&#8203;4976](livekit/livekit#4976))
- sfu: switch VP8 temporal layers up with the dependency descriptor ([#&#8203;4974](livekit/livekit#4974))
- sfu: pad the slot of a filtered packet that follows a sequence number gap ([#&#8203;4983](livekit/livekit#4983))
- sfu: send padding in the slot of a dropped out-of-order packet ([#&#8203;4979](livekit/livekit#4979))
- sfu: parse VP8 and VP9 payload descriptors without an allocation ([#&#8203;4981](livekit/livekit#4981))
- DownTrack: arm key frame requester timer only while a layer lock is pending ([#&#8203;4980](livekit/livekit#4980))
- turn: refuse TCP relays and limit relays to this host to media ports ([#&#8203;4992](livekit/livekit#4992))
- agent endpoints: address an unnamed deployment as "\_" ([#&#8203;4997](livekit/livekit#4997))
- Add OSS Scanner build image and threat model ([#&#8203;4995](livekit/livekit#4995))
- Update golang Docker tag to v1.27.1 ([#&#8203;4985](livekit/livekit#4985))
- Update alpine Docker tag to v3.24.2 ([#&#8203;4984](livekit/livekit#4984))
- Update module github.com/maxbrunsfeld/counterfeiter/v6 to v6.13.0 ([#&#8203;4915](livekit/livekit#4915))

##### Fixed

- Send NACKs when processing RTX packets ([#&#8203;5000](livekit/livekit#5000))
- sfu: send padding-only packets with no payload ([#&#8203;4993](livekit/livekit#4993))
- rtc: release timed out pending tracks at the pending track limit ([#&#8203;4998](livekit/livekit#4998))
- Fix nil pointer dereference in IOInfoService.UpdateIngressState ([#&#8203;4806](livekit/livekit#4806))
- rtc: keep update cache eviction order when listing recent disconnects ([#&#8203;4975](livekit/livekit#4975))
- fix(cli): return non-zero exit status on command errors ([#&#8203;4888](livekit/livekit#4888))
- Disable AV1 for Firefox clients before 157 ([#&#8203;4962](livekit/livekit#4962))

</details>

---

### Configuration

📅 **Schedule**: (UTC)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xNTEuMiIsInVwZGF0ZWRJblZlciI6IjQ0LjE1MS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Reviewed-on: https://git.erwanleboucher.dev/eleboucher/homelab/pulls/2338
hbjydev pushed a commit to hbjydev/phoebe that referenced this pull request Oct 20, 2026
…v1.13.10) (#884)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [docker.io/livekit/livekit-server](https://github.com/livekit/livekit) | patch | `v1.13.9` → `v1.13.10` |

---

### Release Notes

<details>
<summary>livekit/livekit (docker.io/livekit/livekit-server)</summary>

### [`v1.13.10`](https://github.com/livekit/livekit/releases/tag/v1.13.10)

[Compare Source](livekit/livekit@v1.13.9...v1.13.10)

##### Changed

- sfu: forward the dependency descriptor for VP8 simulcast ([#&#8203;4987](livekit/livekit#4987))
- sfu: keep VP8 descriptor frame numbers across migration ([#&#8203;4989](livekit/livekit#4989))
- sfu: filter VP9 and AV1 simulcast temporal layers with the dependency descriptor ([#&#8203;4991](livekit/livekit#4991))
- sfu: filter VP8 temporal layers by frame when the dependency descriptor is sent ([#&#8203;4976](livekit/livekit#4976))
- sfu: switch VP8 temporal layers up with the dependency descriptor ([#&#8203;4974](livekit/livekit#4974))
- sfu: pad the slot of a filtered packet that follows a sequence number gap ([#&#8203;4983](livekit/livekit#4983))
- sfu: send padding in the slot of a dropped out-of-order packet ([#&#8203;4979](livekit/livekit#4979))
- sfu: parse VP8 and VP9 payload descriptors without an allocation ([#&#8203;4981](livekit/livekit#4981))
- DownTrack: arm key frame requester timer only while a layer lock is pending ([#&#8203;4980](livekit/livekit#4980))
- turn: refuse TCP relays and limit relays to this host to media ports ([#&#8203;4992](livekit/livekit#4992))
- agent endpoints: address an unnamed deployment as "\_" ([#&#8203;4997](livekit/livekit#4997))
- Add OSS Scanner build image and threat model ([#&#8203;4995](livekit/livekit#4995))
- Update golang Docker tag to v1.27.1 ([#&#8203;4985](livekit/livekit#4985))
- Update alpine Docker tag to v3.24.2 ([#&#8203;4984](livekit/livekit#4984))
- Update module github.com/maxbrunsfeld/counterfeiter/v6 to v6.13.0 ([#&#8203;4915](livekit/livekit#4915))

##### Fixed

- Send NACKs when processing RTX packets ([#&#8203;5000](livekit/livekit#5000))
- sfu: send padding-only packets with no payload ([#&#8203;4993](livekit/livekit#4993))
- rtc: release timed out pending tracks at the pending track limit ([#&#8203;4998](livekit/livekit#4998))
- Fix nil pointer dereference in IOInfoService.UpdateIngressState ([#&#8203;4806](livekit/livekit#4806))
- rtc: keep update cache eviction order when listing recent disconnects ([#&#8203;4975](livekit/livekit#4975))
- fix(cli): return non-zero exit status on command errors ([#&#8203;4888](livekit/livekit#4888))
- Disable AV1 for Firefox clients before 157 ([#&#8203;4962](livekit/livekit#4962))

</details>

---

### Configuration

📅 **Schedule**: (in timezone Europe/London)

- Branch creation
  - At any time (no schedule defined)
- Automerge
  - At any time (no schedule defined)

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xNjcuNSIsInVwZGF0ZWRJblZlciI6IjQ0LjE2Ny41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9jb250YWluZXIiLCJ0eXBlL3BhdGNoIl19-->

Reviewed-on: https://git.hayden.moe/hayden/phoebe/pulls/884
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants