Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App crashing randomly while taking images by camera in iOS14 #678

Closed
manindra86 opened this issue Oct 15, 2020 · 12 comments
Closed

App crashing randomly while taking images by camera in iOS14 #678

manindra86 opened this issue Oct 15, 2020 · 12 comments

Comments

@manindra86
Copy link

Bug Report

Problem

After taking the picture app crashing randomly in iOS 14. Sometimes it allows to take picture more than 40-50 but sometimes it get crash after taking 4-5 images.

What is expected to happen?

Crash should not happen.

What does actually happen?

While taking picture app is crashing randomly.
Log:

2020-10-15 16:58:38.407845+0530 MyApp[1853:107942] [Camera] Failed to read exposureBiasesByMode dictionary: Error Domain=NSCocoaErrorDomain Code=4864 "*** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: data is NULL" UserInfo={NSDebugDescription=*** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: data is NULL}
2020-10-15 16:58:41.897670+0530 MyApp[1853:107942] [Camera] Failed to read exposureBiasesByMode dictionary: Error Domain=NSCocoaErrorDomain Code=4864 "*** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: data is NULL" UserInfo={NSDebugDescription=*** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: data is NULL}
2020-10-15 16:58:44.499771+0530 MyApp[1853:107942] [Camera] Failed to read exposureBiasesByMode dictionary: Error Domain=NSCocoaErrorDomain Code=4864 "*** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: data is NULL" UserInfo={NSDebugDescription=*** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: data is NULL}
2020-10-15 16:58:48.525883+0530 MyApp[1853:107942] [Camera] Failed to read exposureBiasesByMode dictionary: Error Domain=NSCocoaErrorDomain Code=4864 "*** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: data is NULL" UserInfo={NSDebugDescription=*** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: data is NULL}
2020-10-15 16:58:50.795885+0530 MyApp[1853:111849] *** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSArrayM: 0x281798900> was mutated while being enumerated.'
*** First throw call stack:
(0x1860a25ac 0x19a11c42c 0x1860a1f04 0x1ae8faa28 0x1ae8fad60 0x1ae9adae4 0x1cd588794 0x102ca20f8 0x102ca0f50 0x102c90dd4 0x102c91cb4 0x102c9de38 0x1cd5f4908 0x1cd5fb77c)
libc++abi.dylib: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSArrayM: 0x281798900> was mutated while being enumerated.'
terminating with uncaught exception of type NSException
2020-10-15 17:06:47.634387+0530 MyApp[1853:109314] [Camera] [CAMCaptureEngine] Received a session runtime error notification : Error Domain=AVFoundationErrorDomain Code=-11819 "Cannot Complete Action" UserInfo={NSLocalizedDescription=Cannot Complete Action, NSLocalizedRecoverySuggestion=Try again later.}
2020-10-15 17:06:47.634549+0530 MyApp[1853:109314] [Camera] [CAMCaptureEngine] Performing recovery from error: Error Domain=AVFoundationErrorDomain Code=-11819 "Cannot Complete Action" UserInfo={NSLocalizedDescription=Cannot Complete Action, NSLocalizedRecoverySuggestion=Try again later.}
2020-10-15 17:06:47.634730+0530 MyApp[1853:109314] [Camera] [CAMCaptureEngine] Attempting to recover from a session runtime error by restarting the AVCaptureSession...
*** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSArrayM: 0x281798900> was mutated while being enumerated.'
terminating with uncaught exception of type NSException

Information

Since this issue is random , So try taking lot of images continuously approx 50 to 60. Sometimes app crash only with 4-5 images. This issue I am facing only with iOS 14 or iOS14.0.1.

Environment, Platform, Device

iPhone XR
iOS. 14.0
Xcode 12.0
Camera plugin 5.0.0
Cordova iOS 5.1.1

I have added sample app and crash log.
Camera-Plugin-Demo.zip

@mhornung85
Copy link

hey at all - any news/workarounds for that?

@timbru31
Copy link
Member

Can you please re-test v5.0.1?

@ita33
Copy link

ita33 commented Nov 17, 2020

