Skip to content

Commit 8238c5c

Browse files
authored
fix: Fix creation timing for local participant. (livekit#749)
1 parent 90c6cfd commit 8238c5c

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lib/src/core/room.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,14 @@ class Room extends DisposableChangeNotifier with EventsEmittable<RoomEvent> {
668668
// trigger change notifier only if list of participants membership is changed
669669
var hasChanged = false;
670670
for (final info in updates) {
671+
// The local participant is not ready yet, waiting for the
672+
// `RoomConnectedEvent` to create the local participant.
673+
if (_localParticipant == null) {
674+
await events.waitFor<RoomConnectedEvent>(
675+
duration: const Duration(seconds: 10),
676+
);
677+
}
678+
671679
if (localParticipant?.identity == info.identity) {
672680
await localParticipant?.updateFromInfo(info);
673681
continue;

lib/src/participant/participant.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ abstract class Participant<T extends TrackPublication>
200200

201201
@internal
202202
Future<bool> updateFromInfo(lk_models.ParticipantInfo info) async {
203+
logger.fine('LocalParticipant.updateFromInfo(info: $info)');
203204
if (_participantInfo != null &&
204205
_participantInfo!.sid == info.sid &&
205206
_participantInfo!.version > info.version) {

0 commit comments

Comments
 (0)