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

Low Memory error on Android 10 #74

Open
wimZ opened this issue May 13, 2020 · 47 comments
Open

Low Memory error on Android 10 #74

wimZ opened this issue May 13, 2020 · 47 comments
Assignees
Labels
Library Bug PriorityFix Most Urgent Issues to work on

Comments

@wimZ
Copy link

wimZ commented May 13, 2020

ScanDoc after the camera finishes, sometimes comes with a Low Memory warning. It seems related to the complexity/darkness of the image. the app does not crash since the library fix (4.2.5), but continues after a tap/back.
I have tried with image-quality 1 and 2.5 with the same result.
I never observed this issue on Android 9, but it appeared after upgrading to Android 10.

This is the error message
ScanDoc Low Memory Error

Versions:

  • Scandoc version 4.2.5
  • Cordova Version: 9.0.0 (cordova-lib@9.0.1)
  • Cordova Platform: Android 8.1.0
  • Device OS: Android 10
  • Device: Samsung S9

If there any additional info or assistance is needed, please let me know.
I appreciate any suggestions.

@atebsy
Copy link

atebsy commented Jun 26, 2020

I have observed the same issue on my side

@ChrisTomAlx
Copy link
Collaborator

This issue has to be fixed in the library. Not sure when I will be able to take a look at it though. This is a good starting point anyone trying to tackle this issue.

Cheers,
Chris
Neutrinos

@sachiv-logiciel
Copy link

I am getting the same issue in my ionic project. is somebody find any way to fix this problem?

@narupareliya
Copy link

Same issue im facing, help me asap.

@narupareliya
Copy link

I have observed the same issue on my side

when will u fix this?

@narupareliya
Copy link

narupareliya commented Jul 29, 2020

@ChrisTomAlx Can u tell me when u will help
Low memory issue in plugin

@ChrisTomAlx
Copy link
Collaborator

There is no timeline as of now. So I don't really have an immediate answer for you. But I can look at any PRs that are raised to address this issue.

Cheers,
Chris
Neutrinos

@narupareliya
Copy link

narupareliya commented Aug 7, 2020 via email

@narupareliya
Copy link

narupareliya commented Aug 18, 2020 via email

@anshumanfs
Copy link

anshumanfs commented Aug 18, 2020 via email

@NautamSanghani
Copy link

cordova plugin add cordova-plugin-document-scannner

Command failed with exit code 1: npm view cordova-plugin-document-scannner --json
npm ERR! code E404
npm ERR! 404 'cordova-plugin-document-scannner' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it
npm ERR! 404 (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! 404
npm ERR! 404 'cordova-plugin-document-scannner@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/nalin/.npm/_logs/2020-08-20T04_54_06_917Z-debug.log
{
"error": {
"code": "E404",
"summary": "'cordova-plugin-document-scannner' is not in the npm registry.\nYou should bug the author to publish it\n(or use the name yourself!)\n\nNote that you can also install from a\ntarball, folder, http url, or git url.",
"detail": "\n 'cordova-plugin-document-scannner@latest' is not in the npm registry.\nYou should bug the author to publish it (or use the name yourself!)\n\nNote that you can also install from a\ntarball, folder, http url, or git url."
}
}

@anshumanfs
Copy link

cordova plugin add cordova-plugin-document-scannner

Command failed with exit code 1: npm view cordova-plugin-document-scannner --json
npm ERR! code E404
npm ERR! 404 'cordova-plugin-document-scannner' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it
npm ERR! 404 (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! 404
npm ERR! 404 'cordova-plugin-document-scannner@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/nalin/.npm/_logs/2020-08-20T04_54_06_917Z-debug.log
{
"error": {
"code": "E404",
"summary": "'cordova-plugin-document-scannner' is not in the npm registry.\nYou should bug the author to publish it\n(or use the name yourself!)\n\nNote that you can also install from a\ntarball, folder, http url, or git url.",
"detail": "\n 'cordova-plugin-document-scannner@latest' is not in the npm registry.\nYou should bug the author to publish it (or use the name yourself!)\n\nNote that you can also install from a\ntarball, folder, http url, or git url."
}
}

@NautamSanghani sorry Bro by mistake I used ""cordova-plugin-document-scannner"" , which is actually "cordova-plugin-document-scanner"( spell mistakes)

@narupareliya
Copy link

narupareliya commented Aug 22, 2020 via email

@SeaEagleEye
Copy link

It's not working in Android 10, Samsung Galaxy J8 mobile after taking picture it's showing black screen
blankScreen

@davidquon
Copy link

I'm having the same black screen problem as #74 (comment) running Android 10 on a Samsung Galaxy S9. I'm using Ionic and Cordova with this plugin.

Ionic CLI         : 6.11.8
Cordova CLI       : 10.0.0
Cordova Platforms : android 9.0.0, ios 6.1.0

@SeaEagleEye
Copy link

remove platform android and run ionic cordova platform add android@8.0.0

@davidquon
Copy link

remove platform android and run ionic cordova platform add android@8.0.0

@SeaEagleEye Do you know what the issue is requiring moving back to 8.0.0?

@SeaEagleEye
Copy link

SeaEagleEye commented Sep 17, 2020 via email

@NautamSanghani
Copy link

NautamSanghani commented Sep 17, 2020 via email

@ChrisTomAlx
Copy link
Collaborator

Does using cordova-android 8.0.0 fix this issue for you as well @davidquon? Don't have a device to replicate this issue so would appreciate it if you could get back on the status.

Cheers,
Chris
Neutrinos

@wimZ
Copy link
Author

wimZ commented Sep 17, 2020

For me it works on android 8.0 using android-targetSdkVersion: 29

@wimZ
Copy link
Author

wimZ commented Sep 20, 2020

Unluckily it does not work on 8.1.0, and that is the version that enables application bundles (.aab)

@ChrisTomAlx ChrisTomAlx added the PriorityFix Most Urgent Issues to work on label Sep 21, 2020
@ChrisTomAlx
Copy link
Collaborator

That is really strange. I will try and pick this up as soon as work on the plugin starts again

Thanks for all the testing you guys have done :)

Cheers,
Chris
Neutrinos

@NautamSanghani
Copy link

NautamSanghani commented Sep 21, 2020 via email

@benediktcarda
Copy link

I can confirm the observation of SeaEagleEye that the plugin shows the black screen after taking the picture. Anyway reverting to cordova platform Android 8 did not solve the issue for me.

@ChrisTomAlx
Copy link
Collaborator

Released a new beta version of the plugin.

To test it :-

  1. Make sure to remove the old version using cordova plugin rm cordova-plugin-document-scanner
  2. To test it add the following to your project
    • cordova plugin add cordova-plugin-document-scanner@5.0.0-beta.0
    • cordova plugin add cordova plugin add cordova-plugin-androidx
    • cordova plugin add cordova-plugin-androidx-adapter

If you guys could help by testing this beta version and let me know if it solved your issue, I can release the 5.0.0 version. Latest plugin also solves this issue

Cheers and have a nice day :)
Chris
Neutrinos

@wimZ
Copy link
Author

wimZ commented Nov 10, 2020 via email

@ChrisTomAlx
Copy link
Collaborator

Thanks @wimZ
Appreciate it :))

Cheers,
Chris
Neutrinos

@benediktcarda
Copy link

benediktcarda commented Nov 17, 2020

I tested the beta but the behaviour does not change. After taking the photo it still shows the black screen like SeaEagleEye showed on 8 Sep.

Additional information, but probably not a problem. When adding the plugin "cordova-plugin-androidx" I get the following output:

cordova plugin add cordova-plugin-androidx
Installing "cordova-plugin-androidx" for android
Plugin doesn't support this project's cordova-android version. cordova-android: 9.0.0, failed version requirement: <9.0.0
Skipping 'cordova-plugin-androidx' for android
Adding cordova-plugin-androidx to package.json

Seems like cordova android 9.0 doesn't need cordova-plugin-androidx?

@wimZ
Copy link
Author

wimZ commented Nov 17, 2020 via email

@ChrisTomAlx
Copy link
Collaborator

@benediktcarda @wimZ Could you guys add the following to config.xml as suggested by this comment and see if the issue persists?

<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
   <application android:usesCleartextTraffic="true" android:requestLegacyExternalStorage="true"/>
</edit-config>

Also @benediktcarda it does not matter that cordova-plugin-androidx is deprecated, just add it nonetheless and add the other one too. You can ignore the deprecation notice and continue.

Cheers,
Chris
Neutrinos

@wimZ
Copy link
Author

wimZ commented Nov 17, 2020 via email

@benediktcarda
Copy link

After adding

<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application"> <application android:usesCleartextTraffic="true" android:requestLegacyExternalStorage="true"/> </edit-config>

it started to work again (I can crop the scanned pages and save to my application), but now I get the low memory message wimZ reported initially.

@ChrisTomAlx
Copy link
Collaborator

@wimZ If possible when you reply via email click the 3 dots and remove the history then respond. I have edited your comments and removed the unnecessary reply quotes for now. Also thanks for helping with the testing :). Let me know if you face any other issues in your testing. I will also fix this need to request legacy storage before I release ver 5.0.0.

@benediktcarda Is it just showing low memory error and then you are able to scan normally? or low memory then it just keeps opening up the camera UI over and over again until app crashes? If you are able to continue normally it might actually be an issue with memory and this is expected behavior. Either way let me see what I can find and thank for testing the beta version :)

Cheers,
Chris
Neutrinos

@onlyplaytama
Copy link