We are having the same app crashing issue on the 40th - 50th photo with the below environment and have the same crash issue whether on both Camera plugin 4.1.0 and 5.0.1. The app has always crashed on about the 250th - 350th photo on older iOS versions, but crashing on 40th - 50th photo makes it difficult for a user. Has there possibly been any progress here?

Camera plugin 4.1.0 and 5.0.1
iPhone X
iOS 14.1
Cordova iOS 5.1.1

@ryandsjoquist
Copy link

ryandsjoquist commented Dec 2, 2020

So far from what I can dig up, Is that it might be related to an older bug with Capacitor regarding removing event listeners while events are still being triggered. ionic-team/capacitor#1943
Still digging into stack traces on this, but that's seeming to be in the general direction I'm headed due to the exact same error.
*** Collection <__NSArrayM: 0x283ccadf0> was mutated while being enumerated.
(
0 CoreFoundation 0x00000001966b088c AF3F8E01-C130-3464-AD40-C5532D273483 + 1202316
1 libobjc.A.dylib 0x00000001aac06c50 objc_exception_throw + 60
2 CoreFoundation 0x00000001966b017c AF3F8E01-C130-3464-AD40-C5532D273483 + 1200508
3 CameraUI 0x00000001bfe0c764 33C8166A-6796-36EE-B25A-0A82725559D6 + 976740
4 CameraUI 0x00000001bfe0caa8 33C8166A-6796-36EE-B25A-0A82725559D6 + 977576
5 CameraUI 0x00000001bfdce6f0 33C8166A-6796-36EE-B25A-0A82725559D6 + 722672
6 CameraUI 0x00000001bff1b6e4 33C8166A-6796-36EE-B25A-0A82725559D6 + 2086628
7 libobjc.A.dylib 0x00000001aac05b10 282FD01C-1437-349B-AE1A-2EFF32859670 + 23312
8 libobjc.A.dylib 0x00000001aac1c840 objc_destructInstance + 80
9 libobjc.A.dylib 0x00000001aac2380c _objc_rootDealloc + 80
10 UIKitCore 0x0000000199094928 05147936-B875-3EF3-94DB-9C8869BB0E34 + 12572968
11 UIKitCore 0x0000000198936894 05147936-B875-3EF3-94DB-9C8869BB0E34 + 4847764
12 CameraUI 0x00000001bff128d0 33C8166A-6796-36EE-B25A-0A82725559D6 + 2050256
13 UIKitCore 0x00000001988596d0 05147936-B875-3EF3-94DB-9C8869BB0E34 + 3942096
14 UIKitCore 0x000000019893fb28 05147936-B875-3EF3-94DB-9C8869BB0E34 + 4885288
15 UIKitCore 0x0000000198940918 05147936-B875-3EF3-94DB-9C8869BB0E34 + 4888856
16 UIKitCore 0x0000000198940a30 05147936-B875-3EF3-94DB-9C8869BB0E34 + 4889136
17 UIKitCore 0x000000019881becc 05147936-B875-3EF3-94DB-9C8869BB0E34 + 3690188
18 UIKitCore 0x000000019881bc0c 05147936-B875-3EF3-94DB-9C8869BB0E34 + 3689484
19 UIKitCore 0x00000001988263e4 05147936-B875-3EF3-94DB-9C8869BB0E34 + 3732452
20 UIKitCore 0x0000000198820410 05147936-B875-3EF3-94DB-9C8869BB0E34 + 3707920
21 UIKitCore 0x00000001989649cc 05147936-B875-3EF3-94DB-9C8869BB0E34 + 5036492
22 UIKitCore 0x0000000199567c3c 05147936-B875-3EF3-94DB-9C8869BB0E34 + 17632316
23 UIKitCore 0x00000001995678e8 05147936-B875-3EF3-94DB-9C8869BB0E34 + 17631464
24 UIKitCore 0x000000019959f7b8 05147936-B875-3EF3-94DB-9C8869BB0E34 + 17860536
25 UIKitCore 0x0000000199571b1c 05147936-B875-3EF3-94DB-9C8869BB0E34 + 17672988
26 UIKitCore 0x0000000199572084 05147936-B875-3EF3-94DB-9C8869BB0E34 + 17674372
27 UIKitCore 0x00000001995721e8 05147936-B875-3EF3-94DB-9C8869BB0E34 + 17674728
28 QuartzCore 0x0000000199ad7160 DC2644E7-E5E4-3D83-9110-A5AE7E2C8B1F + 1524064
29 libdispatch.dylib 0x0000000105aa56c0 _dispatch_client_callout + 20
30 libdispatch.dylib 0x0000000105ab4f34 _dispatch_main_queue_callback_4CF + 1000
31 CoreFoundation 0x000000019662c11c AF3F8E01-C130-3464-AD40-C5532D273483 + 659740
32 CoreFoundation 0x0000000196626120 AF3F8E01-C130-3464-AD40-C5532D273483 + 635168
33 CoreFoundation 0x000000019662521c CFRunLoopRunSpecific + 600
34 GraphicsServices 0x00000001ad6a4784 GSEventRunModal + 164
35 UIKitCore 0x000000019905e200 05147936-B875-3EF3-94DB-9C8869BB0E34 + 12349952
36 UIKitCore 0x0000000199063a74 UIApplicationMain + 168
37 AppName 0x0000000104f7a194 main + 64
38 libdyld.dylib 0x00000001962e56c0 BA60CB9E-95C5-3646-BEED-D313E15586CF + 5824
)

