xamarin / Essentials

Xamarin.Essentials is no longer supported. Migrate your apps to .NET MAUI, which includes Maui.Essentials.
https://aka.ms/xamarin-upgrade
Other
1.53k stars 505 forks source link

[Bug] MediaPicker.TakePhotoAsync() throwing SIGABRT exception #1915

Open brytonhuggins opened 2 years ago

brytonhuggins commented 2 years ago

Description

While taking photos on our IOS Device (iPad Air 4th Gen - iOS 14.7.1) when pressing the white capture button the application will crash and the following will be logged in appcenter "exceptionPreprocess SIGABRT: *** Collection <NSArrayM: 0x283cb19b0> was mutated while being enumerated."

The issue occurs very infrequently which has caused issues when trying to reproduce the error. It occurs inside MediaPicker.TakePhotoAsync() and we are unable to catch the exception in our common project.

Full Trace: CoreFoundation exceptionPreprocess libobjc.A.dylib objc_exception_throw CoreFoundation NSFastEnumerationMutationHandler CameraUI -[CAMPriorityNotificationCenter _removeObserver:fromObserversByName:] CameraUI -[CAMPriorityNotificationCenter removeObserver:] CameraUI -[CAMCaptureEngine dealloc] libsystem_blocks.dylib _Block_release libdispatch.dylib _dispatch_source_handler_dispose libdispatch.dylib _dispatch_source_invoke libdispatch.dylib _dispatch_lane_serial_drain libdispatch.dylib _dispatch_lane_invoke libdispatch.dylib _dispatch_workloop_worker_thread libsystem_pthread.dylib _pthread_wqthread libsystem_pthread.dylib start_wqthread

Basic Information

jfversluis commented 2 years ago

Hey there! Thanks for the report. It would help if you have a reproduction sample that shows this behavior. Thanks :)

IzelLight commented 2 years ago

Hi!! I don't know if it's related to that bug but i recently faced a problem with MediaPicker which i'll describe next.

Basic Information Platform Target Frameworks: iOS: 15.1

Nuget Packages: Prism.Forms 8.1.7 Xamarin.Essentials 1.7.0 Xamarin.Forms 5.0.0.2125

Affected Devices: iPhone X

Bug description: I have a view which call a dialog to choose between camera to take a photo or gallery to select one. I'm using prism navigation to show the dialog and return a response from it. When dialog closes with selected option and return to the view viewmodel the method registered to process dialog result it's called automatically . Then this method call MediaPicker.TakePhotoAsync() and silently fail (didn't show camera to take photo) but program execution continues without showing an error. Perhaps the reason it's that is executing out of ui mainthread, i don't know.

If i call MediaPicker.TakePhotoAsync() from viewmodel without calling the dialog it works fine. Hope this help