Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Barcode scanner crashes on Android with live video activated #1630

Open
cjohn001 opened this issue Jul 1, 2020 · 5 comments
Open

Barcode scanner crashes on Android with live video activated #1630

cjohn001 opened this issue Jul 1, 2020 · 5 comments

Comments

@cjohn001
Copy link

cjohn001 commented Jul 1, 2020

Hello together,
I am trying to use the Barcode scanner with live video capture. On IOS the barcode scanner is running as expected. On an android device (Android 8.0) and also on an emulator (Android 9.0) the scanner fails with the same error:

Stacktrace from device:

System.err: An uncaught Exception occurred on "main" thread.
System.err: Calling js method onPreviewFrame failed
System.err: TypeError: Cannot read property 'firebase' of undefined
System.err: 
System.err: StackTrace:
System.err: push.../node_modules/nativescript-plugin-firebase/mlkit/barcodescanning/index.js.MLKitBarcodeScanner.preProcessImage(file: node_modules/nativescript-plugin-firebase/mlkit/barcodescanning/index.android.js:97:0)
System.err:     at onPreviewFrame(file: node_modules/nativescript-plugin-firebase/mlkit/mlkit-cameraview.android.js:168:0)
System.err:     at com.tns.Runtime.callJSMethodNative(Native Method)
System.err:     at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1286)
System.err:     at com.tns.Runtime.callJSMethodImpl(Runtime.java:1173)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1160)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1138)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1134)
System.err:     at com.tns.gen.android.hardware.Camera_PreviewCallback.onPreviewFrame(Camera_PreviewCallback.java:20)
System.err:     at android.hardware.Camera$EventHandler.handleMessage(Camera.java:1124)
System.err:     at android.os.Handler.dispatchMessage(Handler.java:105)
System.err:     at android.os.Looper.loop(Looper.java:164)
System.err:     at android.app.ActivityThread.main(ActivityThread.java:6944)
System.err:     at java.lang.reflect.Method.invoke(Native Method)
System.err:     at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

Stacktrace from Emulator:

System.err: An uncaught Exception occurred on "main" thread.
System.err: Calling js method onPreviewFrame failed
System.err: TypeError: Cannot read property 'firebase' of undefined
System.err: 
System.err: StackTrace:
System.err: push.../node_modules/nativescript-plugin-firebase/mlkit/barcodescanning/index.js.MLKitBarcodeScanner.preProcessImage(file: node_modules/nativescript-plugin-firebase/mlkit/barcodescanning/index.android.js:97:0)
System.err:     at onPreviewFrame(file: node_modules/nativescript-plugin-firebase/mlkit/mlkit-cameraview.android.js:168:0)
System.err:     at com.tns.Runtime.callJSMethodNative(Native Method)
System.err:     at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1286)
System.err:     at com.tns.Runtime.callJSMethodImpl(Runtime.java:1173)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1160)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1138)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:1134)
System.err:     at com.tns.gen.android.hardware.Camera_PreviewCallback.onPreviewFrame(Camera_PreviewCallback.java:20)
System.err:     at android.hardware.Camera$EventHandler.handleMessage(Camera.java:1209)
System.err:     at android.os.Handler.dispatchMessage(Handler.java:106)
System.err:     at android.os.Looper.loop(Looper.java:193)
System.err:     at android.app.ActivityThread.main(ActivityThread.java:6669)
System.err:     at java.lang.reflect.Method.invoke(Native Method)
System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

Has someone an idea what is going wrong here or how I can work arround the issue? Thanks for your help.

@SudhakarPunniyakotti
Copy link

Same error
System.err: An uncaught Exception occurred on "main" thread.
System.err: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: Error calling module function
System.err: TypeError: Cannot read property 'tasks' of undefined
System.err: File: (file:///node_modules/nativescript-plugin-firebase/mlkit/barcodescanning/index.js:7:0)
System.err:

My versions

"tns-android": {
"version": "6.2.0"
}
and "nativescript-plugin-firebase": "^10.5.2",

Any help will be highly appreciated, thank you ...

@cjohn001
Copy link
Author

cjohn001 commented Sep 5, 2020

@sudhakar,
Hello, it seems like the error is related to the android simulator which provides a kind of virtual camera in which you can setup a virtual scene to capture an image. The first time this simulation is loaded there seems to not exist an image preset. This seems to be responsible for the crash. Maybe use a different app to once start the simulation, The issue stopped appearing to me after this even if I am using new simulator images.

Best regards,
Christoph

@zalesak
Copy link

zalesak commented Apr 19, 2021

As a quick workaround drop support for inverse code scanning.
<MLKitBarcodeScanner ... supportInverseBarcodes="false" ...

@zalesak
Copy link

zalesak commented Apr 19, 2021

@EddyVerbruggen can you help here? It seems that call for java function doesn`t work..

@zalesak
Copy link

zalesak commented Apr 20, 2021

So gyus, i found it out.

Just rename

node_modules@nativescript\firebase\platforms\android\nativescript-firebase-mlkit-helper.jar-disabled

to

node_modules@nativescript\firebase\platforms\android\nativescript-firebase-mlkit-helper.jar

I`ll create PR to solve this.

zalesak added a commit to zalesak/nativescript-plugin-firebase that referenced this issue Apr 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants