Skip to content

Windows: Camera selection may pick Windows Hello IR/Infrared camera (wrong default camera) #200

Description

@Tazz85

Describe the bug

On Windows (WinUI), CameraView sometimes automatically initializes the Windows Hello infrared (IR) camera instead of the regular color webcam. This results in an unusable preview / scanning experience (IR camera feed / wrong camera).

I noticed this primarily on HP devices, on both Windows 10 and Windows 11.

Expected behavior

The library should prefer a normal color camera for barcode scanning and avoid selecting Windows Hello IR / Depth / Sensor cameras by default (or at least fall back to a color camera when one is available).

Actual behavior

The library sometimes selects the Windows Hello IR camera automatically.

Reproduction steps

  1. Run the sample app (or an app using BarcodeScanning.Native.Maui) on a Windows 10/11 machine that has Windows Hello IR hardware (e.g. HP laptop).
  2. Navigate to the page containing CameraView.
  3. Camera starts automatically and selects the wrong camera (Windows Hello IR) instead of the standard webcam.

Environment

  • OS: Windows 10 + Windows 11
  • Hardware: HP devices with Windows Hello IR camera
  • Package: BarcodeScanning.Native.Maui (NuGet version: 3.0.3)
  • App type: .NET MAUI WinUI

Possible cause

In BarcodeScanning.Native.Maui/Platform/Windows/CameraManager.cs, GetCameraAsync() selects the first source that matches MediaStreamType.VideoRecord, only preferring front/back by panel, but it does not filter out IR / depth / sensor cameras:

private async Task<MediaFrameSourceInfo?> GetCameraAsync()
{
var mediaFrameSourceGroups = await MediaFrameSourceGroup.FindAllAsync();
var preferredPanel = _cameraView?.CameraFacing == CameraFacing.Front
? Windows.Devices.Enumeration.Panel.Front
: Windows.Devices.Enumeration.Panel.Back;
return mediaFrameSourceGroups
.SelectMany(g => g.SourceInfos)
.Where(s => s.MediaStreamType == MediaStreamType.VideoRecord)
.OrderByDescending(s => s.DeviceInformation?.EnclosureLocation?.Panel == preferredPanel)
.FirstOrDefault();
}

return mediaFrameSourceGroups
    .SelectMany(g => g.SourceInfos)
    .Where(s => s.MediaStreamType == MediaStreamType.VideoRecord)
    .OrderByDescending(s => s.DeviceInformation?.EnclosureLocation?.Panel == preferredPanel)
    .FirstOrDefault();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions