A realtime agent sometimes crashes with a segfault right as the session starts, when two threads create an rtc.AudioResampler at the same moment. It happened in 3 of 10 local runs for us.
The two threads are Google realtime's input path on the main thread and the session recorder's encode thread:
Current thread (most recent call first):
livekit/rtc/_ffi_client.py, line 295 in request
livekit/rtc/audio_resampler.py, line 71 in __init__
livekit/plugins/google/realtime/realtime_api.py, line 1668 in _resample_audio
livekit/plugins/google/realtime/realtime_api.py, line 792 in push_audio
livekit/agents/voice/agent_activity.py, line 1680 in push_audio
Thread (recorder_io encode thread):
livekit/rtc/_ffi_client.py, line 295 in request
livekit/rtc/audio_resampler.py, line 71 in __init__
livekit/agents/voice/recorder_io/recorder_io.py, line 88 in _resample
livekit/agents/voice/recorder_io/recorder_io.py, line 105 in push
livekit/agents/voice/recorder_io/recorder_io.py, line 299 in _encode_thread
Fatal Python error: Segmentation fault
Versions: livekit 1.1.18, livekit-agents 1.8.2, livekit-plugins-google 1.8.2, Python 3.12.14, macOS arm64.
Starting the session with record={"audio": False} avoids it, since no recorder thread is created. Is livekit_ffi_request meant to be safe when resamplers are created from two threads at once?
A realtime agent sometimes crashes with a segfault right as the session starts, when two threads create an
rtc.AudioResamplerat the same moment. It happened in 3 of 10 local runs for us.The two threads are Google realtime's input path on the main thread and the session recorder's encode thread:
Versions: livekit 1.1.18, livekit-agents 1.8.2, livekit-plugins-google 1.8.2, Python 3.12.14, macOS arm64.
Starting the session with
record={"audio": False}avoids it, since no recorder thread is created. Islivekit_ffi_requestmeant to be safe when resamplers are created from two threads at once?