onlyplaytama commented Dec 20, 2020

hi @ChrisTomAlx ..

i saw in your scan library

createdirectory when opencamera is not working with API 29

even if i put androidx and this one still not working also
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application"> <application android:usesCleartextTraffic="true" android:requestLegacyExternalStorage="true"/> </edit-config>

and this code one is not working anymore with API 29 ,
Environment.getExternalStorageDirectory()

i did debug , and i found this :

W/System.err: java.io.FileNotFoundException: open failed: ENOENT (No such file or directory)
W/System.err:     at android.os.ParcelFileDescriptor.openInternal(ParcelFileDescriptor.java:315)
W/System.err:     at android.os.ParcelFileDescriptor.open(ParcelFileDescriptor.java:220)
        at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1505)
        at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1427)
        at com.scanlibrary.PickImageFragment.getBitmap(PickImageFragment.java:238)
        at com.scanlibrary.PickImageFragment.onActivityResult(PickImageFragment.java:165)
        at android.app.Activity.dispatchActivityResult(Activity.java:8319)
        at android.app.ActivityThread.deliverResults(ActivityThread.java:5090)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:5138)
        at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2147)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:7814)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1068)

and also this one , i think this one when opencamera function

W/System.err:     at com.scanlibrary.PickImageFragment.clearTempImages(PickImageFragment.java:75)
        at com.scanlibrary.PickImageFragment.createImageFile(PickImageFragment.java:148)
        at com.scanlibrary.PickImageFragment.openCamera(PickImageFragment.java:128)
        at com.scanlibrary.PickImageFragment.handleIntentPreference(PickImageFragment.java:85)
        at com.scanlibrary.PickImageFragment.init(PickImageFragment.java:66)
        at com.scanlibrary.PickImageFragment.onCreateView(PickImageFragment.java:56)
        at android.app.Fragment.performCreateView(Fragment.java:2534)
        at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1303)
W/System.err:     at android.app.FragmentManagerImpl.addAddedFragments(FragmentManager.java:2431)
        at android.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2210)
        at android.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2166)
        at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2067)
        at android.app.FragmentManagerImpl.dispatchMoveToState(FragmentManager.java:3057)
        at android.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3004)
        at android.app.FragmentController.dispatchActivityCreated(FragmentController.java:184)
        at android.app.Activity.performCreate(Activity.java:7962)
        at android.app.Activity.performCreate(Activity.java:7944)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3423)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3595)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2147)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:7814)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1068)
D/: openCamera: isDirectoryCreated: false

already try run with your scanlibrary 3.2 still not working

Update :
i found that Storage permission are not Allowed , already put <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> in AndroidManifest.xml but its not working , after i turn on allow manually from setting->apps->permision . its working

reg,
tama

@sergiuturus
Copy link

sergiuturus commented Feb 10, 2021

I also get the "Incorrect result or user cancelled the action" message when I take a photo.

Adding android:requestLegacyExternalStorage="true" to the AndroidManifest.xml seems to fix the problem but idk if this is a viable solution as @ChrisTomAlx noted here #82 (comment)

@ChrisTomAlx
Copy link
Collaborator

ChrisTomAlx commented Feb 11, 2021

@sergiuturus Released 5.0.0-beta.1 of this plugin with the fixes. Let me know if this fixes your issue.

To test it :-

  1. Make sure to remove the old version using cordova plugin rm cordova-plugin-document-scanner
  2. To test it add the following to your project
    • cordova plugin add cordova-plugin-document-scanner@5.0.0-beta.1
    • cordova plugin add cordova-plugin-androidx
    • cordova plugin add cordova-plugin-androidx-adapter

Cheers and have a nice day :)
Chris
Neutrinos

@ChrisTomAlx
Copy link
Collaborator

@onlyplaytama You could try and use the diagnostic plugin to manage permissions.

Cheers and have a nice day :)
Chris
Neutrinos

@HerickRaposo
Copy link

HerickRaposo commented Apr 6, 2021

In my case, on android, the plugin dont clear images, how can i exclude generated image by plugin?

@HerickRaposo
Copy link

The comand cordova plugin add cordova-plugin-document-scanner@5.0.0-beta.1 work to me, but dont clear saved images in android

@rubenmiq
Copy link

@sergiuturus Released 5.0.0-beta.1 of this plugin with the fixes. Let me know if this fixes your issue.

To test it :-

  1. Make sure to remove the old version using cordova plugin rm cordova-plugin-document-scanner

  2. To test it add the following to your project

    • cordova plugin add cordova-plugin-document-scanner@5.0.0-beta.1
    • cordova plugin add cordova-plugin-androidx
    • cordova plugin add cordova-plugin-androidx-adapter

Cheers and have a nice day :)
Chris
Neutrinos

Still showing the low memory message, but in the end the scan is made.
I am using cordova android 9.0.0 so i did not install the AndroidX plugins, because they are not compatible with version 9

@HerickRaposo
Copy link

HerickRaposo commented Apr 16, 2021

@sergiuturus Lançado 5.0.0-beta.1 deste plugin com as correções. Avise-me se isso resolver o seu problema.

Para testar: -

  1. Certifique-se de remover a versão antiga usando cordova plugin rm cordova-plugin-document-scanner

  2. Para testá-lo, dependerá do seguinte ao seu projeto

    • cordova plugin add cordova-plugin-document-scanner@5.0.0-beta.1
    • cordova plugin add cordova-plugin-androidx
    • cordova plugin add cordova-plugin-androidx-adapter

Saúde e tenha um bom dia :)
Chris
Neutrinos

I solved the exclusion problem using the cordova file plugin.however I was unable to remove the low memory message. How can I hide it? Do you have a solution? If so tell me where I should modify that I even fork or branch

getCamera(){
       let opts: DocumentScannerOptions = {
      sourceType:1,
      quality:2.0,
      returnBase64: false,
    };
    this.documentScanner.scanDoc(opts)
    .then((res) =>{
      console.log(res)
        if (this.platform.is('ios')) {
          let img = this.webview.convertFileSrc(res)
          let imagemTratada = this.domSanatize.bypassSecurityTrustUrl(img)
          this.images.push(imagemTratada)
          this.caminhoImg.push(res)
        } else {
          this.filePath.resolveNativePath(res).then((url) => {
            //Data = file:///storage/emulated/0/Pictures/ + nome da imagem
            this.filePath.resolveNativePath(res).then((data) => {
              let filename =  res.substring(res.lastIndexOf('/') +1);
              let path = res.substring(0,res.lastIndexOf('/') +1)

              this.file.readAsDataURL(path,filename).then((base64string) => {
                console.log(base64string)
                this.images.push(base64string)
                this.file.resolveDirectoryUrl(this.file.cacheDirectory).then(data => {
                  console.log(data.nativeURL) ;
                  this.file.moveFile(path, filename, data.nativeURL,filename).then((resposta)=>{
                    console.log(resposta)
                    console.log(resposta.nativeURL)
                    this.caminhoImg.push(resposta.nativeURL)
                  }).catch((error) => console.log(error))
                });
              })
            })
          })
          
        }
        this.verificaCondicao();
    })
    .catch((error) => console.error(error));
  }

limpaDiretorio(){
    this.file.resolveDirectoryUrl(this.file.externalRootDirectory ).then((data)=>{
      let caminho = data.nativeURL
      this.file.removeRecursively(caminho, 'scanSample').then((res) =>{
        console.log(res)
        this.limpaCache();
      }).catch(error => {
        console.log(error)
        this.limpaCache();
      })
    }).catch(error => console.log(error))
  }
  
  limpaCache(){
    this.file.resolveDirectoryUrl(this.file.cacheDirectory).then(data => {
      this.file.listDir(data.nativeURL, '').then(async (res) => {
        console.log(res)
        if (res.length > 0 ) {
          for (let i = 0; i < res.length; i++) {

            await this.file.resolveLocalFilesystemUrl(res[i].nativeURL).then((newNativeURL)=> {
              newNativeURL.remove(
                ()=>console.log('sucesso ao excluir'), 
                ()=>console.log('Erro ao excluir')
              );
            })
          }
        }
      })
    });
  }

@ManishBolbanda-dev
Copy link

can some one give me the code to get Base64 of image in Pictures. path : file:///storage/emulated/0/Pictures/my_image.jpg
am trying to get base64 string from Base64 & File plugins but through both the approach am getting null outpot

@benediktcarda
Copy link

The problem that after taking a picture it's showing a black screen is back. Got it reported from a user and tried it myself. When having the blank black screen you can do nothing but either click on the camera icon and take another photo (which again leads to the black screen) or you can click on the folder icon, choose another photo from the gallery and even manipulate the edges but as soon as you click "save" you get the error:

open /storage/emulated/0/Pictures/Title - Sun Mar 13 16-23_45 GMT+01_00 2000.jpg: open failed: EACCES (Permission denied)

@Dbouwheer
Copy link

Dbouwheer commented Jun 29, 2022

@ChrisTomAlx : just a thought, but i do not have any app building experience.

The error pops up just after the "cropping/automatic edge selection" stage.
It seems to me that the “cropping” is done while the photo taken is still in high quality.
Is this a very memory intentive task? Otherwise maybe descaled the image to a lower quality before this stage.
Instead of adjusting the quality in a later stage.

Will delete the comment if i'm talking nonsense ;)

@pedro-sh
Copy link

Hola ¿Alguien ha podido encontrar solucion a este problema?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Library Bug PriorityFix Most Urgent Issues to work on
Projects
None yet
Development

No branches or pull requests