livekit / client-sdk-flutter

Flutter Client SDK for LiveKit
https://docs.livekit.io
Apache License 2.0
256 stars 127 forks source link

[bug][iOS] Hardware.onDeviceChange stream is updated occasionally #206

Open janoskranczler opened 1 year ago

janoskranczler commented 1 year ago

Hardware.onDeviceChange StreamController is only updated occasionally.

I've debugged it and found that for some reason the FlutterWebRTCEventChannel.handleEvents StreamController not updated on every audio device change: https://github.com/flutter-webrtc/flutter-webrtc/blob/1dcb8223355dc58db0852e2df19f8514e9b4cd0d/lib/src/native/event_channel.dart#L15-L16

To Reproduce

  1. Use a physical device and listen to the onDeviceChange (Hardware.instance.onDeviceChange.stream.listen()) with a listener method.
  2. Connect a Bluetooth audio device to your phone and check if the listener method is called after the connection.
  3. Disconnect and check again.
  4. Repeat it a few times because for the first time it will probably work, but after that, it won't.

Expected behavior The onDeviceChange listener method is called for every new audio connected or disconnected.

Platform information

cloudwebrtc commented 1 year ago

The onDeviceChange event should be fired when a new device is connected or an old device is disconnected.

https://github.com/flutter-webrtc/flutter-webrtc/blob/main/common/darwin/Classes/FlutterWebRTCPlugin.m#L139-L143

Strange, it should be listened to when FlutterWebRTCEventChannel.instace is obtained for the first time.