Skip to content

[Web] WebRTC: teardown incorreto e vazamentos de peer connections/streams #59

Description

@ggfto

Contexto

Auditoria de bugs (ver BUGS_AUDIT.md). Ciclo de vida do WebRTC no frontend NUI — teardown incorreto e vazamentos de peer connections/streams.

Problemas

  • W-01 🔴 web/src/components/WebRTCStreamer.tsx:195 — o efeito principal tem gameData nas deps (}, [on, off, sendNui, gameData])). gameData muda de identidade a cada mensagem NUI, então o cleanup fecha todas as peer connections a cada push de dados → stream morre sem reiniciar.
  • W-05 🟠 web/src/components/players/ScreenModal.tsx:85-90 (idem LiveScreensPage.tsx:45-50) — o guard lê o ref selfIdRef.current mas as deps só têm URL/provider; se selfId chega após o mount, o efeito nunca re-roda → viewer nunca registra, "connecting" eterno.
  • W-06 🟠 web/src/utils/signaling/fivem-native.ts:50-63connect() com novo playerId sobrescreve this._listener sem removeEventListener → sinais despachados N× + vazamento de listener. Relacionado: websocket.ts:44 (if (this.ws) return ignora reconfiguração) e signaling.init troca _active sem disconnect() do provider antigo.
  • W-07 🟠 web/src/components/WebRTCStreamer.tsx:169-176 + utils/fivem-renderer.js:61-73 — substituição de startHandler não chama stopStream() antes de startStream() → watcher count fica >0 e o loop WebGL de captura roda para sempre. Idem :72-145: falhas antes de connectionsRef.set(...) (ex.: publishToCF em cf-sfu.ts:70-87) vazam a peer connection.

Severidade: 🔴 Alto — IDs: W-01, W-05, W-06, W-07

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingwebNUI web frontend (React/TS)

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions