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

Cannot play sound effects while connecting or disconnecting a call #439

Open
dfed opened this issue Jul 19, 2024 · 3 comments
Open

Cannot play sound effects while connecting or disconnecting a call #439

dfed opened this issue Jul 19, 2024 · 3 comments
Assignees
Labels
bug Something isn't working Swift

Comments

@dfed
Copy link

dfed commented Jul 19, 2024

Describe the bug
Enabling or disabling the microphone on a LiveKit room affects the audio stack such that playing sound effects or background noise across these events is user-visibly broken.

SDK Version
2.0.12

iOS/macOS Version
Tried on multiple iOS 17 versions, including most recent at time of writing: 17.5.1.

Xcode Version
15.4.0

Steps to Reproduce

  1. Download + open sample project
  2. Set a valid room and token under the // Set your token here comment
  3. Run app (device or simulator – both repro)
  4. Tap "Play audio"
  5. Tap "Connect" Result: audio audibly glitches when the microphone connects
  6. Tap "Disconnect" Result: audio stops playing entirely
  7. Tap "Stop audio"
  8. Tap "Play audio" again Result: app crashes because the player has not seen an I/O cycle. This is because disconnecting has effectively stopped all audio – calling pause() and then play() on the audio engine after disconnecting fixes this crash.

Expected behavior
Background audio can play without distortion or stopping across enabling/disabling the microphone.

Though I'll take a workaround to at a minimum let me play sound effects without distortion.

Screenshots
N/A. Sample project attached

Logs
N/A. Sample project attached

livekit-swift-example-collection-audio.zip

@dfed dfed added the bug Something isn't working label Jul 19, 2024
@dfed
Copy link
Author

dfed commented Jul 23, 2024

Upon further testing the audio issues above occur when calling room.connect(...) and room.disconnect(), regardless of whether room.localParticipant.setMicrophone(enabled: true/false) is called, even when AudioManager.shared.customConfigureAudioSessionFunc is set to no-op.

@dfed dfed changed the title Cannot play sound effects while enabling or disabling the microphone Cannot play sound effects while connecting or disconnecting a call Jul 24, 2024
@bcherry bcherry added the Swift label Aug 30, 2024 — with Linear
@bcherry
Copy link
Contributor

bcherry commented Oct 16, 2024

@dfed we made some changes and improvements to this behavior in recent versions of the Swift SDK. Can you let me know if you still experience this problem?

@dfed
Copy link
Author

dfed commented Oct 16, 2024

@bcherry glad you're investing here! I tried pointing the sample project attached to the OP to both latest main (4a74cf4) and the latest release 2.0.16: the project is still exhibiting the same behavior described in the OP – the form of the distortion may have changed the playback is still quite distorted.

Let me know if you have issues running the sample project – it clearly reproduces the issue when running on an iOS device. The distortion is relatively minor on simulator when I tested tonight, so maybe there were improvements within the simulator environment?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Swift
Projects
None yet
Development

No branches or pull requests

3 participants