Repository navigation
[Agent] WebRTC: fix ICE gathering/trickle and remove dead signaling code #659
Copy link
Copy link
Closed
Labels
agent-candidateMaintainer-approved issue for a managed agent PR; merge stays manualMaintainer-approved issue for a managed agent PR; merge stays manualenhancementNew feature or requestNew feature or requestjavascriptPull requests that update javascript codePull requests that update javascript code
Description
Problem and evidence
web/js/components/preact/WebRTCVideoCell.jsx contains a commented-out trickle-ICE block at ~732-743, which POSTs to /api/webrtc/ice, a route that doesn't exist in LightNVR or go2rtc's HTTP API. Its comment says "If trickle ICE is needed, uncomment the code below". Signaling today is a single HTTP POST {go2rtcBaseUrl}/api/webrtc?src=... with the SDP offer (~814).
Two related cleanups:
- The log says "waiting for ICE gathering...", but it isn't clear whether the code actually waits for
iceGatheringState === 'complete'before sending the offer. If it doesn't, the offer may carry no host or srflx candidates. If it does, connecting is slow on networks where gathering stalls (unreachable STUN/TURN gives a timeout of several seconds). pc.onicecandidateand nearby code log every candidate withconsole.logfor each cell, which is noisy on a 16-camera grid.
Expected behavior and scope
- Find out and document what the current flow does: offer sent before or after gathering, and measured time-to-first-frame on LAN.
- Pick one, and explain why in the PR:
- (a) Real trickle ICE over go2rtc's WebSocket signaling (
/api/ws?src=..., which acceptswebrtc/offerandwebrtc/candidatemessages), proxied through the existing/go2rtc/path; or - (b) Bounded gathering: send the offer when gathering completes or after a short timeout (for example 1 s) with whatever candidates exist.
- (a) Real trickle ICE over go2rtc's WebSocket signaling (
- Delete the dead commented block, and move per-candidate logs behind a debug flag (follow existing debug-log conventions if any).
Acceptance criteria
- Time-to-first-frame on LAN is no worse, and is better when STUN is unreachable (simulate with a bogus ICE server from
/api/ice-servers). - WebRTC still connects through the go2rtc proxy path, both with and without authentication.
- No dead commented code is left, and the console is quiet by default.
Validation
cd web && npx vite build,npm run lint,npm test.- Manual check in Chrome and Firefox against a running instance. Include before and after timings in the PR.
Constraints and rollback
- Frontend only, unless option (a) needs a WebSocket proxy route the backend doesn't already forward. In that case, say so in the PR and keep the backend change minimal.
- Rollback: revert.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
agent-candidateMaintainer-approved issue for a managed agent PR; merge stays manualMaintainer-approved issue for a managed agent PR; merge stays manualenhancementNew feature or requestNew feature or requestjavascriptPull requests that update javascript codePull requests that update javascript code
Activity
WebRTC: bounded ICE gathering and remove dead signaling code (#659)