You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2021/04/23 14:12:35 UTC

[GitHub] [cordova-plugin-camera] HerickRaposo opened a new issue #721: Application fails to take photos with the camera on some android devices

HerickRaposo opened a new issue #721:
URL: https://github.com/apache/cordova-plugin-camera/issues/721


   # Bug Report
   
   ## Problem
   
   Application fails to take photos with the camera on some android devices
   
   ### What is expected to happen?
   
   It is expected that the application after capturing and selecting the preview image will be able to continue the return process without closing the application.
   
   ### What does actually happen?
   
   After taking the image capture and confirming the preview, the process is cut and the application is closed.
   More specifically, when the application is in the background and the camera is accessed, after capturing, previewing and confirming, when trying to return to the application, the system ends the application process, therefore not being able to continue returning the image to the application
   
   ## Information
   <!-- Include all relevant information that might help understand and reproduce the problem -->
   
   According to research, the problem is due to a memory leak, however, the devices where the problem occurred do not lack this feature.
   The problem so far has been encountered most frequently on Android Motorola devices. In my case, the problem was observed in the motoG7Play and MotoG8 phones.
   
   Following instructions from Ionic and GitHub forums, I found some solutions like:
   
   1. enable cordova-plugin-background-mode before capture and disable after (Not Work in Redmi note 7)
   2. Add `<preference name="AndroidLaunchMode" value="singleTask" />` in config.xml (Reduced cases in MotoG8)
   3. Set destinationType to DATA_URL, returning base64 format, later transforming the content into an image recorded on the device. (Dont work)
   
   
   **Search References**
   
   1. [Android Platform Guide](https://cordova.apache.org/docs/en/dev/guide/platforms/android/index.html#what-makes-android-different)
   2. [Ionic cordova-plugin-camera crash the application after take picture](https://github.com/apache/cordova-plugin-camera/issues/705)
   3. [App crashes after taking photo from camera](https://forum.ionicframework.com/t/app-crashes-after-taking-photo-from-camera/100754)
   4. [Native camera ionic make app crash after taking picture](https://stackoverflow.com/questions/49208695/native-camera-ionic-make-app-crash-after-taking-picture)
   5. [Camera plugin crashes app on some android phones when an image is taken](https://github.com/apache/cordova-plugin-camera/issues/345)
   end others
   
   ### Command or Code
   <!-- What command or code is needed to reproduce the problem? -->
   
   I will show you the base codes (First code) and the codes of the aforementioned attempts.
   **Required plugins:** cordova-plugin-file,cordova-plugin-ionic-webview, 
   
   #### Base Code:
   ```
   getimage(op){
       const options: CameraOptions = {
         quality: 85, 
   			destinationType: this.camera.DestinationType.FILE_URI,
   			sourceType: (op == 1) ? this.camera.PictureSourceType.CAMERA : this.camera.PictureSourceType.PHOTOLIBRARY,
   			encodingType: this.camera.EncodingType.JPEG,
   			saveToPhotoAlbum: false,
   			correctOrientation: true,
   
       }
   
       this.camera.getPicture(options).then((imagedata) => {
         let img = this.webview.convertFileSrc(imagedata)
         let imagemTratada = this.domSanatize.bypassSecurityTrustUrl(img)
         this.images.push(imagemTratada)
         if (this.platform.is('ios')) {
           this.caminhoImg.push(imagedata)
         } else {
           this.file.resolveLocalFilesystemUrl(imagedata).then((data)=>{
             this.caminhoImg.push(data.nativeURL);
           }).catch(error => console.log('error'))
         }
         this.verificaCondicao();
       })
     }
   ```
   #### Second Code:
   
   ```
   getimage(op){
       const options: CameraOptions = {
         quality: 85, 
   			destinationType: this.camera.DestinationType.DATA_URL,
   			sourceType: (op == 1) ? this.camera.PictureSourceType.CAMERA : this.camera.PictureSourceType.PHOTOLIBRARY,
   			encodingType: this.camera.EncodingType.JPEG,
   			saveToPhotoAlbum: false,
   			correctOrientation: true,
       }
   
       this.camera.getPicture(options).then((imagedata) => {
         let base64 = 'data:image/jpeg;base64,' + imagedata;
         let blob = this.makeblob(base64);
         let image = this.domSanatize.bypassSecurityTrustUrl(base64)
         this.images.push(image)
         this.file.resolveDirectoryUrl(this.file.cacheDirectory).then((diretorio)=>{
           diretorio.getFile('Image' + Date.now() + '.jpg',{create:true}, (file)=> {
             console.log(file)
             file.createWriter((fileWriter)=>{
               fileWriter.write(blob)
               this.caminhoImg.push(file.nativeURL)
             },
             (error)=>{
               console.log('Unable to save file in path '+ diretorio.nativeURL);
             })
           })
         })
       })
     }
   ```
   ### Environment, Platform, Device
   <!-- In what environment, on what platform or on which device are you experiencing the issue? -->
   
   
   The problem was found during the development of the application with ionic Framework and cord, based on the TypeScript Angular and using Android Studio 4.1 and sdk 28. The devices used for testing were Redmi note 7, iPed Pro, iPhone 5s, iPhone6, MotoG7Play, MotoG8, the camera bug only on the devices: MotoG7Play and MotoG8.
   
   
   ### Version information
   <!-- 
   What are relevant versions you are using?
   For example:
   Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins 
   Other Frameworks: Ionic Framework and CLI version
   Operating System, Android Studio, Xcode etc.
   -->
   
   ```
     Ionic CLI                     : 6.13.1 (C:\Users\micro-85\AppData\Roaming\npm\node_modules\@ionic\cli)
      Ionic Framework               : @ionic/angular 5.6.4
      @angular-devkit/build-angular : 0.1000.8
      @angular-devkit/schematics    : 10.0.8
      @angular/cli                  : 10.0.8
      @ionic/angular-toolkit        : 2.3.3
   
   Cordova:
   
      Cordova CLI       : 10.0.0
      Cordova Platforms : android 9.1.0
      Cordova Plugins   : not available
   
   Utility:
   
      cordova-res : 0.15.3
      native-run  : 1.3.0
   
   System:
   
      NodeJS : v14.15.0 (C:\Program Files\nodejs\node.exe)
      npm    : 6.14.9
      OS     : Windows 10
    
   Android:
   
     AndroidStudio:  4.1
     SDK :28
   ```
   
   ## Checklist
   <!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
   
   - [x] I searched for existing GitHub issues
   - [x] I updated all Cordova tooling to most recent version
   - [x] I included all the necessary information above
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-camera] AmrAbdalrahman commented on issue #721: Application fails to take photos with the camera on some android devices

Posted by GitBox <gi...@apache.org>.
AmrAbdalrahman commented on issue #721:
URL: https://github.com/apache/cordova-plugin-camera/issues/721#issuecomment-826105033


   the same with me, ionic 3, and after updating targetSdkVersion 28 to 29 capture image not show !!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-camera] AmrAbdalrahman commented on issue #721: Application fails to take photos with the camera on some android devices

Posted by GitBox <gi...@apache.org>.
AmrAbdalrahman commented on issue #721:
URL: https://github.com/apache/cordova-plugin-camera/issues/721#issuecomment-826105033


   the same with me, ionic 3, and after updating targetSdkVersion 28 to 29 capture image not show !!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-camera] mirko77 commented on issue #721: Application fails to take photos with the camera on some android devices

Posted by GitBox <gi...@apache.org>.
mirko77 commented on issue #721:
URL: https://github.com/apache/cordova-plugin-camera/issues/721#issuecomment-827471407


   This issue is expected and it has been around for years. When the app goes into the background and the camera app is in the foreground, the system can kill the background app at any time. Even if the phone has 10 GB of free memory. It is a limitation of hybrid apps. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-camera] mirko77 edited a comment on issue #721: Application fails to take photos with the camera on some android devices

Posted by GitBox <gi...@apache.org>.
mirko77 edited a comment on issue #721:
URL: https://github.com/apache/cordova-plugin-camera/issues/721#issuecomment-827471407


   This issue is expected and it has been around for years. When the app goes into the background and the camera app is in the foreground, the system can kill the background app at any time. Even if the phone has 10 GB of free RAM. It is a limitation of hybrid apps. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-camera] PieterVanPoyer closed issue #721: Application fails to take photos with the camera on some android devices

