Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

when the Bluetooth device disconnecting audioDeviceDidChangeWithFreshAudioDeviceList not triggering (only in IOS) #159

Open
ashirkhanpm opened this issue Sep 21, 2022 · 34 comments
Labels
bug Something isn't working iOS

Comments

@ashirkhanpm
Copy link

ashirkhanpm commented Sep 21, 2022

- (void)audioDeviceDidChangeWithFreshAudioDeviceList:(NSArray<MediaDevice *> * _Nonnull)freshAudioDeviceList
{
  NSLog(@"test-ActiveAudio-list freshAudioDeviceList");
  [_bridge configureActiveAudioDevice:freshAudioDeviceList];
}

Some times above function does not trigger when the Bluetooth device disconnects/turns off the Bluetooth
, but it triggers when the Bluetooth device connecting

Test environment Info (please complete the following information):

  • Device: iPhone 7
  • OS: IOS 15.6.1
  • Version amazon-chime-sdk:0.21.2
  • Version amazon-chime-sdk-media: 0.17.2
@ethanjanadrake
Copy link

Hi @ashirkhanpm ,
Could you provide the steps to reproduce this issue with the RN demo?

@ethanjanadrake ethanjanadrake added Needs More Information Assign after requesting information iOS labels Sep 21, 2022
@ashirkhanpm
Copy link
Author

ashirkhanpm commented Sep 22, 2022

Hi @ethanjanadrake

I can able to reproduce this issue with the RN demo, but it happens sometimes only.

steps to reproduce:

  1. clone and set up the react native demo project.
  2. added the DeviceChangeObserver in the bridge file by referring the link feat/use loudspeaker #93
  • Added DeviceChangeObserver in RNDemo/MeetingObservers.h and
  • Added - (void)audioDeviceDidChangeWithFreshAudioDeviceList:(NSArray<MediaDevice *> * _Nonnull)freshAudioDeviceList { [_bridge configureActiveAudioDevice:freshAudioDeviceList]; } in RNDemo/MeetingObservers.m file

then added [meetingSession.audioVideo addDeviceChangeObserverWithObserver:observer]; in -(void)startVideo {} inside RNDemo/NativeMobileSDKBridge.m file

  1. then connect the Bluetooth audio device to the phone and join an existing meeting through the demo app
  2. and I got the log value inside the audioDeviceDidChangeWithFreshAudioDeviceList the first time, but when I disconnect or turn off Bluetooth didn't get the log (but sometimes got the log of disconnection)

Screenshot 2022-09-22 at 2 44 07 PM

@ethanjanadrake ethanjanadrake removed the Needs More Information Assign after requesting information label Sep 22, 2022
@ashirkhanpm
Copy link
Author

ashirkhanpm commented Sep 30, 2022

Hi @ethanjanadrake
did you get this issue on the demo app, any update?

@stale
Copy link

stale bot commented Oct 9, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the inactive label Oct 9, 2022
@ashirkhanpm
Copy link
Author

hi,
any update?

@stale stale bot removed the inactive label Oct 12, 2022
@hokyungh
Copy link
Contributor

Hi @ashirkhanpm, sorry for the late reply. When bluetooth device is connected, do you hear audio from the bluetooth? You can also check it by calling getActiveAudioDevice.

If current device is not bluetooth device, disconnecting does not trigger routeChangeNotification as implemented in our DefaultDeviceController, which resulted in not calling audioDeviceDidChangeWithFreshAudioDeviceList.

@ashirkhan94
Copy link

ashirkhan94 commented Oct 17, 2022

Hi @hokyungh,
Yes, I can hear audio through bluetooth, before device was disconnected,
But the audioDeviceDidChangeWithFreshAudioDeviceList is not called,
Is there any other observer function available for detecting audio route change?

@hokyungh
Copy link
Contributor

Hi @ashirkhan94 , how did you disconnect bluetooth and what bluetooth device do you use? One of our teammates wasn't able to reproduce, so just wanted to see if you have another bluetooth device you can try to test.

@ashirkhan94
Copy link

Hi @hokyungh ,
I disconnect by bluetooth device disconnect option in phone, using Wireless Earbuds (boAt Airdopes 411 ANC), I have facing same issue when tried with another device

@stale
Copy link

stale bot commented Nov 1, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the inactive label Nov 1, 2022
@ashirkhan94
Copy link

Hi, Any update

@hokyungh
Copy link
Contributor

hokyungh commented Nov 4, 2022

Sorry for the late reply. I'll try on my device and get back to you.

But before I testing, are you using

-(void)configureActiveAudioDevice:(NSArray<MediaDevice *> * _Nonnull)audioDeviceList

  __block BOOL isHeadsetPluggedIn = false;

  // Judge useing headohone, if current routes has one or more headphones port.
   [currentOutputs enumerateObjectsUsingBlock:^(AVAudioSessionPortDescription *output, NSUInteger idx, BOOL *stop) {
     if([output.portType isEqual:AVAudioSessionPortHeadphones]){
       isHeadsetPluggedIn = true;
     }
   }];

  // If wiredHeadset connected, use Build-in receiver
  if(isHeadsetPluggedIn)
  {
    // use Build-in receiver
    [meetingSession.audioVideo chooseAudioDeviceWithMediaDevice:[audioDeviceList firstObject]];
  } else {
    // use loud speaker (or other device)
    [meetingSession.audioVideo chooseAudioDeviceWithMediaDevice:[audioDeviceList lastObject]];
  }
}

too?

Just wanted to see if you can add a logic to select bluetooth device.

@stale stale bot removed the inactive label Nov 4, 2022
@ashirkhan94
Copy link

ashirkhan94 commented Nov 10, 2022

Hi, @hokyungh
I am using below logic

