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

fix: add pending browser permission state #1718

Merged
merged 3 commits into from
Mar 12, 2025
Merged

Conversation

myandrienko
Copy link
Contributor

@myandrienko myandrienko commented Mar 12, 2025

Overview

Previously there was no way to track if the SDK is currently prompting browser for a device permission. For example:

  1. Call has camera enabled by default. User visits the call page for the first time. Browser permission prompt is displayed, but in the meanwhile camera toggle is showing that camera is enabled (because hasBrowserPermission is true for prompt state, and optimisticStatus is enabled).
  2. Permissions have been reset, and user tries to enable camera. Once again, browser permission prompt is displayed, but in the meanwhile camera toggle is showing that camera is enabled.

We now introduce another permission state apart from prompt, granted and denied: prompting. This state is in effect while browser prompt is visible, i.e. when permission state is prompt and getUserMedia promise is pending.

Implementation notes

New browser permission state prompting is added to BrowserPermission class.

This state is exposed via the isPermissionPending$ observable in input media device manager state.

State hooks for camera and microphone state also return this flag.

Default device toggles support this flag and display the new "?" badge while permission is pending:

Screenshot 2025-03-12 at 13 03 37

Docs are to follow.


There are also two other minor changes in this PR.

The settled() check in concurrency.ts is fixed to prevent possible race conditions. Previously, it was possible to check for settled(), then add more promises to the queue, and settled() will resolve before these newly added promises are resolved.

isTogglePending flag is returned from device-related call state hooks. It can be used to display a loader while camera/microphone are enabled/disabled. It's not used by our default toggle buttons, but it's nice to have.

@myandrienko myandrienko requested a review from oliverlaz March 12, 2025 12:15
@myandrienko myandrienko marked this pull request as ready for review March 12, 2025 12:15
@myandrienko myandrienko merged commit 7f24be6 into main Mar 12, 2025
19 checks passed
@myandrienko myandrienko deleted the pending-permission-state branch March 12, 2025 13:46
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

Successfully merging this pull request may close these issues.

2 participants