Request microphone permission in foreground before enabling recording.#1047
Open
silviudeac wants to merge 1 commit into
Open
Request microphone permission in foreground before enabling recording.#1047silviudeac wants to merge 1 commit into
silviudeac wants to merge 1 commit into
Conversation
When mic permission is `.notDetermined`, request access at the async mic-enable path (`LocalParticipant.set(source:enabled:)`), but only while the app is foregrounded so the system dialog can appear. This restores the prompt the WebRTC ADM no longer performs implicitly, without blocking a worker thread (livekit#815). The foreground gate lives in a reusable `LiveKitSDK.ensureDeviceAccessIfForegrounded(for:)` helper alongside `ensureDeviceAccess`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the SDK-side follow-up to webrtc-sdk/webrtc#204. That change makes the WebRTC Audio Device Module (ADM) stop implicitly requesting microphone permission — the blocking request that hangs a worker thread when the app is woken in the background (#815) — and replaces it with a passive authorized-check. With the ADM no longer prompting, the SDK now does it:
LocalParticipantproactively requests access at its async mic-enable path, but only while the app is foregrounded so the system dialog can actually appear.The two are meant to land together — #204 removes the hang, this PR restores the prompt.
What changed
LiveKit+DeviceHelpers.swift— newLiveKitSDK.ensureDeviceAccessIfForegrounded(for:): requests access only when the app is.active, reusing the existing non-blockingensureDeviceAccess(for:). A no-op on non-active / non-UIKit contexts.LocalParticipant.set(source:enabled:)— in the.microphonecreate branch, beforeLocalAudioTrack.createTrack(...):Only .notDetermined triggers a request; backgrounded/extension contexts never prompt; muting/unmuting an existing track is untouched. No change to existing API signatures.
Refs #815 (full fix together with webrtc-sdk/webrtc#204).