Skip to content

Since SDK v2.19.0, built-in AEC cannot be used: Platform AEC state can't be modified while recording #796

@ypedegroot

Description

@ypedegroot

Describe the bug
Since SDK v2.19.0, built-in AEC cannot be used.

Among users of my app, I have noticed complaints of typical AEC and NS related issues: chirping, echo and chunky audio in full-duplex situations. I only have these complaints in my app version using SDK v2.19.0 (and higher). In the previous version of my app I used SDK v2.18.3. Using LiveKit SDK v2.18.3, no such complaints were received.

Indeed, I am able to reproduce these audible issues myself. I have now dug a bit deeper and have found that the built-in AEC support in LiveKit SDK v2.19.0 and up is different from LiveKit SDK v2.18.3. I will provide context and logging output in this issue.

To Reproduce
Steps to reproduce the behavior described above with SDK v2.19.0:

  1. Use LiveKit Android SDK v2.19.0 in an Android project
  2. Enable WebRTC logging using LiveKit.loggingLevel = LoggingLevel.VERBOSE and LiveKit.enableWebRTCLogging = true
  3. Observe that, when starting the app, these entries in the log will be displayed:
JavaAudioDeviceModule: HW AEC will be used.
WebRtcAudioRecordExternal: enableBuiltInAEC(false)
WebRtcAudioEffectsExternal: setAEC(false)
  1. When, later on, actually creating a Room and using it (in my case, starting a phone call), observe that we see this in the log (when using aec as the log filter):
2025-11-09 14:08:33.768 30092-30120 Timber                  com.example.app                       I  [RTCModule] JavaAudioDeviceModule: HW AEC will be used.
2025-11-09 14:08:33.785 30092-30338 Timber                  com.example.app                       I  [RTCModule] webrtc_voice_engine.cc: (line 594): WebRtcVoiceEngine::ApplyOptions: AudioOptions {aec: 0, agc: 0, ns: 0, hf: 0, swap: 0, audio_jitter_buffer_max_packets: 200, audio_jitter_buffer_fast_accelerate: 0, audio_jitter_buffer_min_delay_ms: 0, }
2025-11-09 14:08:33.785 30092-30338 Timber                  com.example.app                       I  [RTCModule] audio_record_jni.cc: (line 216): EnableBuiltInAEC(0)
2025-11-09 14:08:33.785 30092-30338 Timber                  com.example.app                       I  [RTCModule] WebRtcAudioRecordExternal: enableBuiltInAEC(false)
2025-11-09 14:08:33.785 30092-30338 Timber                  com.example.app                       I  [RTCModule] WebRtcAudioEffectsExternal: setAEC(false)
2025-11-09 14:08:34.480 30092-30338 Timber                  com.example.app                       I  [RTCModule] webrtc_voice_engine.cc: (line 1270): Setting voice channel options: AudioOptions {aec: 1, agc: 1, ns: 1, hf: 1, }
2025-11-09 14:08:34.480 30092-30338 Timber                  com.example.app                       I  [RTCModule] webrtc_voice_engine.cc: (line 594): WebRtcVoiceEngine::ApplyOptions: AudioOptions {aec: 1, agc: 1, ns: 1, hf: 1, audio_jitter_buffer_max_packets: 200, audio_jitter_buffer_fast_accelerate: 0, audio_jitter_buffer_min_delay_ms: 0, }
2025-11-09 14:08:34.480 30092-30338 Timber                  com.example.app                       I  [RTCModule] audio_record_jni.cc: (line 216): EnableBuiltInAEC(1)
2025-11-09 14:08:34.480 30092-30338 Timber                  com.example.app                       I  [RTCModule] WebRtcAudioRecordExternal: enableBuiltInAEC(true)
2025-11-09 14:08:34.480 30092-30338 Timber                  com.example.app                       I  [RTCModule] WebRtcAudioEffectsExternal: setAEC(true)
2025-11-09 14:08:34.480 30092-30338 Timber                  com.example.app                       E  [RTCModule] WebRtcAudioEffectsExternal: Platform AEC state can't be modified while recording
2025-11-09 14:08:34.481 30092-30338 Timber                  com.example.app                       I  [RTCModule] webrtc_voice_engine.cc: (line 1284): Set voice send channel options. Current options: AudioOptions {aec: 1, agc: 1, ns: 1, hf: 1, audio_jitter_buffer_max_packets: 200, audio_jitter_buffer_fast_accelerate: 0, audio_jitter_buffer_min_delay_ms: 0, }
2025-11-09 14:08:34.547 30092-30338 Timber                  com.example.app                       I  [RTCModule] webrtc_voice_engine.cc: (line 594): WebRtcVoiceEngine::ApplyOptions: AudioOptions {aec: 1, agc: 1, ns: 1, hf: 1, audio_jitter_buffer_max_packets: 200, audio_jitter_buffer_fast_accelerate: 0, audio_jitter_buffer_min_delay_ms: 0, }
2025-11-09 14:08:34.547 30092-30338 Timber                  com.example.app                       I  [RTCModule] audio_record_jni.cc: (line 216): EnableBuiltInAEC(1)
2025-11-09 14:08:34.548 30092-30338 Timber                  com.example.app                       I  [RTCModule] WebRtcAudioRecordExternal: enableBuiltInAEC(true)
2025-11-09 14:08:34.548 30092-30338 Timber                  com.example.app                       I  [RTCModule] WebRtcAudioEffectsExternal: setAEC(true)
2025-11-09 14:08:34.548 30092-30338 Timber                  com.example.app                       E  [RTCModule] WebRtcAudioEffectsExternal: Platform AEC state can't be modified while recording
2025-11-09 14:08:34.549 30092-30338 Timber                  com.example.app                       I  [RTCModule] webrtc_voice_engine.cc: (line 1284): Set voice send channel options. Current options: AudioOptions {aec: 1, agc: 1, ns: 1, hf: 1, audio_jitter_buffer_max_packets: 200, audio_jitter_buffer_fast_accelerate: 0, audio_jitter_buffer_min_delay_ms: 0, }
2025-11-09 14:08:34.549 30092-30338 Timber                  com.example.app                       I  [RTCModule] webrtc_voice_engine.cc: (line 594): WebRtcVoiceEngine::ApplyOptions: AudioOptions {aec: 1, agc: 1, ns: 1, hf: 1, audio_jitter_buffer_max_packets: 200, audio_jitter_buffer_fast_accelerate: 0, audio_jitter_buffer_min_delay_ms: 0, }
2025-11-09 14:08:34.549 30092-30338 Timber                  com.example.app                       I  [RTCModule] audio_record_jni.cc: (line 216): EnableBuiltInAEC(1)
2025-11-09 14:08:34.549 30092-30338 Timber                  com.example.app                       I  [RTCModule] WebRtcAudioRecordExternal: enableBuiltInAEC(true)
2025-11-09 14:08:34.549 30092-30338 Timber                  com.example.app                       I  [RTCModule] WebRtcAudioEffectsExternal: setAEC(true)
2025-11-09 14:08:34.549 30092-30338 Timber                  com.example.app                       E  [RTCModule] WebRtcAudioEffectsExternal: Platform AEC state can't be modified while recording

