dmlkl
May 7, 2019, 9:54am
1
Hi everyone,
I have been exploring this issue for a while. When I take a photo or select photo with the using of the native camera plugin, the app will auto reload. It happens randomly, the screen appears to be white for a while (1-3 secs) and reload. Is this the memory issue? or any other issue? Does anyone know?
Thanks in advance.
1 Like
It’s how Android behave when there isn’t enough memory available
I documented the subject when I was analyzing it and developing a solution to handle restart in the following post: https://forum.ionicframework.com/t/solved-camera-plugin-restart-app-on-android
dmlkl
May 8, 2019, 4:29am
3
Hi,
Thanks for reply. But the solution doesn’t seem to fix mine problem. The problem is still there with my iPhone 7s Plus. Any other suggestion?
Thanks.
Oh ok, effectively what I was explaining above is only effective for Android phones
Never had this problem with iPhone
Can you add the code that your using, if the app crashes due to some reasons, then also there is chance of above issue.
dmlkl
May 8, 2019, 5:55am
6
Hi all, below is my camera setting,
this.photoTakingOptions = {
quality: 90,
allowEdit: true,
sourceType: this.camera.PictureSourceType.CAMERA,
saveToPhotoAlbum: false,
correctOrientation: true,
targetWidth: 1000,
targetHeight: 1000,
destinationType: this.camera.DestinationType.DATA_URL,
mediaType: this.camera.MediaType.PICTURE,
encodingType: this.camera.EncodingType.JPEG
}
this.photoLibraryOptions = {
quality: 90,
allowEdit: true, *
sourceType: this.camera.PictureSourceType.PHOTOLIBRARY,
saveToPhotoAlbum: false,
correctOrientation: true,
targetWidth: 1000,
targetHeight: 1000,
destinationType: this.camera.DestinationType.DATA_URL,
encodingType: this.camera.EncodingType.JPEG,
mediaType: this.camera.MediaType.PICTURE
}
I did try to debug the error, but, the app refreshes without entering any condition (success or error).
photoTaking(id) {
let self = this;
this.camera.getPicture(this.photoTakingOptions).then((imageData) => {
this.camera.cleanup().then(() => {
})
var file = 'data:image/jpeg;base64,' + imageData;
self.upload(file, id);
self.toast = this.toastController.create({
message: "Processing ..."
});
self.toast.present();
}).catch(err =>{
console.error(err);
})
}
photoLibrary(id) {
let self = this;
this.camera.getPicture(this.photoLibraryOptions).then((imageData) => {
this.camera.cleanup().then(() => {
})
var file = 'data:image/jpeg;base64,' + imageData;
self.upload(file, id);
self.toast = this.toastController.create({
message: "Processing ..."
});
self.toast.present();
}).catch(err =>{
console.error(err);
})
}
Thanks.
Hi Can you remove below code from photoTaking function
this.camera.cleanup().then(() => {
})
var file = 'data:image/jpeg;base64,' + imageData;
self.upload(file, id);
self.toast = this.toastController.create({
message: "Processing ..."
});
self.toast.present();
and just put a log there,
console.log(imageData)
I think
this.camera.cleanup().then(() => {
})
is causing some issue.
dmlkl
May 8, 2019, 6:35am
8
Hi,
The cleanup function I just added today, this issue happened before I add the cleanup function. And it wont go into the .then function, the app just refresh after I took or select the photo. So even if I add console on .then function or catch error function, it wont be triggered.
Thanks.