cold-hydrogen-40655
10/17/2025, 12:19 PMtall-airline-16756
10/17/2025, 12:19 PMtall-airline-16756
10/17/2025, 12:21 PMregisterGlobals() and that you’re using Expo development builds instead of Expo Go.
• Connection State Monitoring: Adding proper connection state monitoring in your app can help gracefully handle connection failures and implement retry logic.
• Memory Optimization: Take a look at which LiveKit components you’re using, like STT or TTS, and consider turning off enhanced features such as noise cancellation if they’re not essential.
To better assist you, could you please share a bit more info?
• What memory usage levels are you seeing in your React Native app?
• Are there any specific error messages when the agent can’t join?
• Which agent components (like STT, TTS) are you currently using?
• Are your agents running on your own infrastructure or LiveKit Cloud?
• Can you confirm your Expo app is using development builds rather than Expo Go?
Once I have this information, I’ll be in a much better position to help you find the right solution. Looking forward to your reply!
Sources: Deploying to custom environments | LiveKit Docs | pkg/stats/monitor.go | agents/CHANGELOG.md | livekit-agents/livekit/agents/ipc/supervised_proc.py | docs/functions/LiveKitRoom.htmlcold-hydrogen-40655
10/17/2025, 12:23 PMtall-airline-16756
10/17/2025, 12:25 PMAudioSession class to start and stop sessions as needed — this can really help reduce memory overhead.
• Adaptive Streaming: Consider configuring adaptive streaming to better match your device's capabilities. For instance, using screen pixel density can help handle different screen resolutions more efficiently.
• Background Processing: For Android, setting up a foreground service can keep connections alive in the background. On iOS, make sure to enable the audio and voip background modes in your XCode project.
• Track Management: Cleaning up unused tracks when components unmount is a great way to free up memory. Hooks like useTracks can assist with efficient track rendering.
• Development Build: Double-check that you’re using development builds created with expo-dev-client, since LiveKit isn’t compatible with Expo Go.
Also, since you’re using LiveKit Cloud, it’s a good idea to ensure your agent server has enough memory resources—ideally at least 8GB—to handle the workload comfortably.
Could you please let me know if these suggestions help with the issue? If you’re still seeing problems, feel free to share any specific memory-related symptoms like app crashes, slow performance, or connection drops. Also, letting me know if this happens on both iOS and Android or just one platform will really help me guide you better.
Sources: Expo quickstart | LiveKit Docs | README.md | Deploying to custom environments | LiveKit Docs | README.md | Web and mobile frontends | LiveKit Docscold-hydrogen-40655
10/17/2025, 12:35 PMtall-airline-16756
10/17/2025, 12:35 PMjob_memory_warn_mb and job_memory_limit_mb work in LiveKit to keep an eye on memory usage for each job process:
• `job_memory_warn_mb`: This sets a memory warning threshold (default is 500 MB). If a job process goes over this limit, a friendly warning is logged, but the process keeps running smoothly.
• `job_memory_limit_mb`: This defines the maximum memory a job can use (default is 0, meaning no limit). If a job exceeds this, it’s stopped to avoid hogging too many resources.
These settings are part of LiveKit’s process isolation model, which means if one job uses too much memory and gets stopped, it won’t impact the other agents you have running. This is especially helpful when working with memory-heavy tasks like audio processing or AI model inference.
Since your agent works perfectly in the sample app but not in your own, it might be that your app’s memory use is going beyond these limits. You can easily tweak these parameters in your agent configuration to better fit your app’s needs. For example:
from livekit.agents import WorkerOptions
opts = WorkerOptions(
entrypoint_fnc=your_agent_function,
job_memory_warn_mb=750, # Log warnings at 750 MB
job_memory_limit_mb=1024, # Kill process at 1 GB
)
If you’d like, I’m here to guide you through adjusting these settings in your environment—just let me know!
Sources: livekit-agents/livekit/agents/ipc/proc_pool.pycold-hydrogen-40655
10/17/2025, 12:38 PMtall-airline-16756
10/17/2025, 12:40 PMjob_memory_limit_mb to 0 does disable the memory limit, so it typically shouldn’t cause the agent to hang directly. That said, I understand how frustrating this hanging issue can be, and it might be connected to other parts of the agent lifecycle or the memory monitoring system. Let’s explore a few areas that could be worth checking:
• Process Initialization Timing: Sometimes, even with the limit disabled, the memory monitoring system might still affect initialization.
• Executor Type: If you’re using something other than a process-based executor, the memory limit setting might lead to unexpected behavior.
• Resource Allocation: The memory monitoring infrastructure could still be active and influencing resource availability.
To help you further, could you please share a bit more info?
• What type of job executor are you using (process or thread)?
• Are there any specific error messages or logs when the hanging happens?
• Does the hanging occur every time or only in certain situations?
• What happens if you try setting job_memory_limit_mb to a positive number instead of 0?
• Are there any other configuration differences between the sample app that works and your app?
• At which exact point does the hanging occur? For example, during worker registration, job acceptance, or room connection?
Once I have these details, I’ll be in a better position to help you identify the root cause and suggest some targeted solutions. I’m here to support you every step of the way!
Sources: livekit-agents/livekit/agents/ipc/job_proc_lazy_main.py