jamesmontemagno / MediaPlugin

Take & Pick Photos and Video Plugin for Xamarin and Windows
MIT License
711 stars 360 forks source link

iOS App - Rare occasions it crashes #541

Open silverholm opened 6 years ago

silverholm commented 6 years ago

Being trying to figure this one out, but it is quite difficult to reproduce. After I have been taking pictures (150++ pictures) in our app for a few hours it crashes in some very rare occasions. When this happens it crashes when the camera is being initalized. I have tried to narrow down the issue, and I think it can be related to network / unstable internet connection ( very poor Wifi coverage, no 3G/4G network) as the crash happens when I enter the engine room of a vessel where there is almost no internet.

Any clues on what this can be? We do not use location on our images, so I assume this is disabled by default if not implemented?

Bug Information

IOSurface
IOSurfaceClientGetBaseAddress
AVFoundation
-[AVCapturePhoto fileDataRepresentationWithReplacementMetadata:replacementEmbeddedThumbnailPhotoFormat:replacementEmbeddedThumbnailPixelBuffer:replacementDepthData:]
CameraUI
-[CAMCameraViewController _clientPropertiesForStillImageWithURL:captureOrientation:previewSurface:previewOrientation:uniqueIdentifier:savedToPhotoLibrary:captureResult:]
CameraUI
-[CAMCameraViewController captureController:didGenerateStillImageCaptureResult:fromRequest:]
libdispatch.dylib
_dispatch_call_block_and_release
libdispatch.dylib
_dispatch_client_callout
libdispatch.dylib
_dispatch_queue_serial_drain$VARIANT$mp
libdispatch.dylib
_dispatch_queue_invoke$VARIANT$mp
libdispatch.dylib
_dispatch_root_queue_drain_deferred_wlh$VARIANT$mp
libdispatch.dylib
_dispatch_workloop_worker_thread$VARIANT$mp
libsystem_pthread.dylib
_pthread_wqthread
libsystem_pthread.dylib
start_wqthread

Version Number of Plugin: 3.1.3 Device Tested On: iPad Air 2 Simulator Tested On: N/A Version of VS: Visual Studio for Mac 7.5 (Build 1254) Version of Xamarin: Latest stable as of 2018-05-11 Versions of other things you are using:

### Steps to reproduce the Behavior N/A ### Expected Behavior Take picture and preview it. ### Actual Behavior Crash ### Code snippet

var fileName = Guid.NewGuid().ToString() + ".jpg"; var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions { Directory = GlobalConstants.ImageDir, Name = fileName, CompressionQuality = 70, MaxWidthHeight = 1200, PhotoSize = Plugin.Media.Abstractions.PhotoSize.MaxWidthHeight, DefaultCamera = Plugin.Media.Abstractions.CameraDevice.Rear, SaveMetaData = false });

No stack trace, only crash report from App Center as shown above. ### Screenshots N/A

seanyda commented 6 years ago

I also have the same issue, here is stack trace.

Foundation.MonoTouchException: Objective-C exception thrown. Name: NSGenericException Reason: *** Collection <__NSArrayM: 0x1c0444230> was mutated while being enumerated. Native stack trace: 0 CoreFoundation 0x0000000183912da4 <redacted> + 252 1 libobjc.A.dylib 0x0000000182acc5ec objc_exception_throw + 56 2 CoreFoundation 0x00000001839123c0 <redacted> + 0 3 CameraUI 0x00000001a072e8f4 <redacted> + 480 4 CameraUI 0x00000001a072f394 <redacted> + 716 5 CoreFoundation 0x00000001838a4c3c <redacted> + 20 6 CoreFoundation 0x00000001838a41b8 <redacted> + 428 7 CoreFoundation 0x00000001838a3f14 <redacted> + 216 8 CoreFoundation 0x000000018392184c <redacted> + 1408 9 CoreFoundation 0x00000001837daf38 _CFXNotificationPost + 384 10 Foundation 0x000000018424bbbc <redacted> + 68 11 CameraUI 0x00000001a06e7220 <redacted> + 352 12 CameraUI 0x00000001a06e74c0 <redacted> + 412 13 Foundation 0x000000018435e0ec <redacted> + 340 14 CoreFoundation 0x00000001838bb404 <redacted> + 24 15 CoreFoundation 0x00000001838bac2c <redacted> + 276 16 CoreFoundation 0x00000001838b879c <redacted> + 1204 17 CoreFoundation 0x00000001837d8da8 CFRunLoopRunSpecific + 552 18 GraphicsServices 0x00000001857be020 GSEventRunModal + 100 19 UIKit 0x000000018d7f8758 UIApplicationMain + 236 20 Dispatch.iOS 0x0000000101bfd020 _ZN7plcrash2MS5async24dwarf_cfa_state_iteratorIyxE4nextEPjPNS1_28plcrash_dwarf_cfa_reg_rule_tEPy + 14730384 21 Dispatch.iOS 0x0000000101b7999c _ZN7plcrash2MS5async24dwarf_cfa_state_iteratorIyxE4nextEPjPNS1_28plcrash_dwarf_cfa_reg_rule_tEPy + 14192140 22 Dispatch.iOS 0x0000000101b7995c _ZN7plcrash2MS5async24dwarf_cfa_state_iteratorIyxE4nextEPjPNS1_28plcrash_dwarf_cfa_reg_rule_tEPy + 14192076 23 Dispatch.iOS 0x0000000100e1ebc0 _ZN7plcrash2MS5async24dwarf_cfa_state_iteratorIyxE4nextEPjPNS1_28plcrash_dwarf_cfa_reg_rule_tEPy + 188464 24 Dispatch.iOS 0x00000001010f4158 _ZN7plcrash2MS5async24dwarf_cfa_state_iteratorIyxE4nextEPjPNS1_28plcrash_dwarf_cfa_reg_rule_tEPy + 3159496 25 Dispatch.iOS 0x0000000102808e30 mono_pmip 
Finneyv commented 6 years ago

I've also been running into this issue while running the 3.0.6 version of the Media plugin. I'm curious if this issue is still present on later versions. @seanyda What version of the plugin are you running?

pcampbell83 commented 4 years ago

This is something we struggle with as well. Something we have discovered when digging into the plugin code; if you set the UIImagePickerController property ShowCameraControls to false, we appear to not get any crashes at all.

This worked fine so long as you didn't want/need to show image previews, as some of our users requested. We then decided to allow users to pick between these modes, and as soon as we added the ability to set ShowCameraControls back to true (ie: show previews), the crashes started rolling in again.

This makes me think it may in fact be a Xamarin iOS issue since we're no longer using the plugin but instead rolled our own code - and we still get these same crashes, but only if we set ShowCameraControls to true.

yalamandarao commented 4 years ago

@pcampbell83 Where to set the ShowCameraControls to false in the code. I'm using MediaPlugin plugin