Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 48976

Taking a picture using the ionic-native camera plugin sometime makes the app restart

$
0
0

VERSIONS:
Ionic CLI (ionic -v): 6.12.1
cordova (cordova -v): 9.0.0

@ionic/angular: 5.2.3
@ionic-native/camera: 5.27.0
cordova-android: 8.1.0

Problem
I have an Ionic app which uses the ionic-native camera plugin. 99% of the time I take a picture with that plugin, everything works as intended and I get an bas64 string back from the camera. However, sometimes when confirming the photo in the camera app (when it should return to my app), it restarts my app.

I’ve tried using the cordova-plugin-background-mode plugin to enable the backgroundMode just before starting the camera, but this doesn’t change the outcome (this makes it “worse” because now the app doesn’t restart, but is just killed).

I’ve checked if it’s a memory issue, but it also happens on devices that have more than enough memory (8gb, more than 3gb free)

Code example

// Camera options
this.defaultCameraOptions = {
    quality: 80,
    destinationType: DestinationType.DATA_URL,
    encodingType: EncodingType.JPEG,
    mediaType: MediaType.PICTURE,
    targetHeight: 1000,
    targetWidth: 1000,
    correctOrientation: true,
    saveToPhotoAlbum: false,
    cameraDirection: 0,
    sourceType: PictureSourceType.CAMERA
};

const cameraResult: string = await this.camera.getPicture(this.defaultCameraOptions);

let resultBase64: string = '';
if (cameraResult) {
    resultBase64 = 'data:image/jpeg;base64,' + cameraResult;
}

console.log(resultBase64);

Debug logs:
Using logcat I got the following logs:

PluginManager: THREAD WARNING: exec() call to Camera.takePicture blocked the main thread for 40ms. Plugin should use CordovaInterface.getThreadPool().
CordovaActivity: Paused the activity.
CordovaActivity: Stopped the activity.

Process : Sending signal. PID: 29900 SIG: 9
Zygote  : Process 29900 exited due to signal 9 (Killed)
ActivityManager: Process <package.id> (pid 29900) has died: fore TOP 
libprocessgroup: Successfully killed process cgroup uid 10175 pid 29900 in 0ms

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 48976

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>