@Spinnenzunge
Copy link

The same error appears in an Ionic app built with capacitor and an input type=file in the webview when you select the camera option:

2020-12-10 14:44:19.245921+0100 App[1814:167550] [Camera] Failed to read exposureBiasesByMode dictionary: Error Domain=NSCocoaErrorDomain Code=4864 "*** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: data is NULL" UserInfo={NSDebugDescription=*** -[NSKeyedUnarchiver _initForReadingFromData:error:throwLegacyExceptions:]: data is NULL}

This app does not crash tho and I get a File object in the FileList of the html file input element. So this looks more like an iOS bug?

@ita33
Copy link

ita33 commented Dec 28, 2020

I think we may have found a potential fix using a slightly different implementation, however we would need an option added to the plugin to be able to start the camera and leave it started in the background, instead of stopping the camera at the end of each use. We found this potential fix while testing a different camera plugin (cordova-plugin-camera-preview) that has an option to either start and stop the plugin after each use or to start and leave it started in the background. When using this plugin with the start and stop (after each photo capture) option on iOS 14, the app crashes after about 40 photos. When using the option to leave the camera started in the background, we got to 1,000 photos with no crash. We plan to leave the camera plugin open during each photo shoot of a single object, so the user can take their 30 - 50 photos of the object and then close the camera at the end of the shoot. We ran the same test on Android 10 and 11 and believe it may also fix issue #665. Is it possible for cordova-plugin-camera to have a similar option to leave the camera started in the background? Thank you in advance for your consideration.

@ita33
Copy link

ita33 commented Feb 13, 2021

Checking in to see if there is a possibility someone might have time soon to look into this issue. It is reproducible every time on iOS 14.1 - 14.4. App is consistently crashing on the 40th - 50th photo. Thanks for your consideration.

@capc0
Copy link

capc0 commented Apr 14, 2021

@ita33 can you elaborate on your current setup? did you switch to Cordova-plugin-camera-preview?

@fbarbedette
Copy link

Hi, we're facing the same problem. is there a fix we could apply waiting for the real fix from the plugin? Is there at least a way of catching the error so we can show a message to the user?

@backendeveloper
Copy link

Hi, has any changes?

@glister
Copy link

glister commented Sep 21, 2021

@capc0

I took the same approach as @ita33 and it works well, run cordova plugin add cordova-plugin-camera-preview.

Then do something along the lines of the following, where element is the dom element you want to contain the photo preview.

var targetPosition = element.getBoundingClientRect();

CameraPreview.startCamera({
    x: targetPosition.left,
    y: targetPosition.top,
    width: targetPosition.width,
    height: targetPosition.height,
    //...other options
});

Then wire up your buttons to take a photo etc. Also don't forget to listen to orientation change event so your camera repositions with your dom element

window.removeEventListener('orientationchange', repositionCamera);

@breautek
Copy link
Contributor

stale

@breautek breautek closed this as not planned Won't fix, can't repro, duplicate, stale Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests