Skip to content

fix: allow camera usage when microphone permission is denied on Windows#3140

Open
AopBK wants to merge 9 commits into
CommunityToolkit:mainfrom
AopBK:fix/windows-camera-without-mic-permission
Open

fix: allow camera usage when microphone permission is denied on Windows#3140
AopBK wants to merge 9 commits into
CommunityToolkit:mainfrom
AopBK:fix/windows-camera-without-mic-permission

Conversation

@AopBK
Copy link
Copy Markdown

@AopBK AopBK commented Mar 10, 2026

Description of Change

The settings for initialising MediaCapture now differ depending on whether microphone permissions have been granted. This prevents the app from crashing due to an UnauthorizedAccessException.

Linked Issues

PR Checklist

  • Has a linked Issue, and the Issue has been approved(bug) or Championed (feature/proposal)
  • Has tests (if omitted, state reason in description)
  • Has samples (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Changes adhere to coding standard
  • Documentation created or updated: https://github.com/MicrosoftDocs/CommunityToolkit/pulls

Additional information

}

var cameraPermissionStatus = await Permissions.CheckStatusAsync<Permissions.Camera>();
if (cameraPermissionStatus == PermissionStatus.Granted)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We removed all permission checks from the library. It is now up to developers to request permission they need and when they need, with the way to use their own UI for user permissions.

Copy link
Copy Markdown
Author

@AopBK AopBK Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the clarification.
In my PR, the CameraViewExtensions.Windows.cs only checks the permission status, but does not request or manage permissions. The actual permission requests are handled in the CameraViewPage, as expected.
@VladislavAntonyuk ,could you please advise on how to best implement this in line with the library’s current design?
For example, should I pass a parameter from the manager, or is there another approach you recommend?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VladislavAntonyuk How can we proceed? Can you check my comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @VladislavAntonyuk Is there still no suggestion? We have to move forward with this topic

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to check for camera permission at all. For microphone permission as it is required for settings we can keep it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @VladislavAntonyuk . I did a second commit with you suggestion. Looking forward to your comment.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@VladislavAntonyuk Could you please take a look and let me know what you think?

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts Windows MediaCapture initialization for CameraView so camera usage can continue when microphone permission is denied, preventing UnauthorizedAccessException crashes (Issue #3139).

Changes:

  • Build MediaCaptureInitializationSettings dynamically based on microphone permission/capability state.
  • Add a camera permission status check and throw a CameraException when not granted.

Comment thread src/CommunityToolkit.Maui.Camera/Extensions/CameraViewExtensions.windows.cs Outdated
Copy link
Copy Markdown
Collaborator

@TheCodeTraveler TheCodeTraveler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a better way to fix the linked issue without using Permissions.CheckStatusAsync?

CommunityToolkit.Maui.Camera (and all MAUI Toolkit libraries) now defers all permissions requests to the developers consuming our library:

https://github.com/CommunityToolkit/Maui/releases/tag/6.0.0-camera

@dotnet-policy-service dotnet-policy-service Bot added stale The author has not responded in over 30 days help wanted This proposal has been approved and is ready to be implemented labels Apr 28, 2026
@AopBK
Copy link
Copy Markdown
Author

AopBK commented Apr 29, 2026 via email

@VladislavAntonyuk VladislavAntonyuk added the needs discussion Discuss it on the next Monthly standup label Apr 30, 2026
@AopBK AopBK force-pushed the fix/windows-camera-without-mic-permission branch from af24cab to 9e7e90e Compare April 30, 2026 11:52
@AopBK AopBK force-pushed the fix/windows-camera-without-mic-permission branch from 9e7e90e to 7ec0b9e Compare April 30, 2026 12:37
@TheCodeTraveler TheCodeTraveler requested a review from Copilot May 7, 2026 18:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@TheCodeTraveler TheCodeTraveler removed help wanted This proposal has been approved and is ready to be implemented stale The author has not responded in over 30 days needs discussion Discuss it on the next Monthly standup labels May 7, 2026
@TheCodeTraveler
Copy link
Copy Markdown
Collaborator

Hey @VladislavAntonyuk! Did you get a chance to test on Windows to verify there's no popup dialog?

@TheCodeTraveler TheCodeTraveler dismissed their stale review May 8, 2026 23:54

Resolved in May 2026 Standup

Copy link
Copy Markdown
Contributor

@VladislavAntonyuk VladislavAntonyuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AopBK the application crashes if microphone permission is denied. Also the app now requests microphone permission automatically on first open.

Image Image

@AopBK
Copy link
Copy Markdown
Author

AopBK commented May 11, 2026

@AopBK the application crashes if microphone permission is denied. Also the app now requests microphone permission automatically on first open.
Image Image

Hi @VladislavAntonyuk ,
Thank you for taking the time to review the code.
I had the same access-denied problem in my development environment until I changed the WindowsPackageType, as you did in the commit 780acfce

@MFinkBK
Copy link
Copy Markdown
Contributor

MFinkBK commented May 12, 2026

@VladislavAntonyuk asking on behalf of my colleague @AopBK : Is there something we have to do here for this PR, or can it be merged? Along with my other two PRs that you recently merged it would be good if we can have all the bugfixes in one new CommunityToolkit.Maui release :-) Thanks!

@VladislavAntonyuk
Copy link
Copy Markdown
Contributor

@MFinkBK The changes you made are not working. I see the error I shared on screenshot.

@MFinkBK
Copy link
Copy Markdown
Contributor

MFinkBK commented May 12, 2026

@VladislavAntonyuk Ah sorry, we misunderstood your screenshot and your commit after that (switching to MSIX). We will take a look!

@AopBK
Copy link
Copy Markdown
Author

AopBK commented May 12, 2026

Hello @VladislavAntonyuk,
We improved the microphone permissions for unpackaged apps and added the webcam capability.

We also found that the unpackaged app can access the camera only if, in Windows Settings → Privacy & security → Camera, the option "Let desktop apps access your camera" is enabled.

Screenshot 2026-05-12 145331

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] CameraView crashes on Windows if microphone permission is denied

5 participants