Skip to content

bug: Browser streaming fails on any host without a hardware video encoder #156

Description

@knguyen298

Summary

cptr/frontend/static/browser-encoder.js configures the WebCodecs VideoEncoder with hardwareAcceleration: 'prefer-hardware'. On hosts with no hardware video encoder (headless servers, GPU-less VMs), VideoEncoder.isConfigSupported() returns supported: false for every codec, so the guard throws and the browser tab errors out.

Environment

  • cptr with managed Chrome (Google Chrome, H.264-capable)
  • Linux VM, no GPU/hardware video encoder
  • Reproduces regardless of codec or resolution

Root cause

Per the WebCodecs spec, hardwareAcceleration defaults to no-preference, and prefer-hardware/prefer-software are hints that user agents should respect when possible but may ignore. Chromium does not implement them as hints: it treats prefer-hardware as a hard requirement, while no-preference means "use hardware if available, otherwise fall back to software."

Because there is no hardware encoder on these hosts, prefer-hardware causes isConfigSupported() to return false for all codecs, and this guard throws:

const support = await VideoEncoder.isConfigSupported(config);
if (!support.supported) throw new Error(`H.264 WebCodecs encoding is unavailable ...`);

Confirmed empirically on current Chrome: with prefer-hardware the config returns supported: false; with no-preference it returns true and encodes in software.

Suggested fix

Change the encoder config in browser-encoder.js:

hardwareAcceleration: 'prefer-hardware'  ->  'no-preference'

This loses nothing on hosts that have a hardware encoder (Chromium still uses hardware under no-preference); it only adds the software fallback where no hardware encoder exists. If explicit intent is preferred, try prefer-hardware first and retry once with no-preference on !supported before throwing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions