Skip to content

bug: libobs: the output interleaver batch limit grows on every restart of the same output #487

Closed

Description

@chriscoveries

Summary

Each time an output starts, the interleaver adds the batch limit for the new capture onto the previous value instead of replacing it. After one restart (or a reconnect) the limit is double what it should be, after two it is triple, and so on. The catch-up that sends an extra packet when the interleave buffer backs up then triggers later and later, so a backlog drains more slowly than designed. Severity: low. There is no crash or data loss; it shows up as extra latency after stalls on outputs that restart.

Steps / trigger

Public API, with an output that has one 50 fps video encoder and one audio encoder at 48 kHz with 960-sample packets (both packet intervals are 20 ms, so the limit is four):

  1. Start the output. With debug logging on, "Maximum interleaver batch size for ... calculated to be 4 packets" is logged.
  2. Stop and start the same output object again (an automatic reconnect does the same). The log now says 8, then 12 after the next restart.
  3. Queue five eligible packets past the ordinary send. On the first capture the catch-up sends a second packet; after the restart it sends only one, and the backlog stays queued.

Cause

Line numbers are against current master.

  • libobs/obs-output.c:2737-2780: calculate_batch_size does output->interleaver_max_batch_size += num (:2775) and never sets the field to zero first.
  • libobs/obs-output.c:2805: it is called from obs_output_begin_data_capture_internal on every start.
  • libobs/obs-internal.h:1281: the field is only zero-initialised when the output is created.
  • libobs/obs-output.c:2326: the catch-up check --streamable > output->interleaver_max_batch_size reads the inflated value.

Proposed fix

Reset interleaver_max_batch_size to zero at the start of calculate_batch_size. The regression test uses public encoder, output and media APIs. It creates one output, starts it twice, and checks that with exactly four, five and six eligible packets queued the delivery count is the same on the first capture and on the restart (one, two and two).

I'd like to work on this; a fix with a regression test is ready.

Activity

  1. zackees commented on Oct 13, 2026

    @zackees
    Member

    @chriscoveries go ahead: please open the PR with the RED test commit first, then the fix (one PR per issue, targeting master). Marking it claimed for you so nobody duplicates it.

  2. added
    claimed
    on Oct 13, 2026
  3. chriscoveries commented on Oct 14, 2026

    @chriscoveries
    ContributorAuthor

    Releasing this one. We're backed up on CI and won't get it landed soon, so anyone who wants it is welcome to take it.

    If it helps, our RED test and fix are on the fork branch fix/interleave-batch-size-reset. They passed review on our side but haven't been through CI, so reuse them or start fresh, whichever you prefer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    claimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions