Maui icon indicating copy to clipboard operation
Maui copied to clipboard

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

Open datoml opened this issue 3 months ago • 2 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

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

  • [x] I have read the "Reporting a bug" section on Contributing file: https://github.com/CommunityToolkit/Maui/blob/main/CONTRIBUTING.md#reporting-a-bug

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

datoml avatar Oct 06 '25 06:10 datoml

A possible workaround would be to prevent the back navigation while an image is being captured

bijington avatar Oct 06 '25 07:10 bijington

A possible workaround would be to prevent the back navigation while an image is being captured

This is my current workaround for that :)

datoml avatar Oct 06 '25 07:10 datoml