-(void)configureActiveAudioDevice:(NSArray<MediaDevice *> * _Nonnull)audioDeviceList
{
  NSLog(@"test-ActiveAudio-list  currentoutput: %ld%ld" ,[[audioDeviceList firstObject]type],[[audioDeviceList lastObject]type]);
  if([[audioDeviceList firstObject]type]==0||[[audioDeviceList firstObject]type]==1)
     {
       NSLog(@"test-ActiveAudio-list  if value2: %@" ,[audioDeviceList firstObject]);
       [meetingSession.audioVideo chooseAudioDeviceWithMediaDevice:[audioDeviceList firstObject]];
       [self sendEventWithName:KEventonGetActiveAudioDevice body:@([[audioDeviceList firstObject] type])];
     } else {
       NSLog(@"test-ActiveAudio-list  else value3: %@" ,[audioDeviceList lastObject]);
       [meetingSession.audioVideo chooseAudioDeviceWithMediaDevice:[audioDeviceList lastObject]];
       [self sendEventWithName:KEventonGetActiveAudioDevice body:@([[audioDeviceList lastObject] type])];
     }
}

but my issue is audioDeviceDidChangeWithFreshAudioDeviceList function not triggering some times, when i disconnect bluetooth device

- (void)audioDeviceDidChangeWithFreshAudioDeviceList:(NSArray<MediaDevice *> * _Nonnull)freshAudioDeviceList
{
  NSLog(@"test-ActiveAudio-list freshAudioDeviceList");
  [_bridge configureActiveAudioDevice:freshAudioDeviceList];
}

@hokyungh
Copy link
Contributor

Could you try with https://github.com/aws-samples/amazon-chime-react-native-demo/tree/use-device and see if it works for you?

@ashirkhan94
Copy link

ashirkhan94 commented Nov 18, 2022

Hi, @hokyungh
It's not working, i tried with above changes.
The audio is routing successfully when we connect or disconnect bluetooth device, but some times can't able to change the icons, means if we disconnect bluetooth device the audio is flowing through earpiece, but the icon showing is bluetooth icon, not earpiece icon, because the audioDeviceDidChangeWithFreshAudioDeviceList is not trigger some times .

- (void)audioDeviceDidChangeWithFreshAudioDeviceList:(NSArray<MediaDevice *> * _Nonnull)freshAudioDeviceList
{
  NSLog(@"test-ActiveAudio-list freshAudioDeviceList");
  [_bridge configureActiveAudioDevice];
}

@hokyungh
Copy link
Contributor

Hi @ashirkhan94, do you mind explaining the case where it is not working? We have a report on aws/amazon-chime-sdk-ios#242, and there is case where if you are on different device and disconnect bluetooth, it won't get callback, which we have reported to Apple.

@ashirkhan94
Copy link

ashirkhan94 commented Nov 22, 2022

Hi @hokyungh,
Case:
Connect the bluetooth device and the audio flowing through the bluetooth device, then
I disconnect the bluetooth device using 3 ways

  1. turn off bluetooth in phone , but audioDeviceDidChangeWithFreshAudioDeviceList was not trigger
    IMG_0075

  2. Disconnect the Bluetooth device from phone, but audioDeviceDidChangeWithFreshAudioDeviceList was not trigger
    IMG_0074

  3. closed the earBud box, then device disconnected from phone, but audioDeviceDidChangeWithFreshAudioDeviceList was not trigger

In my case the disconnected time audio is not flowing through different device, audio is on bluetooth device.

@stale
Copy link

stale bot commented Dec 3, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the inactive label Dec 3, 2022
@ashirkhan94
Copy link

Hi
any update

@stale stale bot removed the inactive label Dec 12, 2022
@hokyungh
Copy link
Contributor

Sorry for late reply. Could you try with our demo application to see if you are getting the log?

@stale
Copy link

stale bot commented Jan 2, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the inactive label Jan 2, 2023
@ashirkhan94
Copy link

Sorry for late reply. Could you try with our demo application to see if you are getting the log?

Yes I already tried with the demo application
#159 (comment)

@stale stale bot removed the inactive label Jan 2, 2023
@ashirkhan94
Copy link

Hi,
Any update?

@hokyungh
Copy link
Contributor

Hi sorry for late reply. I couldn't reproduce with our demo application, so I am getting new bluetooth earphone to test again.

@stale
Copy link

stale bot commented Jan 21, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the inactive label Jan 21, 2023
@ashirkhan94
Copy link

Hi @hokyungh
any update

@hokyungh
Copy link
Contributor

Hi I have tried all three test cases you posted with new bluetooth device, but only the third case I wasn't able to reproduce. We'll have to look into the third case, but for the first two cases, I hear beeping sound disconnecting and able to get audioDeviceDidChangeWithFreshAudioDeviceList callback. Let me mark it as bug.

@stale stale bot removed the inactive label Jan 24, 2023
@hokyungh hokyungh added the bug Something isn't working label Jan 24, 2023
@AlkanV
Copy link

AlkanV commented Feb 14, 2023

hello any news on this?
@hokyungh

@hokyungh
Copy link
Contributor

Hi @AlkanV, we filed a ticket to apple and waiting for their reply.

@AlkanV
Copy link

AlkanV commented Feb 15, 2023

@hokyungh thank you for lightning fast response.

@ashirkhan94
Copy link

Hi @hokyungh
Any update ?

@salimkt
Copy link

salimkt commented May 9, 2023

Hi @hokyungh
Still having this issue.Any progress on this?

@hokyungh
Copy link
Contributor

hokyungh commented May 9, 2023

Hi sorry, we haven't got reply yet. We might need to implement short-term mitigation to fix this issue.

@shivam-kakkar27
Copy link

@hokyungh Hi, Any update on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working iOS
Projects
None yet
Development

No branches or pull requests

7 participants