Skip to content

Allow joining when the camera or microphone is missing - #222

Open
RaphaelFakhri wants to merge 1 commit into
cloudflare:mainfrom
RaphaelFakhri:fix/permissions-missing-device
Open

RaphaelFakhri wants to merge 1 commit into
cloudflare:mainfrom
RaphaelFakhri:fix/permissions-missing-device

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

Title: Allow joining when the camera or microphone is missing

Fixes #165

Problem

The "Allow access" button calls getUserMedia({ audio: true, video: true }) once. When the machine has no camera or no microphone, the browser rejects the call with NotFoundError. The .catch treats every rejection as a refusal, so the page shows "Permission denied" and the user cannot enter the room. A listen-only participant with neither device is blocked the same way.

Fix

Move the request into requestMediaPermissions:

  • Request both devices together first.
  • If that fails with anything other than NotAllowedError or SecurityError, request the microphone and the camera separately and use whichever succeed, including neither.
  • Reject only when the user or the browser refuses permission. Streams from the fallback requests are stopped after their device ids are read.

EnsurePermissions calls the helper and no longer indexes getAudioTracks()[0] or getVideoTracks()[0], which throw when a device is missing.

Tests

app/utils/requestMediaPermissions.test.ts covers both devices present, microphone only, camera only, neither device, and a refusal.

npx vitest --watch false app/utils/requestMediaPermissions.test.ts

With the previous single-call behavior in the helper, three tests fail (microphone only, camera only, neither). With the fix, all five pass. tsc, eslint and prettier --check are clean for the changed files.

The permission prompt asked for camera and microphone in one
getUserMedia call. When either device is missing the call rejects with
NotFoundError, and the page treated that as a refusal and showed
'Permission denied'. Fall back to each device on its own and only show
the denied page when the user refuses.
@nils-ohlmeier

Copy link
Copy Markdown
Collaborator

Sorry for my pretty basic question, but why would anyone without a camera and microphone be interested in joining a video meeting?

This meeting tool doesn't even a chat feature yet, so the participant would have no way to communicate with the meeting participants at all.

@RaphaelFakhri

Copy link
Copy Markdown
Author

Hey, transparency upfront this PR was part of a barrage that claude did without consulting me. I did not intend to have claude push 350 ish PRs in one day without my review.

Now regarding why someone would join a meeting without either, maybe they're in a hurry and will plug their earpods a few seconds in but want to show up on time 😅

Can't say I wouldn't relate

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.

Bug report: cannot grant permission when device is missing

2 participants