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

Camera plugin crashes Android 9 device #554

Closed
3 of 6 tasks
aximobile opened this issue Jan 28, 2020 · 7 comments · Fixed by #585
Closed
3 of 6 tasks

Camera plugin crashes Android 9 device #554

aximobile opened this issue Jan 28, 2020 · 7 comments · Fixed by #585

Comments

@aximobile
Copy link

aximobile commented Jan 28, 2020

Issue Type

  • Bug Report
  • Feature Request
  • Support Question

Description

The camera plugin randomly crashes my Ionic v1 app when taking a picture with the camera. Sometimes after taking 50 pictures, sometimes after taking 5 pictures.

Information

See next comments for the stacktrace and full logging of the app crash.
Its pretty difficult to provide a reproducable case since the crashes happen randomly.
The best way to reproduce is to simply create an empty Ionic v1 project, add the plugin and start taking pictures on an Android 9 device.

Command or Code

See comments below for logging

Code:
navigator.camera.getPicture(deferred.resolve, function(error) {
$log.error("Unable to obtain picture: ", error);
deferred.reject(error);
}, {
allowEdit: false,
correctOrientation: true,
destinationType: Camera.DestinationType.FILE_URI,
direction: Camera.Direction.BACK,
encodingType: Camera.EncodingType.JPEG,
mediaType: Camera.MediaType.PICTURE,
quality: 100,
sourceType: Camera.PictureSourceType.CAMERA,
targetWidth: 1000,
targetHeight: 625
});

Environment, Platform, Device

  • Environment: Ionic v1
  • Ionic CLI: 2.1.17
  • Cordova CLI: 7.1.0
  • Platform: Android
  • Camera plugin version: 4.1.0
  • Device: Samsung Galaxy tab S5e(Android 9)
  • Cordova-android version: 8.0.0
  • Npm CLI: 5.6.0
  • Node version: 8.11.3

Checklist

  • I searched for already existing GitHub issues about this
  • I updated all Cordova tooling to their most recent version
  • I included all the necessary information above
@aximobile
Copy link
Author

aximobile commented Jan 28, 2020

Stacktrace of error that propably caused the crash:

01-28 11:47:39.946 10440-10467/? E/PdkUtil: Fail to acquire available samsung key list.
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.samsung.android.camera.core2.local.internal.PdkUtil.getAvailableSamsungKeyList(PdkUtil.java:313)
at com.samsung.android.camera.core2.local.vendorkey.SemCameraCharacteristics.getAvailableSessionKeys(SemCameraCharacteristics.java:1004)
at com.samsung.android.camera.core2.CamCapability.getAvailableSamsungSessionKeys(CamCapability.java:528)
at com.samsung.android.camera.core2.CamCapability.getAvailableSamsungSessionKeyNames(CamCapability.java:553)
at com.samsung.android.camera.core2.maker.PhotoMakerBase.connectCamDevice(PhotoMakerBase.java:992)
at com.samsung.android.camera.core2.maker.ProcessingPhotoMakerBase.connectCamDevice(ProcessingPhotoMakerBase.java:66)
at com.sec.android.app.camera.engine.request.ConnectMakerRequest.execute(ConnectMakerRequest.java:102)
at com.sec.android.app.camera.engine.request.Request.run(Request.java:88)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.IllegalArgumentException: Could not find tag for key 'samsung.android.request.availableSessionKeys')
at android.hardware.camera2.impl.CameraMetadataNative.nativeGetTagFromKeyLocal(Native Method)
at android.hardware.camera2.impl.CameraMetadataNative.getBase(CameraMetadataNative.java:514)
at android.hardware.camera2.impl.CameraMetadataNative.get(CameraMetadataNative.java:404)
at android.hardware.camera2.impl.CameraMetadataNative.get(CameraMetadataNative.java:373)
at android.hardware.camera2.CameraCharacteristics.get(CameraCharacteristics.java:223)
at android.hardware.camera2.CameraCharacteristics.getAvailableSamsungKeyList(CameraCharacteristics.java:287)
at com.samsung.android.sdk.camera.impl.internal.CustomInterfaceHelper.getAvailableSamsungKeyList(CustomInterfaceHelper.java:41)
at java.lang.reflect.Method.invoke(Native Method) 
at com.samsung.android.camera.core2.local.internal.PdkUtil.getAvailableSamsungKeyList(PdkUtil.java:313) 
at com.samsung.android.camera.core2.local.vendorkey.SemCameraCharacteristics.getAvailableSessionKeys(SemCameraCharacteristics.java:1004) 
at com.samsung.android.camera.core2.CamCapability.getAvailableSamsungSessionKeys(CamCapability.java:528) 
at com.samsung.android.camera.core2.CamCapability.getAvailableSamsungSessionKeyNames(CamCapability.java:553) 
at com.samsung.android.camera.core2.maker.PhotoMakerBase.connectCamDevice(PhotoMakerBase.java:992) 
at com.samsung.android.camera.core2.maker.ProcessingPhotoMakerBase.connectCamDevice(ProcessingPhotoMakerBase.java:66) 
at com.sec.android.app.camera.engine.request.ConnectMakerRequest.execute(ConnectMakerRequest.java:102) 
at com.sec.android.app.camera.engine.request.Request.run(Request.java:88) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
at java.lang.Thread.run(Thread.java:764) 
01-28 11:47:39.983 681-10479/? E/CHI: [SS_ERR ]: [CHI ]: chxusecaseutils.cpp: Destroy: 1706: ImageBuffer 0xe4287da0 is destroyed with reference count = 1

@shashankdevp
Copy link

Hi, We are also facing the same issue where once the camera is opened within the app and a picture is taken, app crashes. This particular issue is observed in both Android and IOS devices.

This issue is inconsistent and not able to reproduce in multiple devices. For example in one of the phone model OnePlus 6t crashes the app while using native camera within the app and at the same time another device with same model does not crash the app.

@KamranKawish
Copy link

I am facing this problem as well, never had the chance to test it on ios device, but both of my android devices with Android 9 crash when I am done taking picure with the camera

@aximobile
Copy link
Author

aximobile commented Feb 10, 2020

I believe the root cause of the problem is primarily the increasing resolution of photos by newer Android devices in combination with the amount of memory on the device.

I've tested the plugin on two devices:

Device 1: Samsung Galaxy tab S2(2016)

  • Memory: 3GB
  • Android version: 7.0
  • Approx image size: 3264x2448
  • Never crashes

Device 2: Samsung Galaxy tab S5e(2019)

  • Memory: 4GB
  • Android version: 9.0
  • Approx image size: 4128x3096
  • Random crash interval

Other things worth mentioning:

  • The S2 tablet takes pictures MUCH faster then the S5e tablet. When I take a picture on the S5e tablet, it takes some time for the OS to send the image from the native camera to my Ionic app while this process doesn't even take a second on the S2 tablet. Everything feels much smoother on the S2 tablet then on the S5e tablet.

  • The moment I take a picture on the S5e tablet, the camera app 'hangs' for 3 seconds. This is not the case on the S2 tablet.

@shashankdevp
Copy link

Is it something related to cordova-camera plugin version. I have installed the latest version of the plugin. I am facing crash issue once updated to a new camera plugin version. Can anyone comment on this ?

@sirhaplo
Copy link

sirhaplo commented Mar 13, 2020

I see the same problem on our app.
On android 8 i see no problems. On android 9 it crashes randomly.
To reproduce i need to shoot a lot of photos, but i have reports from users that has the problem more often.
The problem is with cordova-camera 4.0.3 and also with 4.1.0. I dint tried lower versions.

In other places i read thet my stacktrace could be about permission on disk, but its seem all good. On normal use i save the images correctly, and some rare times i cant. So the permissions are right.

I have problems with Samsung Galaxy Tab A 2019 ( not with 2016 that have android 8 ) that have Exynos chip and with LG G7 that have Snapdragon.

My code to call the camera :
navigator.camera.getPicture(onSuccess, onFail, { quality: 50, allowEdit: true, destinationType: Camera.DestinationType.FILE_URI, correctOrientation: true });

Here the trace :
03-13 10:45:10.585 16037 16037 D AndroidRuntime: Shutting down VM 03-13 10:45:10.586 16037 16037 E AndroidRuntime: FATAL EXCEPTION: main 03-13 10:45:10.586 16037 16037 E AndroidRuntime: Process: it.tideup.riquesto, PID: 16037 03-13 10:45:10.586 16037 16037 E AndroidRuntime: java.lang.RuntimeException: Unable to resume activity {it.tideup.riquesto/it.tideup.riquesto.MainActivity}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=34, result=-1, data=null} to activity {it.tideup.riquesto/it.tideup.riquesto.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object reference 03-13 10:45:10.586 16037 16037 E AndroidRuntime: at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3830) 03-13 10:45:10.586 16037 16037 E AndroidRuntime: at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3862) 03-13 10:45:10.586 16037 16037 E AndroidRuntime: at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:51) 03-13 10:45:10.586 16037 16037 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145) 03-13 10:45:10.586 16037 16037 E AndroidRuntime: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70) 03-13 10:45:10.586 16037 16037 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1816) 03-13 10:45:10.586 16037 16037 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106) 03-13 10:45:10.586 16037 16037 E AndroidRuntime: at android.os.Looper.loop(Looper.java:193) 03-13 10:45:10.586 16037 16037 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6854) 03-13 10:45:10.586 16037 16037 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 03-13 10:45:10.586 16037 16037 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 03-13 10:45:10.586 16037 16037 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:860) 03-13 10:45:10.586 16037 16037 E AndroidRuntime: Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=34, result=-1, data=null} to activity {it.tideup.riquesto/it.tideup.riquesto.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object reference 03-13 10:45:10.586 16037 16037 E AndroidRuntime: at android.app.ActivityThread.deliverResults(ActivityThread.java:4427) 03-13 10:45:10.586 16037 16037 E AndroidRuntime: at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3819) 03-13 10:45:10.586 16037 16037 E AndroidRuntime: ... 11 more 03-13 10:45:10.586 16037 16037 E AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object reference 03-13 10:45:10.586 16037 16037 E AndroidRuntime: at android.support.v4.content.FileProvider.parsePathStrategy(FileProvider.java:604) 03-13 10:45:10.586 16037 16037 E AndroidRuntime: at android.support.v4.content.FileProvider.getPathStrategy(FileProvider.java:578) 03-13 10:45:10.586 16037 16037 E AndroidRuntime: at android.support.v4.content.FileProvider.getUriForFile(FileProvider.java:416) 03-13 10:45:10.586 16037 16037 E AndroidRuntime: at org.apache.cordova.camera.CameraLauncher.onActivityResult(CameraLauncher.java:803) 03-13 10:45:10.586 16037 16037 E AndroidRuntime: at org.apache.cordova.CordovaInterfaceImpl.onActivityResult(CordovaInterfaceImpl.java:152) 03-13 10:45:10.586 16037 16037 E AndroidRuntime: at org.apache.cordova.CordovaActivity.onActivityResult(CordovaActivity.java:358) 03-13 10:45:10.586 16037 16037 E AndroidRuntime: at android.app.Activity.dispatchActivityResult(Activity.java:7469) 03-13 10:45:10.586 16037 16037 E AndroidRuntime: at android.app.ActivityThread.deliverResults(ActivityThread.java:4420) 03-13 10:45:10.586 16037 16037 E AndroidRuntime: ... 12 more

@mirko77
Copy link

mirko77 commented Mar 17, 2020

See #345

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants