EddyVerbruggen / nativescript-plugin-firebase

:fire: NativeScript plugin for Firebase
https://firebase.google.com
MIT License
1.01k stars 441 forks source link

onPreviewFrame MLKitImageLabeling error on Android #1192

Open FranciZ opened 5 years ago

FranciZ commented 5 years ago

Occasionally the MLKitImageLabeling camera will fail with the below exception. I think it loses reference to the JavaScript method.

System.err: com.tns.NativeScriptException: 
System.err: Calling js method onPreviewFrame failed
System.err: 
System.err: Error: Cannot convert object to Lcom/google/android/gms/tasks/OnFailureListener; at index 0
System.err: File: "file:///data/data/app.loco/files/app/tns_modules/nativescript-plugin-firebase/mlkit/mlkit-cameraview.js, line: 168, column: 29
System.err: 
System.err: StackTrace: 
System.err:     Frame: function:'onPreviewFrame', file:'file:///data/data/app.loco/files/app/tns_modules/nativescript-plugin-firebase/mlkit/mlkit-cameraview.js', line: 168, column: 30
System.err: 
System.err:     at com.tns.Runtime.callJSMethodNative(Native Method)
System.err:     at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1120)
System.err:     at com.tns.Runtime.callJSMethodImpl(Runtime.java:1000)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:987)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:967)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:959)
System.err:     at com.tns.gen.android.hardware.Camera_PreviewCallback.onPreviewFrame(Camera_PreviewCallback.java:17)
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:6718)
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)
FranciZ commented 5 years ago

When putting the phone to and out of sleep I also sometimes start getting the below exception.

System.err: com.tns.NativeScriptException: Attempt to use cleared object reference id=45414
System.err:     at com.tns.Runtime.getJavaObjectByID(Runtime.java:923)
System.err:     at com.tns.Runtime.callJSMethodNative(Native Method)
System.err:     at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1120)
System.err:     at com.tns.Runtime.callJSMethodImpl(Runtime.java:1000)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:987)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:967)
System.err:     at com.tns.Runtime.callJSMethod(Runtime.java:959)
System.err:     at com.tns.gen.android.hardware.Camera_PreviewCallback.onPreviewFrame(Camera_PreviewCallback.java:17)
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:6718)
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)
EddyVerbruggen commented 5 years ago

Can you share the code that triggers these?