client-sdk-flutter icon indicating copy to clipboard operation
client-sdk-flutter copied to clipboard

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

Open janoskranczler opened this issue 3 years ago • 1 comments

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

  • Flutter version: [✓] Flutter (Channel stable, 3.3.7, on macOS 13.0 22A380 darwin-arm, locale en-HU) • Flutter version 3.3.7 on channel stable at /Users/janoskranczler/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision e99c9c7cd9 (9 days ago), 2022-11-01 16:59:00 -0700 • Engine revision 857bd6b74c • Dart version 2.18.4 • DevTools version 2.15.0

  • Plugin version: 1.1.7 - https://github.com/livekit/client-sdk-flutter/commit/22a18d3e9cff352c56870aa723567777855bbf2b

  • Flutter target OS: iOS

  • Flutter target OS version: 16.1

janoskranczler avatar Nov 10 '22 12:11 janoskranczler

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.

cloudwebrtc avatar Nov 10 '22 13:11 cloudwebrtc