Skip to content

[bug] Invalid sequence of ParticipantDisconnectedEvent and TrackUnpublishedEvent events #1051

@Pluxury

Description

@Pluxury

Describe the bug

A room is created in which two participants join. It is IMPORTANT to join with a working microphone or camera. At the moment when one of the participants presses exit, that is, it calls await room.disconnect(); The first participant receives a sequence of events

2026-04-10 14:04:02.534109 [INFO] LiveKitCallBloc: ParticipantDisconnectedEvent: gfb(participant: Chb(sid: PA_7s63SwjomRxV, identity: 0_1775819035719))

2026-04-10 14:04:02.534194 [INFO] LiveKitCallBloc: TrackUnpublishedEvent: jfb(participant: Chb(sid: PA_7s63SwjomRxV, identity: 0_1775819035719), publication: Dhb(sid: TR_VC8KpTuFqLqLtW, source: TrackSource.camera))

Since I am reacting to the information contained by room.remoteParticipants after calling each event, this leads to erroneous processing.

UPD:
I think this is due to the inconsistency of the calls. The result has been
updated = waiting for the result.participant.Update from MINFO(information); line 759
in the Room class, which will eventually lead to the
await removePublishedTrack(sid) call;

At the same time, the disconnected handler is called, in which
await participant.removeAllPublishedTracks(notify: true); is called

To Reproduce

Just create a call and join it. The iOS/android platform

Expected behavior

After ParticipantDisconnectedEvent, it must be guaranteed that there can be no events related to the disconnected participant and room.remoteParticipants not contains disconnected participant

Platform information

  • Flutter version:
    [✓] Flutter (Channel stable, 3.38.5, on macOS 26.2 25C56 darwin-arm64, locale
    ru-RU)
    [✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    [✓] Xcode - develop for iOS and macOS (Xcode 26.2)
    [✓] Chrome - develop for the web
    [✓] Connected device (3 available)
    [✓] Network resources

  • Plugin version: 2.7.0'

  • Flutter target OS: Android/iOS real devices

  • Flutter target OS version:

  • Flutter console log:

[ExLogging] livekit: Chb.updateFromInfo(info: sid: PA_7s63SwjomRxV
identity: 0_1775819035719
state: ACTIVE
metadata: {"UserId":184754,"FirstName":"–Ь–∞—А–Є—П","MiddleName":"–Р–ї–µ–Ї—Б–∞–љ–і—А–Њ–≤–љ–∞","LastName":"–Р–ї–µ—Е–Є–љ–∞"}
joinedAt: 1775819038
name: 0_1775819035719
version: 8
permission: {
  canSubscribe: true
  canPublish: true
  canPublishData: true
  canUpdateMetadata: true
  canSubscribeMetrics: true
}
isPublisher: true
joinedAtMs: 1775819038852
)
2026-04-10 14:04:02.533926 [INFO] [ExLogging] livekit: Lkb#706838020 onDispose()
2026-04-10 14:04:02.533929 [INFO] [ExLogging] livekit: Lkb#706838020.stop()
2026-04-10 14:04:02.534089 [INFO] [ExLogging] livekit: [SignalEvent] Bgb(participants: [sid: PA_7s63SwjomRxV
identity: 0_1775819035719
state: DISCONNECTED
metadata: {"UserId":184754,"FirstName":"–Ь–∞—А–Є—П","MiddleName":"–Р–ї–µ–Ї—Б–∞–љ–і—А–Њ–≤–љ–∞","LastName":"–Р–ї–µ—Е–Є–љ–∞"}
joinedAt: 1775819038
name: 0_1775819035719
version: 9
permission: {
  canSubscribe: true
  canPublish: true
  canPublishData: true
  canUpdateMetadata: true
  canSubscribeMetrics: true
}
isPublisher: true
disconnectReason: CLIENT_INITIATED
joinedAtMs: 1775819038852
])
2026-04-10 14:04:02.534109 [INFO] LiveKitCallBloc: ParticipantDisconnectedEvent: gfb(participant: Chb(sid: PA_7s63SwjomRxV, identity: 0_1775819035719))
2026-04-10 14:04:02.534157 [INFO] [ExLogging] livekit: Lkb#706838020.disable() disabling lcb#53595495...
2026-04-10 14:04:02.534169 [INFO] [ExLogging] livekit: Lkb#706838020.disable() disabling lcb#53595495...
2026-04-10 14:04:02.534171 [INFO] [ExLogging] livekit: [Dhb<Lkb>#579229416] unnecessary dispose() called.
2026-04-10 14:04:02.534194 [INFO] LiveKitCallBloc: TrackUnpublishedEvent: jfb(participant: Chb(sid: PA_7s63SwjomRxV, identity: 0_1775819035719), publication: Dhb<Lkb>(sid: TR_VC8KpTuFqLqLtW, source: TrackSource.camera))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions