Conversation
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011J1hazAiH8ZzPimmmRH9oc
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved moderate findings remain in simulcast limit handling, audio bandwidth behavior, and bitrate reporting.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This PR caps outgoing video bitrate and reports resolved per-track and per-layer limits to the server.
Changes:
- Adds centralized video bitrate caps and resolution.
- Preserves simulcast limits and updates bitrate reporting.
- Updates React defaults, types, documentation, and tests.
File summaries
| File | Reviewed changes and final findings |
|---|---|
packages/webrtc-client/tests/methods/bandwidthLimits.test.ts |
Tests bitrate caps, defaults, and reporting. |
packages/webrtc-client/tests/methods/addTrackMethod.test.ts |
Tests simulcast bandwidth limits. |
packages/webrtc-client/src/webRTCEndpoint.ts |
Applies bandwidth resolution. Moderate findings: default simulcast limits resolve to an invalid numeric value, and audio limits are incorrectly capped. Nit: update stale public API documentation. |
packages/webrtc-client/src/types.ts |
Updates bandwidth-limit documentation. |
packages/webrtc-client/src/tracks/Local.ts |
Synchronizes bandwidth state. Moderate finding: setTrackBandwidth replaces simulcast per-variant limits with a scalar. |
packages/webrtc-client/src/tracks/bitrates.ts |
Builds reported bitrate metadata. Moderate finding: configured audio bandwidth is not reported after updates. |
packages/webrtc-client/src/index.ts |
Exports bitrate utilities. Nit: fix export formatting. |
packages/webrtc-client/src/bitrate.ts |
Defines bitrate caps and resolution helpers. |
packages/react-client/src/utils/bandwidth.ts |
Applies capped bandwidth defaults. |
packages/react-client/src/utils/bandwidth.test.ts |
Tests React bandwidth defaults. |
packages/react-client/src/types/public.ts |
Allows partial simulcast limits. |
packages/react-client/src/FishjamProvider.tsx |
Updates bandwidth configuration documentation. |
Review details
Suppressed comments (1)
packages/webrtc-client/src/tracks/bitrates.ts:13
- This early audio return ignores
trackContext.maxBandwidth, so aftersetTrackBandwidthchanges an audio sender, the server is still told the fixed 50,000 bps default rather than the configured bitrate. Since the setter updates both the sender and the context, report the configured audio limit when one exists (or reject audio bandwidth changes consistently).
if (kind === 'audio') return [{ variant: Variant.VARIANT_UNSPECIFIED, bitrate: defaultBitrates.audio }];
- Files reviewed: 12/12 changed files
- Comments generated: 5
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
2d6daf0 to
b1b1a89
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Audio bitrate reporting and stale public addTrack documentation remain unresolved.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (2)
packages/ts-client/src/FishjamClient.ts:669
- The new bandwidth-cap behavior also changes the contract of this class's
addTrack, but its publicaddTrackJSDoc still describes0as unlimited and saysmaxBandwidthhas no effect for simulcast. Update that documentation alongside these setter docs so the ts-client API does not advertise the old behavior.
* Single-stream video is clamped to `MAX_BANDWIDTH_LIMITS.singleStream`. For simulcast video each variant is
* clamped to `MAX_BANDWIDTH_LIMITS.simulcast[variant]` after the split. 0 means "use the cap(s)".
packages/webrtc-client/src/webRTCEndpoint.ts:470
- The new resolver changes video
0from unlimited to a cap and now uses simulcast limits passed toaddTrack, but the publicaddTrackdocumentation immediately above still says0is unlimited and thatmaxBandwidthhas no effect for simulcast (the same stale contract remains inpackages/ts-client/src/FishjamClient.ts). This contradicts the breaking behavior implemented here; update the public docs/default comment to describe the cap and per-variantMapsemantics.
* Applies the video caps to the limit passed to {@link addTrack}. Audio limits are ignored (0).
* For a simulcast track 0 means "every layer at its cap"; a positive number is kept as-is and
* rejected later, when the transceiver is created.
- Files reviewed: 24/24 changed files
- Comments generated: 1
- Review effort level: Lite
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved moderate issues affect API compatibility, bitrate resolution, documentation, and shared workspace configuration.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (2)
packages/ts-client/src/FishjamClient.ts:675
- The
FishjamClient.addTrackJSDoc at lines 579–580 still says 0 means unlimited and thatmaxBandwidthhas no effect for simulcast, while this newTrackBandwidthLimitAPI relies on those rules. Update the ts-clientaddTrackdocumentation so published docs describe the cap/default behavior.
public async setTrackBandwidth(trackId: string, bandwidth: TrackBandwidthLimit): Promise<boolean> {
packages/webrtc-client/src/webRTCEndpoint.ts:431
- The public
addTrackJSDoc immediately above still describes the old threshold/0-unlimited behavior and saysmaxBandwidthhas no effect for simulcast, but this new code now caps video and applies simulcast defaults. The generated API docs will contradict runtime behavior; update theaddTrackcontract (and its matching wrapper documentation).
const resolvedMaxBandwidth = this.resolveInitialBandwidth(track, simulcastConfig, maxBandwidth);
- Files reviewed: 27/27 changed files
- Comments generated: 3
- Review effort level: Lite
Cap video bitrate and report it to the server
Fixes video freezes caused by the high simulcast layer running at ~6 Mbps while the SFU assumed 2.5 Mbps.
Changes
MAX_BANDWIDTH_LIMITS(1500 kbps single stream, 150 / 500 / 1500 kbps for low / medium / high), exported fromwebrtc-clientandts-client.addTrack,setTrackBandwidthandsetEncodingBandwidthclamp values above the cap (with aconsole.warn) and treat 0 or a missing variant as "use the cap". Audio tracks are unaffected.addTrackcoerced aMapof per-variant limits to 0, so user-provided simulcast limits never reached the encoder.trackIdToBitratesnow carries per-variant bitrates derived from the configured limits instead of a hardcoded 1.5 Mbps in the wrong field.setTrackBandwidthalso sent kbps where the server expects bps; both setters now keeptrackContext.maxBandwidthin sync.bandwidthLimitsfills missing values fromMAX_BANDWIDTH_LIMITS; thesimulcastprop is nowPartial.Breaking change
0no longer means "unlimited" for video limits. It resolves to the cap.Testing
fishjam-videoroomusing0.30.2-rc.0.Documentation impact
Types of changes
not work as expected)