Skip to content

stream: fix firefox datachannel readiness counting#9

Open
kfatehi wants to merge 1 commit intocommaai:masterfrom
kfatehi:fix/firefox-datachannel-ready
Open

stream: fix firefox datachannel readiness counting#9
kfatehi wants to merge 1 commit intocommaai:masterfrom
kfatehi:fix/firefox-datachannel-ready

Conversation

@kfatehi
Copy link
Copy Markdown

@kfatehi kfatehi commented Feb 27, 2026

Summary

I used an AI assistant to help trace this, then verified and tested the fix manually.

Fixes a Firefox-specific readiness bug in WebRTCBaseStream._parse_incoming_streams that prevented messaging (e.g. joystick commands) from being set up.

Root cause

expected_number_of_incoming_media was over-counted when SDP included a datachannel media section (m=application) with a=sendrecv (common in Firefox).

The parser counted that application media twice:

  1. in the generic sendonly/sendrecv media count
  2. again in the explicit datachannel (m.kind == "application") count

That made expected_number_of_incoming_media larger than the actual runtime media/events, so readiness never completed.

Fix

  • Restrict generic sending-media counting to audio and video only.
  • Count datachannel presence as one messaging channel (int(len(channel_medias) > 0)), avoiding double-counting.

Behavior

  • Before: joystick/datachannel flow could work in Chrome but stall in Firefox.
  • After: readiness completes correctly and messaging works in both Chrome and Firefox.

Tests

  • Added regression test:
    • test_parse_incoming_streams_datachannel_not_double_counted
  • Command run:
    • PYTHONPATH=. pytest -q -o addopts='' tests/test_stream.py -k datachannel_not_double_counted
    • 1 passed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant