Skip to content

[BUG] CameraView App crashes when switching camera on Windows #2559

@ruc12127

Description

@ruc12127

Is there an existing issue for this?

  • I have searched the existing issues

Did you read the "Reporting a bug" section on Contributing file?

Current Behavior

Switching the camera between front and rear causes the app to crash on Windows. Works fine on Android and iOS.

Expected Behavior

Should be able to switch between the available camera on all platforms without any crashes.

Steps To Reproduce

  1. Open and run the solution on Windows.
  2. Click the "Switch Camera" Button
  3. Notice the app crash.

Link to public reproduction project repository

https://github.com/ruc12127/CameraViewWindowsCrash

Environment

- .NET MAUI CommunityToolkit.Maui.Camera: 2.0.2
- OS: Windows 10
- .NET MAUI: 9.0.30

Exception Details

System.Runtime.InteropServices.COMException (0xC00D36B4): The data specified for the media type is invalid, inconsistent, or not supported by this object.
The data specified for the media type is invalid, inconsistent, or not supported by this object.
at CommunityToolkit.Maui.Core.CameraManager.PlatformUpdateResolution(Size resolution, CancellationToken token) in //src/CommunityToolkit.Maui.Camera/CameraManager.windows.cs:line 204
at CommunityToolkit.Maui.Core.CameraManager.d__21.MoveNext() in /
/src/CommunityToolkit.Maui.Camera/CameraManager.windows.cs:line 164
at CommunityToolkit.Maui.Core.CameraManager.UpdateCurrentCamera(CameraInfo cameraInfo, CancellationToken token) in //src/CommunityToolkit.Maui.Camera/CameraManager.shared.cs:line 82
at CommunityToolkit.Maui.Core.Handlers.CameraViewHandler.MapSelectedCamera(CameraViewHandler handler, ICameraView view) in /
/src/CommunityToolkit.Maui.Camera/Handlers/CameraViewHandler.shared.cs:line 158
at System.Threading.Tasks.Task.<>c.b__128_0(Object state)
at Microsoft.UI.Dispatching.DispatcherQueueSynchronizationContext.<>c__DisplayClass2_0.b__0()
--- End of stack trace from previous location ---
at WinRT.ExceptionHelpers.g__Throw|38_0(Int32 hr)
at ABI.Windows.ApplicationModel.Core.IUnhandledErrorMethods.Propagate(IObjectReference _obj)
at Microsoft.AppCenter.Utils.ApplicationLifecycleHelperWinUI.<.ctor>b__0_3(Object sender, UnhandledErrorDetectedEventArgs eventArgs)
--- End of stack trace from previous location ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions