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

camState and micState from useDevices() are set to "granted" before permissions are requested #10

Closed
rileyjshaw opened this issue Jan 5, 2023 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@rileyjshaw
Copy link
Contributor

Expected behavior

useDevices().camState and useDevices().micState should be set to "pending" or "unknown" until device access is requested and granted.

Describe the bug (unexpected behavior)

When a call is created with startAudioOff and startVideoOff set to true, then joined, useDevices().camState and useDevices().micState return "granted" even before device access is requested with callObject.updateParticipant('local', { setVideo: true, setAudio: true }).

Steps to reproduce

Initialize the call with startAudioOff and startVideoOff set to true:

const callObject = DailyIframe.createCallObject({
	startAudioOff: true,
	startVideoOff: true,
	// ...
});

Join the call:

await callObject.join({ url: dailyRoomUrl, token: dailyMeetingToken, userName: name });

Later (but before calling callObject.updateParticipant), run the following:

const { camState, micState } = useDevices();
console.log(camState, micState); // > granted granted

System information

  • Device: Macbook Pro M1 Max, 2021
  • OS, version: MacOS Ventura 13.1
  • Browser, version: 109.0b2 (64-bit)

Additional context

I’m currently using the following as a workaround:

const { cameras, microphones } = useDevices();
const isMediaAccessGranted =
	cameras.some(c => c.selected && c.state === 'granted') &&
	microphones.some(m => m.selected && m.state === 'granted');
@rileyjshaw rileyjshaw added the bug Something isn't working label Jan 5, 2023
@Regaddi Regaddi self-assigned this Jan 6, 2023
@Regaddi
Copy link
Contributor

Regaddi commented Jan 6, 2023

Thanks @rileyjshaw for the bug report!

I'll investigate the issue today and will let you know about any updates.

@Regaddi
Copy link
Contributor

Regaddi commented Jan 6, 2023

Update

I have opened a PR which introduces a new device state "idle", which becomes the new default state.
For rooms configured with cam and mic off, the state will remain in "idle" until the first call to getUserMedia, which switches the state to "pending" and eventually to "granted", "blocked" or any of the other possible error states.

With that "pending" gets a clearer meaning as it maps to a pending getUserMedia call.

I decided to not use "unknown" for the described case, as the state is generally known and "unknown" is already defined as a state to represent an "unknown error".

The plan is to push out a release today or Monday, which will include this and some other fixes and improvements (e.g. #6 and #9).

@rileyjshaw
Copy link
Contributor Author

Fantastic!! I love the idea of introducing an "idle" state, that makes a lot of sense. Thanks for all the work, and for being so quick to respond here 😊

@Regaddi Regaddi closed this as completed Jan 10, 2023
@Regaddi
Copy link
Contributor

Regaddi commented Jan 10, 2023

This change has shipped with daily-react 0.7.0 today!

@rileyjshaw
Copy link
Contributor Author

rileyjshaw commented Jan 10, 2023 via email

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

No branches or pull requests

2 participants