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

Audio source RtcAudioSource stream does not work on some android devices #77

Open
louismuk opened this issue Dec 27, 2024 · 1 comment

Comments

@louismuk
Copy link

Problem

The app cannot stream audio from the microphone to the LiveKit server on certain Android devices, particularly older devices and some brands. This behavior is not related to microphone hardware, as i tried to set test audio on loop in the AudioSource and it works on most devices but fails on few devices i found listed below.

Affected Devices:
Motorola G20 API 30 (Firebase Test Lab)
moto g API 30 (Firebase Test Lab)
Vivo 1610 API 23 (Firebase Test Lab)
Huawei P20 Pro API 29 (Physical)
Embedded Devices Base Android API 30 (Physical)

This issue does not occur when using the native Android SDK—only with the Unity SDK.

Expected Behavior

Audio should stream properly from the microphone to the LiveKit server across all supported Android devices, regardless of brand or API level.

Actual Behavior

On some devices, audio streaming fails completely despite other devices working fine.

Steps to Reproduce

  1. Clone Unity Example Repository.
  2. Set up room token and LiveKit URL.
  3. Download and install Bluestacks.
  4. Build and Install the app in Bluestacks.
  5. Make a call and open the microphone.
  6. Test microphone functionality.

Findings and Tests Conducted

The issue reproduces on Bluestacks, mimicking behavior on the non working physical devices.
The Android SDK (https://github.com/livekit/client-sdk-android) works on all devices, including Bluestacks.
The Unity Android SDK fails on the affected devices.
Switching to a test audio loop instead of a microphone input does not fix the issue.

@vinnycall
Copy link

The issue you're facing seems to be related to compatibility problems between the Unity SDK for LiveKit and certain Android devices, particularly those running specific API levels or from certain manufacturers. Here are some steps you can take to diagnose and potentially resolve the issue:

Diagnosis and Debugging Steps:
Log Detailed Errors:

Enable verbose logging in the Unity SDK and review logs on the affected devices. This might provide more insight into what is failing during the audio streaming process.
Compare with Native SDK Behavior:

Since the native Android SDK works on all devices, compare the configurations used in the native SDK with the Unity SDK. Look for differences in how the microphone is initialized or how audio data is handled.
Audio Permissions and Settings:

Ensure that all necessary permissions are correctly requested and granted on the affected devices.
Check if there are any device-specific settings or restrictions that could be affecting microphone access or audio streaming.
Audio Configuration Differences:

Review and compare the audio configuration settings (e.g., sample rate, audio format) between the native Android SDK and Unity SDK. Mismatches here could lead to compatibility issues.
Device-Specific Issues:

Look for any known issues or limitations with the affected devices, especially regarding audio handling in Unity.
Some older devices or certain brands may have unique audio hardware or software constraints.
Bluestacks Emulation Issues:

Since Bluestacks is not a physical device, its emulation of audio hardware may differ from real devices. Confirm that the same issue reproduces on the actual affected devices.
Potential Solutions:
Unity Audio Configuration:

Experiment with different audio input settings in Unity (e.g., different sample rates, buffer sizes) to find a configuration that works across all devices.
Custom Audio Processing:

Implement a custom audio processing pipeline within Unity that might bypass potential issues with the built-in Unity audio handling.
SDK Update or Bug Report:

Check if there are updates or patches available for the LiveKit Unity SDK that address this issue.
Report the bug to the LiveKit Unity SDK maintainers, providing detailed logs and device information to help them diagnose and fix the issue.
Fallback Mechanism:

Implement a fallback mechanism in the app to detect problematic devices and switch to an alternative method of audio handling, possibly using the native Android SDK for audio streaming on those devices.
By systematically following these steps, you should be able to narrow down the cause of the issue and either find a workaround or contribute valuable information for a more permanent fix in the SDK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants