NeutrinosPlatform / cordova-plugin-document-scanner

cordova plugin for document scan
https://www.neutrinos.co/
MIT License
85 stars 61 forks source link

Android 10 (One plus phone) document scanner hangs and after some time crashes #72

Closed ndev10 closed 4 years ago

ndev10 commented 4 years ago

Code looks like this

` const opts: DocumentScannerOptions = {

  sourceType: DocumentScannerSourceType.CAMERA,
  quality: 5.0,
  returnBase64: true
};

this.documentScanner.scanDoc(opts)
  .then((imageData: string) => {
    this.uploadedDocuments.push(imageData);
    this.presentAddMorePopup(false);
  }).catch((error: any) => {
    console.error("need to run in device")
  });

` Even on lowest quality it hands and then crashes Please find below image 1584117549219

ChrisTomAlx commented 4 years ago

Hey @ndev10

Could you share the error stack trace from android studio?

Cheers and have a nice day :) Chris Neutrinos

ndev10 commented 4 years ago

Thanks Chris for prompt response..

Following are the stack trace from android studio..

D/ViewRootImpl@39a01b3[MainActivity]: ViewPostIme pointer 0 D/ViewRootImpl@39a01b3[MainActivity]: ViewPostIme pointer 1 D/Capacitor: Handling local request: http://localhost/assets/header-bg.svg D/InputMethodManager: HSIFW - flag : 0 Pid : 14456 D/Capacitor: Handling local request: http://localhost/assets/icon/favicon.png D/Capacitor: Handling local request: http://localhost/assets/logo-sm.svg D/ViewRootImpl@39a01b3[MainActivity]: ViewPostIme pointer 0 D/ViewRootImpl@39a01b3[MainActivity]: ViewPostIme pointer 1 D/InputMethodManager: HSIFW - flag : 0 Pid : 14456 D/Capacitor: Handling local request: http://localhost/1-es2015.js D/ViewRootImpl@39a01b3[MainActivity]: ViewPostIme pointer 0 D/ViewRootImpl@39a01b3[MainActivity]: ViewPostIme pointer 1 V/Capacitor/Plugin: To native (Cordova plugin): callbackId: Scan1824875570, service: Scan, action: scanDoc, actionArgs: [1,"image",5,true] D/Capacitor: App paused D/InputMethodManager: HSIFW - flag : 0 Pid : 14456 D/ViewRootImpl@2dd90ff[MainActivity]: dispatchDetachedFromWindow Surface release. android.view.ViewRootImpl.doDie:7979 android.view.ViewRootImpl$ViewRootHandler.handleMessage:4970 android.os.Handler.dispatchMessage:106 android.os.Looper.loop:214 android.app.ActivityThread.main:7050 java.lang.reflect.Method.invoke:-2 com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run:494 com.android.internal.os.ZygoteInit.main:965 D/InputTransport: Input channel destroyed: fd=150 W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@29d1401 I/DecorView: createDecorCaptionView >> DecorView@a59a332[], isFloating: false, isApplication: true, hasWindowDecorCaption: false, hasWindowControllerCallback: true D/InputTransport: Input channel constructed: fd=179 D/ViewRootImpl@291ff71[ScanActivity]: setView = DecorView@a59a332[ScanActivity] TM=true MM=false D/ViewRootImpl@39a01b3[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 0 1 D/InputMethodManager: prepareNavigationBarInfo() DecorView@4d3817c[MainActivity] getNavigationBarColor() -855310 D/ViewRootImpl@291ff71[ScanActivity]: dispatchAttachedToWindow D/ViewRootImpl@291ff71[ScanActivity]: Relayout returned: old=[0,0][1080,2220] new=[0,0][1080,2220] result=0x7 surface={valid=true 514106040320} changed=true D/mali_winsys: EGLint new_window_surface(egl_winsys_display , void , EGLSurface, EGLConfig, egl_winsys_surface , EGLBoolean) returns 0x3000 D/OpenGLRenderer: eglCreateWindowSurface = 0x77b5ba7f00, 0x77b31ba010 D/ViewRootImpl@291ff71[ScanActivity]: MSG_RESIZED: frame=Rect(0, 0 - 1080, 2220) ci=Rect(0, 72 - 0, 144) vi=Rect(0, 72 - 0, 144) or=1 D/ViewRootImpl@291ff71[ScanActivity]: MSG_WINDOW_FOCUS_CHANGED 0 1 D/InputMethodManager: prepareNavigationBarInfo() DecorView@a59a332[ScanActivity] getNavigationBarColor() -855310 D/ViewRootImpl@291ff71[ScanActivity]: MSG_WINDOW_FOCUS_CHANGED 0 0 D/InputMethodManager: HSIFW - flag : 0 Pid : 14456 D/InputTransport: Input channel destroyed: fd=170 W/libEGL: EGLNativeWindowType 0x77be279010 disconnect failed D/OpenGLRenderer: eglDestroySurface = 0x77cf696100, 0x77be279000 D/ViewRootImpl@39a01b3[MainActivity]: Relayout returned: old=[0,0][1080,2220] new=[0,0][1080,2220] result=0x5 surface={valid=false 0} changed=true D/ViewRootImpl@39a01b3[MainActivity]: Relayout returned: old=[0,0][1080,2220] new=[0,0][1080,2220] result=0x1 surface={valid=false 0} changed=false D/ViewRootImpl@39a01b3[MainActivity]: setWindowStopped(true) old=false D/ViewRootImpl@39a01b3[MainActivity]: Surface release. android.view.WindowManagerGlobal.setStoppedState:669 android.app.Activity.performStop:7650 android.app.ActivityThread.callActivityOnStop:4379 android.app.ActivityThread.performStopActivityInner:4357 android.app.ActivityThread.handleStopActivity:4432 android.app.servertransaction.StopActivityItem.execute:41 android.app.servertransaction.TransactionExecutor.executeLifecycleState:145 android.app.servertransaction.TransactionExecutor.execute:70 D/Capacitor/Plugin/App: Firing change: false V/Capacitor/Plugin/App: Notifying listeners for event appStateChange D/Capacitor/Plugin/App: No listeners found for event appStateChange D/Capacitor: App stopped D/Capacitor: Saving instance state! D/ViewRootImpl@39a01b3[MainActivity]: Relayout returned: old=[0,0][1080,2220] new=[0,0][1080,2220] result=0x1 surface={valid=false 0} changed=false D/ViewRootImpl@291ff71[ScanActivity]: setWindowStopped(false) old=false D/ViewRootImpl@291ff71[ScanActivity]: MSG_WINDOW_FOCUS_CHANGED 1 1 D/InputMethodManager: prepareNavigationBarInfo() DecorView@a59a332[ScanActivity] D/InputMethodManager: getNavigationBarColor() -855310 D/InputMethodManager: prepareNavigationBarInfo() DecorView@a59a332[ScanActivity] D/InputMethodManager: getNavigationBarColor() -855310 V/InputMethodManager: Starting input: tba=com.le.staffdna ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false D/InputMethodManager: startInputInner - Id : 0 I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus D/InputTransport: Input channel constructed: fd=151 D/ViewRootImpl@291ff71[ScanActivity]: Relayout returned: old=[0,0][1080,2220] new=[0,0][1080,2220] result=0x1 surface={valid=true 514106040320} changed=false D/ViewRootImpl@291ff71[ScanActivity]: MSG_WINDOW_FOCUS_CHANGED 0 1 D/InputMethodManager: prepareNavigationBarInfo() DecorView@a59a332[ScanActivity] getNavigationBarColor() -855310 D/InputTransport: Input channel destroyed: fd=151 W/libEGL: EGLNativeWindowType 0x77b31ba010 disconnect failed D/OpenGLRenderer: eglDestroySurface = 0x77b5ba7f00, 0x77b31ba000 D/ViewRootImpl@291ff71[ScanActivity]: Relayout returned: old=[0,0][1080,2220] new=[0,0][1080,2220] result=0x5 surface={valid=false 0} changed=true D/ViewRootImpl@291ff71[ScanActivity]: setWindowStopped(true) old=false D/ViewRootImpl@291ff71[ScanActivity]: Surface release. android.view.WindowManagerGlobal.setStoppedState:669 android.app.Activity.performStop:7650 android.app.ActivityThread.callActivityOnStop:4379 android.app.ActivityThread.performStopActivityInner:4357 android.app.ActivityThread.handleStopActivity:4432 android.app.servertransaction.StopActivityItem.execute:41 android.app.servertransaction.TransactionExecutor.executeLifecycleState:145 android.app.servertransaction.TransactionExecutor.execute:70 D/Dialog: mIsSamsungBasicInteraction = false mIsSamsungBasicInteraction = false, isMetaDataInActivity = false I/DecorView: createDecorCaptionView >> DecorView@a7621ad[], isFloating: true, isApplication: true, hasWindowDecorCaption: false, hasWindowControllerCallback: false D/ScrollView: initGoToTop D/ScrollView: initGoToTop D/InputTransport: Input channel constructed: fd=150 D/ViewRootImpl@563e463[ScanActivity]: setView = DecorView@a7621ad[ScanActivity] TM=true MM=false I/Choreographer: Skipped 72 frames! The application may be doing too much work on its main thread. D/ViewRootImpl@563e463[ScanActivity]: dispatchAttachedToWindow D/ViewRootImpl@563e463[ScanActivity]: Relayout returned: old=[0,72][1080,2076] new=[540,1038][540,1038] result=0x1 surface={valid=false 0} changed=false W/StaticLayout: maxLineHeight should not be -1. maxLines:2 lineCount:2 W/StaticLayout: maxLineHeight should not be -1. maxLines:2 lineCount:2 W/StaticLayout: maxLineHeight should not be -1. maxLines:2 lineCount:2 W/StaticLayout: maxLineHeight should not be -1. maxLines:2 lineCount:2 W/StaticLayout: maxLineHeight should not be -1. maxLines:2 lineCount:2 D/ScrollView: onsize change changed I/com.le.staffdn: CollectorTransition concurrent copying GC freed 18126(968KB) AllocSpace objects, 0(0B) LOS objects, 69% free, 2MB/8MB, paused 246us total 119.823ms E/chromium: [ERROR:aw_gl_functor.cc(102)] Received unexpected kModeProcessNoContext E/libEGL: call to OpenGL ES API with no current context (logged once per thread) D/Dialog: mIsSamsungBasicInteraction = false D/Dialog: mIsSamsungBasicInteraction = false, isMetaDataInActivity = false I/DecorView: createDecorCaptionView >> DecorView@6b455de[], isFloating: true, isApplication: true, hasWindowDecorCaption: false, hasWindowControllerCallback: false D/ScrollView: initGoToTop D/ScrollView: initGoToTop D/InputTransport: Input channel constructed: fd=81 D/ViewRootImpl@52bef24[ScanActivity]: setView = DecorView@6b455de[ScanActivity] TM=true MM=false D/ViewRootImpl@52bef24[ScanActivity]: dispatchAttachedToWindow D/ViewRootImpl@52bef24[ScanActivity]: Relayout returned: old=[0,72][1080,2076] new=[540,1038][540,1038] result=0x1 surface={valid=false 0} changed=false W/StaticLayout: maxLineHeight should not be -1. maxLines:2 lineCount:2 I/chatty: uid=10319(com.le.staffdna) identical 3 lines W/StaticLayout: maxLineHeight should not be -1. maxLines:2 lineCount:2 D/ScrollView: onsize change changed D/ViewRootImpl@52bef24[ScanActivity]: Relayout returned: old=[540,1038][540,1038] new=[27,1038][1053,1038] result=0x7 surface={valid=true 514106040320} changed=true I/OpenGLRenderer: Initialized EGL, version 1.4 D/OpenGLRenderer: Swap behavior 2 D/mali_winsys: EGLint new_window_surface(egl_winsys_display , void , EGLSurface, EGLConfig, egl_winsys_surface , EGLBoolean) returns 0x3000 D/OpenGLRenderer: eglCreateWindowSurface = 0x77d62b0e00, 0x77b31ba010 D/ViewRootImpl@291ff71[ScanActivity]: Relayout returned: old=[0,0][1080,2220] new=[0,0][1080,2220] result=0x1 surface={valid=false 0} changed=false D/ViewRootImpl@563e463[ScanActivity]: Relayout returned: old=[540,1038][540,1038] new=[27,1038][1053,1038] result=0x7 surface={valid=true 514109263872} changed=true D/mali_winsys: EGLint new_window_surface(egl_winsys_display , void , EGLSurface, EGLConfig, egl_winsys_surface , EGLBoolean) returns 0x3000 D/OpenGLRenderer: eglCreateWindowSurface = 0x77cf696180, 0x77b34cd010 D/: onActivityResult-1 W/ExifInterface: Skip the tag entry since tag number is not defined: 2 Stop reading file since a wrong offset may cause an infinite loop: 0 I/chatty: uid=10319(com.le.staffdna) identical 1 line W/ExifInterface: Stop reading file since a wrong offset may cause an infinite loop: 0 D/ViewRootImpl@52bef24[ScanActivity]: setWindowStopped(false) old=false D/ViewRootImpl@563e463[ScanActivity]: setWindowStopped(false) old=false D/ViewRootImpl@291ff71[ScanActivity]: setWindowStopped(false) old=true D/ViewRootImpl@52bef24[ScanActivity]: setWindowStopped(false) old=false D/ViewRootImpl@563e463[ScanActivity]: setWindowStopped(false) old=false D/ViewRootImpl@291ff71[ScanActivity]: setWindowStopped(false) old=false D/ViewRootImpl@52bef24[ScanActivity]: Relayout returned: old=[27,1038][1053,1038] new=[27,1038][1053,1038] result=0x3 surface={valid=true 514106040320} changed=false W/libEGL: EGLNativeWindowType 0x77b31ba010 disconnect failed D/OpenGLRenderer: eglDestroySurface = 0x77d62b0e00, 0x77b31ba000 D/mali_winsys: EGLint new_window_surface(egl_winsys_display , void , EGLSurface, EGLConfig, egl_winsys_surface , EGLBoolean) returns 0x3000 D/OpenGLRenderer: eglCreateWindowSurface = 0x77d62b0e00, 0x77b31ba010 D/ViewRootImpl@563e463[ScanActivity]: Relayout returned: old=[27,1038][1053,1038] new=[27,1038][1053,1038] result=0x3 surface={valid=true 514109263872} changed=false W/libEGL: EGLNativeWindowType 0x77b34cd010 disconnect failed D/OpenGLRenderer: eglDestroySurface = 0x77cf696180, 0x77b34cd000 D/mali_winsys: EGLint new_window_surface(egl_winsys_display , void , EGLSurface, EGLConfig, egl_winsys_surface , EGLBoolean) returns 0x3000 D/OpenGLRenderer: eglCreateWindowSurface = 0x77cf696180, 0x77b34cd010 D/ViewRootImpl@291ff71[ScanActivity]: Relayout returned: old=[0,0][1080,2220] new=[0,0][1080,2220] result=0x7 surface={valid=true 514150223872} changed=true D/mali_winsys: EGLint new_window_surface(egl_winsys_display , void , EGLSurface, EGLConfig, egl_winsys_surface , EGLBoolean) returns 0x3000 D/OpenGLRenderer: eglCreateWindowSurface = 0x77b31aa900, 0x77b5bdd010 D/ViewRootImpl@52bef24[ScanActivity]: MSG_RESIZED: frame=Rect(27, 1038 - 1053, 1038) ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1 MSG_WINDOW_FOCUS_CHANGED 1 1 D/ViewRootImpl@563e463[ScanActivity]: MSG_RESIZED: frame=Rect(27, 1038 - 1053, 1038) ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1 V/Scanning: Scaning getPoints V/Scanning: Scaning size() 0 I/OpenGLRenderer: Davey! duration=734ms; Flags=0, IntendedVsync=117256377049105, Vsync=117256860382419, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=117256866397465, AnimationStart=117256866489273, PerformTraversalsStart=117256866821042, DrawStart=117256871391465, SyncQueued=117256875636042, SyncStart=117256875843542, IssueDrawCommandsStart=117256883781273, SwapBuffers=117257107965503, FrameCompleted=117257112239849, DequeueBufferDuration=3110000, QueueBufferDuration=1113000, D/ViewRootImpl@52bef24[ScanActivity]: Relayout returned: old=[27,1038][1053,1038] new=[27,763][1053,1313] result=0x21 surface={valid=true 514106040320} changed=false W/libEGL: EGLNativeWindowType 0x77b31ba010 disconnect failed D/OpenGLRenderer: eglDestroySurface = 0x77d62b0e00, 0x77b31ba000 D/mali_winsys: EGLint new_window_surface(egl_winsys_display , void , EGLSurface, EGLConfig, egl_winsys_surface , EGLBoolean) returns 0x3000 D/OpenGLRenderer: eglCreateWindowSurface = 0x77d62b0e00, 0x77b31ba010 D/ScrollView: onsize change changed I/OpenGLRenderer: Davey! duration=935ms; Flags=1, IntendedVsync=117256377049105, Vsync=117256860382419, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=117256866397465, AnimationStart=117256866489273, PerformTraversalsStart=117256866821042, DrawStart=117257268832580, SyncQueued=117257280458849, SyncStart=117257280789195, IssueDrawCommandsStart=117257280958234, SwapBuffers=117257310770311, FrameCompleted=117257312608311, DequeueBufferDuration=1790000, QueueBufferDuration=714000, D/ViewRootImpl@563e463[ScanActivity]: Relayout returned: old=[27,1038][1053,1038] new=[27,763][1053,1313] result=0x21 surface={valid=true 514109263872} changed=false W/libEGL: EGLNativeWindowType 0x77b34cd010 disconnect failed D/OpenGLRenderer: eglDestroySurface = 0x77cf696180, 0x77b34cd000 D/mali_winsys: EGLint new_window_surface(egl_winsys_display , void , EGLSurface, EGLConfig, egl_winsys_surface , EGLBoolean) returns 0x3000 D/OpenGLRenderer: eglCreateWindowSurface = 0x77cf696180, 0x77b34cd010 D/ScrollView: onsize change changed I/OpenGLRenderer: Davey! duration=1014ms; Flags=1, IntendedVsync=117256377049105, Vsync=117256860382419, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=117256866397465, AnimationStart=117256866489273, PerformTraversalsStart=117256866821042, DrawStart=117257375724657, SyncQueued=117257383572772, SyncStart=117257383774118, IssueDrawCommandsStart=117257383919388, SwapBuffers=117257388411003, FrameCompleted=117257391909926, DequeueBufferDuration=1590000, QueueBufferDuration=1461000, I/Choreographer: Skipped 31 frames! The application may be doing too much work on its main thread. D/ViewRootImpl@52bef24[ScanActivity]: MSG_RESIZED: frame=Rect(27, 763 - 1053, 1313) ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1 D/ViewRootImpl@563e463[ScanActivity]: MSG_RESIZED: frame=Rect(27, 763 - 1053, 1313) ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1 D/Capacitor: Handling local request: http://localhost/assets/icon/favicon.png D/Capacitor: Handling local request: http://localhost/assets/header-bg.svg D/Capacitor: Handling local request: http://localhost/assets/icon/favicon.png D/Capacitor: Handling local request: http://localhost/assets/icon/favicon.png

ndev10 commented 4 years ago

Also observed the issue on SAMSUNG GALAXY S8 WITH ANDORID 9.

SAMSUNG_GALXY

ChrisTomAlx commented 4 years ago

Hey @ndev10

Thanks for sharing the stack trace but I don't seem to see an error logged here.. Make sure the errors are being logged and copy the stack trace only after the app crashes so as to capture the final error causing app to crash

Cheers and have a nice day :) Chris Neutrinos

vishnupriyads commented 4 years ago

Hey @ChrisTomAlx

The same issue i am facing only in android 10 it is crashing. Other versions of android it is working. Please do the needful

prasanth003 commented 4 years ago

@ChrisTomAlx

we are using this plugin for OCR. This plugin is worked in my previous version of android. After upgrading to android 10, i am not able to do document scanning. the app automatically closing. My Mobile Modal is REDMI K20

ChrisTomAlx commented 4 years ago

Hey @prasanth003 and @vishnupriyads

Please share error logs from android studio. I don't have an android 10 phone currently to test this.

Cheers and have a nice day :) Chris Neutrinos

wimZ commented 4 years ago

I have the same issue. When using sourceType: Camera, returnBase64: true, the symptoms are as described above; no error is thrown, the app continues without calling success or error function. When using sourceType: File, returnBase64: true; result is the same, but I do see the cropped image in a file.
I have no idea how to fix or debug a plugin, so rely on you for this. As Android 10 starts to roll onto Samsung now, I appreciate your support.

If necessary, I can assist if I know how.

Hope this can be fixed Kind regards, WIm

ChrisTomAlx commented 4 years ago

This issue has now been fixed in plugin version 4.2.5 Sorry about the delay This is what was causing the issue.. On the 33rd build the bitmap insertImage function used to fail/

Cheers and stay safe :) Chris Neutrinos

wimZ commented 4 years ago

I just upgraded my project to version 4.2.5. Unluckily the Low memory error still occurs on each scan.

atebsy commented 4 years ago

Hi @ChrisTomAlx ,

the issue on Android 10 is still persisting, this only happens when the sourceType is set to 1, once the scanner is open I can't go back to the app the camera hangs there, event without taking a picture and after eventually pressing the back button multiple times it goes back to the home page. And I have noticed that in the version 2.23 this works but intermittently (Sometimes it does and sometimes it does not) but on Version 2.25 it doesn't work at all it hangs all the time here is the android studio log:

2020-06-26 14:33:47.823 13481-13612/ W/PluginManager: THREAD WARNING: exec() call to Scan.scanDoc blocked the main thread for 62ms. Plugin should use CordovaInterface.getThreadPool(). 2020-06-26 14:33:47.826 13481-13481/ D/CordovaActivity: Paused the activity. 2020-06-26 14:33:47.850 13481-13481/ W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@76ebd26 2020-06-26 14:33:47.930 13481-13481/ V/ActivityThread: callActivityOnCreate 2020-06-26 14:33:48.001 13481-13481/ W/WindowDecorActionBar: should not do the transition or the transition anim is null or it is running or the mContainer view is null or mContainer view hasn't been drawn to screen 2020-06-26 14:33:48.012 13481-13481/ D/HwGalleryCacheManagerImpl: mIsEffect:false 2020-06-26 14:33:48.207 13481-13481/ D/ActivityThread: add activity client record, r= ActivityRecord{c88dec8 token=android.os.BinderProxy@76ebd26 {/com.scanlibrary.ScanActivity}} token= android.os.BinderProxy@76ebd26 2020-06-26 14:33:48.321 13481-14251/ D/HiTouch_PressGestureDetector: onAttached, package=, windowType=1, mHiTouchRestricted=false 2020-06-26 14:33:48.357 13481-13519/ D/mali_winsys: EGLint new_window_surface(egl_winsys_display , void , EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000 2020-06-26 14:33:48.744 13481-13519/ W/libEGL: EGLNativeWindowType 0x763fdd5dd0 disconnect failed 2020-06-26 14:33:48.991 13481-13519/ W/libEGL: EGLNativeWindowType 0x76bd1e1950 disconnect failed

macsupport commented 4 years ago

I have the same issue. When using sourceType: 1, returnBase64: true. Error is: incorrect result or user cancelled the action.