Skip to content

CarLife: time-bounded video queue and coalesced keyframe requests - #38

Merged
riko2chen merged 1 commit into
mainfrom
feature/carlife-keyframe-loop
Nov 29, 2026
Merged

riko2chen merged 1 commit into
mainfrom
feature/carlife-keyframe-loop

Conversation

@riko2chen

Copy link
Copy Markdown
Contributor

A CarPlay source faster than the rate the CarLife receiver negotiated overran the three-frame video queue. Every overflow cleared the backlog and requested a keyframe; the large IDR overran the queue again, and the 1.5 s periodic keyframe request kept the loop going. A community report (OnePlus 7 Pro relay, 2.x head unit, 60 fps source against 30 fps negotiated) showed 30% of frames dropped and 146 keyframe requests in one session. iOS fixed the same loop in OpenXPlay-c8om8; this ports that fix to kotlin/carlife.

Changes

  • CarlifeFrameQueue: bounded by media span (600 ms), bytes (4 MiB) and frame count (120) instead of three frames. An overflow resets the queue, keeps an incoming keyframe, and reports which limit was hit.
  • Keyframe requests: recovery requests (overflow, waiting for a keyframe, rejected frame) are coalesced to at most one per second and cancelled once a keyframe is queued. The periodic refresh runs only after 5 s without a sent keyframe. Requests at video start and on a source size change are unchanged.
  • Diagnostics: the session summary adds keyframeRequestsDeferred, queueBytes, queueSpanMs, queueOverflows. The first overflow per session is logged with its limit, and the first eight keyframe requests are logged with their reason.
  • The negotiated send cadence is unchanged: the receiver decodes at 1000/fps, so sending faster only moves the backlog into the head unit.

Tests

New CarlifeFrameQueueTest and a clock-injected session test for coalescing and the periodic refresh. :carlife:compileTestKotlin passes locally; unit tests were not run locally and are left to CI. Not device-tested.

A source faster than the negotiated send rate overran the three-frame queue. Each overflow
cleared the backlog and asked for a keyframe, and the large IDR overran the queue again; a
1.5 s periodic request kept the loop going. A community report against a 2.x head unit showed
30% of frames dropped and 146 keyframe requests in one session.

Bound queued video by media span (600 ms), bytes (4 MiB) and frames (120). Recovery requests
are at most one per second and are cancelled once a keyframe is queued; the periodic refresh
only runs after 5 s without a sent keyframe. The negotiated send cadence is unchanged. The
session summary gains keyframeRequestsDeferred, queueBytes, queueSpanMs and queueOverflows, and
the first overflow of a session is logged with its limit.

Ports iOS OpenXPlay-c8om8.

Signed-off-by: Riko <symeonchen@gmail.com>
@riko2chen
riko2chen enabled auto-merge November 29, 2026 16:15
@riko2chen
riko2chen merged commit 18b160a into main Nov 29, 2026
6 checks passed
@riko2chen
riko2chen deleted the feature/carlife-keyframe-loop branch November 29, 2026 16:17
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant