question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

useDevicePermissionStatus initial value

See original GitHub issue

What happened and what did you expect to happen?

useDevicePermissionStatus hook does not reflect initial value correctly. It always sets the initial value to DevicePermissionStatus.UNSET and value is updated only when observers detect change in device permissions.

This means that if my let’s say Chrome browser remembers my permissions and does not ask me again, useDevicePermissionStatus is going to return DevicePermissionStatus.UNSET instead of DevicePermissionStatus.GRANTED until I change permissions manually again. I cannot even force users to confirm manually each time because meetingManager.invokeDeviceProvider(DeviceLabels.AudioAndVideo) does nothing when called on Chrome with permissions already granted.

Can the hook be changed to return initial values depending on the outcomes of navigator.mediaDevices.getUserMedia?

Have you reviewed our existing documentation?

Reproduction steps

  1. Log in to meeting using Chrome
  2. Make sure both audio and video is allowed in the browser
  3. import { useDevicePermissionStatus } from 'amazon-chime-sdk-component-library-react'
  4. const permissionStatus = useDevicePermissionStatus();
  5. permissionStatus will always be DevicePermissionStatus.UNSET until you change the permissions in the browser

Amazon Chime SDK React Components Library version

2.14.0

What browsers are you seeing the problem on?

Chrome

Browser version

97.0.4692.71

Device Information

macOS Big Sur 11.6.2

Meeting and Attendee ID Information.

No response

Browser console logs

chime-permission-status.log

Add any other context about the problem here.

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ltrungcommented, Feb 8, 2022

So this is not convenience but you can follow our logic and call await navigator.mediaDevices.enumerateDevices(); and check whether the device has label. If they don’t then it means there is no permission given yet.

0reactions
xuesichaocommented, Jul 25, 2022

We have renamed the following interfaces in the V3 version to avoid confusion:

Before in 2.x After in 3.x
DevicePermissionStatus DeviceLabelTriggerStatus
DevicePermissionStatus.UNSET DevicePermissionStatus.UNTRIGGERED
useDevicePermissionStatus useDeviceLabelTriggerStatus
MeetingManager.devicePermissionStatus MeetingManager.deviceLabelTriggerStatus
MeetingManager.devicePermissionsObserver MeetingManager.deviceLabelTriggerStatusObservers
MeetingManager.subscribeToDevicePermissionStatus() MeetingManager.subscribeToDeviceLabelTriggerStatus()
MeetingManager.unsubscribeFromDevicePermissionStatus() MeetingManager.unsubscribeFromDeviceLabelTriggerStatus()
MeetingManager.deviceLabelTriggerChangeObservers MeetingManager.deviceLabelTriggerObservers
MeetingManager.subscribeToDeviceLabelTriggerChange() MeetingManager.subscribeToDeviceLabelTrigger()
MeetingManager.unsubscribeFromDeviceLabelTriggerChange() MeetingManager.unsubscribeFromDeviceLabelTrigger()

And we have documented the limitation of this hook in the storybook: https://aws.github.io/amazon-chime-sdk-component-library-react/?path=/story/sdk-hooks-usedevicelabeltriggerstatus--page

We are waiting navigator.permissions.query() API to be supported by browsers, so we can update this hook. Currently only Chrome and Edge support the query to ‘camera’. https://developer.mozilla.org/en-US/docs/Web/API/Permissions

Once the above API is well supported by major browsers, we can update this hook.

Close the issue for now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

amazon-chime-sdk-component-library-react
Fetch the meeting and attendee data from Chime. Initialize MeetingSessionConfiguration. Create and join the meeting. First, you need to fetch the meeting and ......
Read more >
useDevicePermissionStatus initial value - Aws/Amazon ...
useDevicePermissionStatus hook does not reflect initial value correctly. It always sets the initial value to DevicePermissionStatus.
Read more >
React useState setting initial value has no effect - Stack Overflow
First time the filter is an empty array, then props change, filter now returns values. initialState will be set only once. Put setStatusValue...
Read more >
aws/amazon-chime-sdk-component-library - changelogs.md
Move the definition of default theme from its implementation to its d.ts file under . ... Rename useDevicePermissionStatus to useDeviceLabelTriggerStatus .
Read more >
amazon-chime-sdk-component-library-react - bytemeta
... seen intermittently) when 2nd attendee join video call , and start sharing his video attendee video blinking ... useDevicePermissionStatus initial value.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found