Posted by GitBox <gi...@apache.org>.
PieterVanPoyer closed issue #721:
URL: https://github.com/apache/cordova-plugin-camera/issues/721


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-camera] mirko77 edited a comment on issue #721: Application fails to take photos with the camera on some android devices

Posted by GitBox <gi...@apache.org>.
mirko77 edited a comment on issue #721:
URL: https://github.com/apache/cordova-plugin-camera/issues/721#issuecomment-827471407


   This issue is expected and it has been around for years. When the app goes into the background and the camera app is in the foreground, the system can kill the background app at any time. Even if the phone has 10 GB of free RAM. It is a limitation of hybrid apps. There is not any solution on the Cordova side, you might try the [Camera Preview plugin](https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview) and build your embedded camera UI. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-camera] mirko77 edited a comment on issue #721: Application fails to take photos with the camera on some android devices

Posted by GitBox <gi...@apache.org>.
mirko77 edited a comment on issue #721:
URL: https://github.com/apache/cordova-plugin-camera/issues/721#issuecomment-827471407


   This issue is expected and it has been around for years. When the Cordova app goes into the background and the camera app is in the foreground, the system can kill the Cordova app at any time. Even if the phone has 10 GB of free RAM. It is a limitation of hybrid apps. There is not any solution on the Cordova side, you might try the [Camera Preview plugin](https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview) and build your embedded camera UI. But anyway for production enterprise apps where the camera features need to be reliable at all times, Cordova (and hybrid apps in general) are not recommended.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-camera] mirko77 edited a comment on issue #721: Application fails to take photos with the camera on some android devices

Posted by GitBox <gi...@apache.org>.
mirko77 edited a comment on issue #721:
URL: https://github.com/apache/cordova-plugin-camera/issues/721#issuecomment-827471407


   This issue is expected and it has been around for years. When the Cordova app goes into the background and the camera app is in the foreground, the system can kill the Cordova app at any time. Even if the phone has 10 GB of free RAM. It is a limitation of hybrid apps. There is not any solution on the Cordova side, you might try the [Camera Preview plugin](https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview) and build your embedded camera UI. But anyway for production apps where the camera features need to be reliable at all times, Cordova (and hybrid apps in general) are not recommended.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-camera] PieterVanPoyer commented on issue #721: Application fails to take photos with the camera on some android devices

Posted by GitBox <gi...@apache.org>.
PieterVanPoyer commented on issue #721:
URL: https://github.com/apache/cordova-plugin-camera/issues/721#issuecomment-843525187


   I have to agree with @mirko77 . More details can be found at: https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-camera/index.html#android-quirks 
   Version 5.0.2 is released previous week. You could try that version and when everything goes well, the result after an app restart during the camera action, should be in the PendingResult.
   It's up to you to save the state of the app before the camera action is started and to guide the users back to the correct part of the app (with the photo from the PendingResult).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-camera] mirko77 edited a comment on issue #721: Application fails to take photos with the camera on some android devices

Posted by GitBox <gi...@apache.org>.
mirko77 edited a comment on issue #721:
URL: https://github.com/apache/cordova-plugin-camera/issues/721#issuecomment-827471407


   This issue is expected and it has been around for years. When the app goes into the background and the camera app is in the foreground, the system can kill the background app at any time. Even if the phone has 10 GB of free RAM. It is a limitation of hybrid apps. There is not any solution on the Cordova side, you might try the [Camera Preview plugin](https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview) and build your embedded camera UI. But anyway for production enterprise apps where the camera features need to be reliable at all times, Cordova (and hybrid apps in general) are not recommended.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


[GitHub] [cordova-plugin-camera] PieterVanPoyer commented on issue #721: Application fails to take photos with the camera on some android devices

Posted by GitBox <gi...@apache.org>.
PieterVanPoyer commented on issue #721:
URL: https://github.com/apache/cordova-plugin-camera/issues/721#issuecomment-855278384


   Closing ticket due to lack of response, issue is probably resolved in latest version.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org