Skip to content

[BUG] CameraView crashes Android application when going Back too soon #2900

@datoml

Description

@datoml

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

Hello,
I am facing an issue with the CameraView when capturing an image and the user hits the Back button before the callback was handled.
This results in the following exception.

**System.NotSupportedException:** 'Unable to activate instance of type CommunityToolkit.Maui.Core.CameraManager+ImageCallBack from native handle 0x79636e2bf8 (key_handle 0x2b0bc91).'

If the capture event was handled the Back button will not crash the application.

Expected Behavior

The application should not crash when the exception is thrown.

Steps To Reproduce

  1. Open the CommunityToolkit.Maui.Sample.sln solution
  2. Start the CommunityToolkit.Maui.Sample application on an Android phone.
  3. Navigate to Views
  4. Select the CameraView Page
  5. Hit the Capture Image button and immediately hit the Back button in the toolbar.

Link to public reproduction project repository

https://github.com/CommunityToolkit/Maui/tree/49a124115c6bc09d9ca1ddcdbcc8b425c8ff7479/samples

Environment

- .NET MAUI CommunityToolkit:12.2.0
- OS: Android
- .NET MAUI: 9.x

Anything else?

No response

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