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
- 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).
- Navigate to the page containing
CameraView.
- 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();
Describe the bug
On Windows (WinUI),
CameraViewsometimes 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
BarcodeScanning.Native.Maui) on a Windows 10/11 machine that has Windows Hello IR hardware (e.g. HP laptop).CameraView.Environment
Possible cause
In
BarcodeScanning.Native.Maui/Platform/Windows/CameraManager.cs,GetCameraAsync()selects the first source that matchesMediaStreamType.VideoRecord, only preferring front/back by panel, but it does not filter out IR / depth / sensor cameras:BarcodeScanning.Native.Maui/BarcodeScanning.Native.Maui/Platform/Windows/CameraManager.cs
Lines 368 to 380 in d7582bd