Concurrent transport teardown: cleanUp() nulls publisher/subscriber after awaiting dispose()
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Tranquilo
- Área
- audio-video-rtc, mobile
Línea de trabajo
Start with test/race/teardown_race_test.dart to reproduce the concurrent teardown, then read engine.dart around cleanUp() and restartConnection(), plus room.dart around _cleanUp() and listener creation. Compare the race scenarios with the transport disposal paths; done means concurrent pc.close() calls are serialized and the regression test passes.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Environment
livekit_client 2.11.0 · flutter_webrtc 1.6.0 · reproduced in the package's own test harness (no device needed)
Summary
Engine.cleanUp() nulls the transport fields after awaiting dispose():
await publisher?.dispose(); // engine.dart:289 — suspends inside pc.close()
publisher = null; // engine.dart:290 — only after it returns
A concurrent caller entering during that await still sees publisher non-null and calls dispose() on the same object. Disposable correctly guards the second dispose of the same transport — but that guard returns immediately, so the second cleanUp() overtakes the first and tears down the other transport while the first is still inside pc.close(). Two RTCPeerConnection.close() calls end up in flight at once, which never happens when the paths run sequentially.
Three uncoordinated writers touch those fields: cleanUp() (:289), restartConnection() (:1211-1217, a near-copy), and Room._cleanUp() via :1079. Room's engine listener is created with createListener() (room.dart:183) — unsynchronized — so Room's handlers do not serialize either.
Reproduction
test/race/teardown_race_test.dart on the branch below. Real Room + real Engine, mock socket and peer connection; the tracing peer connection's close() spans several event-loop turns to model the blocking native close.
| scenario | concurrent pc.close |
double-dispose |
|---|---|---|
| S1 give-up branch alone | 1 | 0 |
S2 give-up ‖ room.dispose() |
2 | 2 |
S3 pending reconnect + disconnect() |
1 | 0 |
S4 two EngineDisconnectedEvents |
2 | 2 |
S2 is ordinary public API: the SDK gives up reconnecting while the app disposes the Room. S4 is reachable because the give-up branch never sets _isClosed = true (unlike :1014 and :1473), leaving the engine free to emit a second disconnect.
Your own log line is the tell — the baseline run prints !! [Transport#…] unnecessary dispose() called. (disposable.dart:55).
A fix that looks sufficient and is not
Locking cleanUp() alone still fails S2, because restartConnection() bypasses it. Confirmed by intervention, not by reasoning.
Suggested fix (branch ready, happy to open a PR)
Extract _disposeTransportsLocked() that detaches before awaiting, route cleanUp() and restartConnection() through one Engine lock, and give Room._cleanUp() its own. synchronized is already a direct dependency (used by event.dart).
The probe fails on pristine v2.11.0, passes with the change, and the full suite stays green (402 passed).
Branch: https://github.com/Kyra-H-I/client-sdk-flutter/tree/fix/serialize-transport-teardown
What we have not established
Whether this causes a specific native crash. We hit an iOS EXC_BAD_ACCESS that turned out to be a separate, already-fixed WebRTC-SDK bug (webrtc-sdk/webrtc@f47af7bc9658, shipped in 144.7559.10). This race may be a trigger for that class of fault — the faulting path requires a redundant stop — but we cannot prove it, and we are reporting the race on its own merits.
- Lenguaje dominante
- Dart
- Estrellas
- 421
- Forks
- 260
- Merge medio
- 2 d 5 h
- PR fusionados (30 d)
- 17
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de livekit/client-sdk-flutter
-
`jwtPayload.video` returns null grants for tokens from LiveKit server SDKsPosiblemente ocupada @RaphaelFakhri la tomó hace 4 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
livekit/client-sdk-flutter#1236 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
livekit/client-sdk-flutter#1227 ·
Los mantenedores suelen responder en 1 día
-
Inbound data packets never delivered while media flows normally (2.13.0, LiveKit Cloud 1.13.7)Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
livekit/client-sdk-flutter#1221 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 30/100
livekit/client-sdk-flutter#1219 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
iOS: `audioDeviceModule` becomes permanently `nil`/unavailable after backgrounding, even though `AVAudioSession` is never interruptedPosiblemente ocupada @hiroshihorie la tomó hace 30 días. Abierto
livekit/client-sdk-flutter#1206 · 2 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de livekit/client-sdk-flutter
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
[Bug]: The daily reminder keeps its old language after the app language changesPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertobacklog:low bug localization
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
simonoppowa/OpenNutriTracker#1366 ·
Los mantenedores suelen responder en 1 día
-
Mobile reading view shows a sender without display name as "<[email protected]>" with angle bracketsAbiertoai-driven-qa bug Cosmetic
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
linagora/tmail-flutter#4999 ·
Los mantenedores suelen responder en 1 día
-
waiting for response
Dificultad 2/5 Menos de una hora Aptitud para principiantes 72/100
flutter/flutter#194381 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
newrelic/newrelic-flutter-agent#243 · 3 comentarios ·