Specifically, the statements enableBuiltInAEC(true) and setAEC(true), follwed by the error Platform AEC state can't be modified while recording are interesting. This behaviour does not occur when using LiveKit SDK v2.18.3.

Expected behavior
Expected behaviour is what we see when using LiveKit SDK v2.18.3.

When starting the app:

JavaAudioDeviceModule: HW AEC will be used.
WebRtcAudioRecordExternal: enableBuiltInAEC(true)
WebRtcAudioEffectsExternal: setAEC(true)

When later on creating a Room and using it:

2025-11-09 14:11:03.390 30681-30724 Timber                  com.example.app                       I  [RTCModule] JavaAudioDeviceModule: HW AEC will be used.
2025-11-09 14:11:03.408 30681-30902 Timber                  com.example.app                       I  [RTCModule] webrtc_voice_engine.cc: (line 478): WebRtcVoiceEngine::ApplyOptions: AudioOptions {aec: 1, agc: 1, ns: 1, hf: 1, swap: 0, audio_jitter_buffer_max_packets: 200, audio_jitter_buffer_fast_accelerate: 0, audio_jitter_buffer_min_delay_ms: 0, }
2025-11-09 14:11:03.408 30681-30902 Timber                  com.example.app                       I  [RTCModule] audio_record_jni.cc: (line 215): EnableBuiltInAEC(1)
2025-11-09 14:11:03.408 30681-30902 Timber                  com.example.app                       I  [RTCModule] WebRtcAudioRecordExternal: enableBuiltInAEC(true)
2025-11-09 14:11:03.408 30681-30902 Timber                  com.example.app                       I  [RTCModule] WebRtcAudioEffectsExternal: setAEC(true)
2025-11-09 14:11:04.096 30681-30902 Timber                  com.example.app                       I  [RTCModule] webrtc_voice_engine.cc: (line 1236): Setting voice channel options: AudioOptions {aec: 1, agc: 1, ns: 1, hf: 1, }
2025-11-09 14:11:04.096 30681-30902 Timber                  com.example.app                       I  [RTCModule] webrtc_voice_engine.cc: (line 478): WebRtcVoiceEngine::ApplyOptions: AudioOptions {aec: 1, agc: 1, ns: 1, hf: 1, audio_jitter_buffer_max_packets: 50, audio_jitter_buffer_fast_accelerate: 0, audio_jitter_buffer_min_delay_ms: 0, }
2025-11-09 14:11:04.097 30681-30902 Timber                  com.example.app                       I  [RTCModule] audio_record_jni.cc: (line 215): EnableBuiltInAEC(1)
2025-11-09 14:11:04.097 30681-30902 Timber                  com.example.app                       I  [RTCModule] WebRtcAudioRecordExternal: enableBuiltInAEC(true)
2025-11-09 14:11:04.097 30681-30902 Timber                  com.example.app                       I  [RTCModule] WebRtcAudioEffectsExternal: setAEC(true)
2025-11-09 14:11:04.098 30681-30902 Timber                  com.example.app                       I  [RTCModule] webrtc_voice_engine.cc: (line 1250): Set voice send channel options. Current options: AudioOptions {aec: 1, agc: 1, ns: 1, hf: 1, audio_jitter_buffer_max_packets: 50, audio_jitter_buffer_fast_accelerate: 0, audio_jitter_buffer_min_delay_ms: 0, }
2025-11-09 14:11:04.155 30681-30902 Timber                  com.example.app                       I  [RTCModule] webrtc_voice_engine.cc: (line 478): WebRtcVoiceEngine::ApplyOptions: AudioOptions {aec: 1, agc: 1, ns: 1, hf: 1, audio_jitter_buffer_max_packets: 50, audio_jitter_buffer_fast_accelerate: 0, audio_jitter_buffer_min_delay_ms: 0, }
2025-11-09 14:11:04.155 30681-30902 Timber                  com.example.app                       I  [RTCModule] audio_record_jni.cc: (line 215): EnableBuiltInAEC(1)
2025-11-09 14:11:04.155 30681-30902 Timber                  com.example.app                       I  [RTCModule] WebRtcAudioRecordExternal: enableBuiltInAEC(true)
2025-11-09 14:11:04.156 30681-30902 Timber                  com.example.app                       I  [RTCModule] WebRtcAudioEffectsExternal: setAEC(true)
2025-11-09 14:11:04.157 30681-30902 Timber                  com.example.app                       I  [RTCModule] webrtc_voice_engine.cc: (line 1250): Set voice send channel options. Current options: AudioOptions {aec: 1, agc: 1, ns: 1, hf: 1, audio_jitter_buffer_max_packets: 50, audio_jitter_buffer_fast_accelerate: 0, audio_jitter_buffer_min_delay_ms: 0, }
2025-11-09 14:11:04.175 30681-30902 Timber                  com.example.app                       I  [RTCModule] webrtc_voice_engine.cc: (line 478): WebRtcVoiceEngine::ApplyOptions: AudioOptions {aec: 1, agc: 1, ns: 1, hf: 1, audio_jitter_buffer_max_packets: 50, audio_jitter_buffer_fast_accelerate: 0, audio_jitter_buffer_min_delay_ms: 0, }
2025-11-09 14:11:04.175 30681-30902 Timber                  com.example.app                       I  [RTCModule] audio_record_jni.cc: (line 215): EnableBuiltInAEC(1)
2025-11-09 14:11:04.176 30681-30902 Timber                  com.example.app                       I  [RTCModule] WebRtcAudioRecordExternal: enableBuiltInAEC(true)
2025-11-09 14:11:04.176 30681-30902 Timber                  com.example.app                       I  [RTCModule] WebRtcAudioEffectsExternal: setAEC(true)

It looks like, with LiveKit SDK v2.19.0, the built-in AEC gets disabled and, as a result, cannot be used at any point later in the code, resulting in bad audio quality in terms of AEC, NS and full-duplex. This behaviour does not change, whether or not the javaAudioDeviceModuleCustomizer is used.

To be clear: the audio quality in LiveKit SDK v2.18.3 is very good in terms of AEC and NS. From LiveKit SDK v2.19.0, the audio quality in terms of AEC and NS is very poor. The built-in AEC yields the best results and I want to use that in the app.

Device Info:

  • Device: Samsung XCover 6 Pro
  • OS: Android 16
  • LiveKit SDK version: v2.19.0 (also happens in newer versions)

Additional context
In the release notes, I can read that the underlying libwebrtc versions are as follows:

LiveKit SDK v2.18.3 -> libwebrtc v125.6422.07
LiveKit SDK v2.19.0 -> libwebrtc v137.7151.01
LiveKit SDK v2.20.0 -> libwebrtc v137.7151.03

My suspicion is that in the update from libwebrtc v125.6422.07 to v137.7151.01, something fundamental has changed. Any help on this topic is greatly appreciated.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions