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

Inconsistent echo behavior on certain android devices

Open davidzhao opened this issue 3 years ago • 8 comments

Reported in Slack community.

I’m playing a lot with RoomOptions.audioTrackCaptureDefaults flags and with LiveKitOverrides.javaAudioDeviceModuleCustomizer (to set UseHardwareAcousticEchoCanceler and UseHardwareNoiseSuppressor). Sometimes I find combination that seems to solve the problem, but the flags configurations end up being completely different on every device I try. On some other devices I don’t find a working configuration at all.

Examples

  • Samsung S8 (with Android 9): this one generates echo for all the other participants in the room if the audioTrackCaptureDefaults are true, but it doesn’t if they are false
  • pixel 2 we need to enable hardware cancellation not to get echoes & audio artifacts (by setting UseHardwareAcousticEchoCanceler to true in the audio module)

davidzhao avatar Jun 20 '22 07:06 davidzhao

Hello! I think I managed to solve it for all my use cases/devices by not touching the audioTrackCaptureDefaults and only tweaking the setUseHardwareAcousticEchoCanceler() in the JavaAudioDeviceModule. I connect by doing something like this:

LiveKit.connect(
            context, url, token,
            roomOptions = RoomOptions(adaptiveStream = true),
            overrides = LiveKitOverrides(
                javaAudioDeviceModuleCustomizer = { builder ->
                    val useHardwareAudioProcessing = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
                    builder.setUseHardwareAcousticEchoCanceler(useHardwareAudioProcessing)
                        .setUseHardwareNoiseSuppressor(useHardwareAudioProcessing)
                }
            )
        )

symphonybiz avatar Jun 20 '22 13:06 symphonybiz

@symphonybiz If it's not too much trouble, could you list the devices this worked on?

davidliu avatar Jun 20 '22 13:06 davidliu

Sure:

  • Samsung Galaxy S8 (Android 9)
  • Pixel 2 (Android 11)
  • Sony Xperia Z5 Compact (Android 7)
  • Xiaomi Mi 9T (Android 11)

symphonybiz avatar Jun 20 '22 15:06 symphonybiz

@symphonybiz how did you get echo to reproduce? Is this by holding two devices close to each other so they are picking up each other's feedback?

davidzhao avatar Jun 21 '22 05:06 davidzhao

@davidzhao no, actually the opposite. I put one in a different room.

I encountered 2 types of "echo": one is basically a single repetition of what's being said coming back from the offending device, while the other is a very noisy feedback loop. From the Samsung s8 I would get the first type, while from the Sony Xperia I would get the other.

symphonybiz avatar Jun 21 '22 07:06 symphonybiz

@symphonybiz just to confirm, the proposed solution is to turn on the hardware cancellers in devices Q and above?

This issue seems to imply the opposite, so just want to confirm.

davidliu avatar Jun 23 '22 13:06 davidliu

yes @davidliu this is what it seems to work for us: disabling HW cancellation on < API 29

symphonybiz avatar Jun 27 '22 07:06 symphonybiz

@davidliu from my POV this can be closed, because we're using the javaAudioDeviceModuleCustomizer customization above and have no problems now

symphonybiz avatar Aug 04 '22 07:08 symphonybiz