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

CameraMLVision close event stream exception #9

Closed
lewixlabs opened this issue Apr 16, 2019 · 6 comments · Fixed by #32
Closed

CameraMLVision close event stream exception #9

lewixlabs opened this issue Apr 16, 2019 · 6 comments · Fixed by #32
Assignees
Labels
bug Something isn't working

Comments

@lewixlabs
Copy link

Hi,
probably I'm doing something wrong.
CameraMLVision is set dinamically by a generic widget, calling setState

Widget _activeWidget = CameraMlVision<VisionText>(
        detector: FirebaseVision.instance.textRecognizer().processImage,
        onResult: (VisionText visionTextResult) {
          //print("******* visionText => ${visionTextResult.text}");
          if (!_isScanning && visionTextResult.text.length > 0) {
            var priceDetected = _regexCapturePrice(visionTextResult.text);
            if (priceDetected != null) {
              setState(() {
                _activeWidget = _priceResultView(priceDetected);
              });
            }
          }
        });

As you can see in this code, when result are returned, _activeWidget becomes a report widget with details.

Doing this, I get this exception:

E/EventChannel#plugins.flutter.io/camera/imageStream(26834): Failed to close event stream
E/EventChannel#plugins.flutter.io/camera/imageStream(26834): java.lang.NullPointerException: Attempt to invoke virtual method 'void android.media.ImageReader.setOnImageAvailableListener(android.media.ImageReader$OnImageAvailableListener, android.os.Handler)' on a null object reference
E/EventChannel#plugins.flutter.io/camera/imageStream(26834): at io.flutter.plugins.camera.CameraHandler$Camera$9.onCancel(CameraHandler.java:827)
E/EventChannel#plugins.flutter.io/camera/imageStream(26834): at io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler.onCancel(EventChannel.java:194)
E/EventChannel#plugins.flutter.io/camera/imageStream(26834): at io.flutter.plugin.common.EventChannel$IncomingStreamRequestHandler.onMessage(EventChannel.java:162)
E/EventChannel#plugins.flutter.io/camera/imageStream(26834): at io.flutter.view.FlutterNativeView$PlatformMessageHandlerImpl.handleMessageFromDart(FlutterNativeView.java:188)
E/EventChannel#plugins.flutter.io/camera/imageStream(26834): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:202)
E/EventChannel#plugins.flutter.io/camera/imageStream(26834): at android.os.MessageQueue.nativePollOnce(Native Method)
E/EventChannel#plugins.flutter.io/camera/imageStream(26834): at android.os.MessageQueue.next(MessageQueue.java:323)
E/EventChannel#plugins.flutter.io/camera/imageStream(26834): at android.os.Looper.loop(Looper.java:143)
E/EventChannel#plugins.flutter.io/camera/imageStream(26834): at android.app.ActivityThread.main(ActivityThread.java:7225)
E/EventChannel#plugins.flutter.io/camera/imageStream(26834): at java.lang.reflect.Method.invoke(Native Method)
E/EventChannel#plugins.flutter.io/camera/imageStream(26834): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
E/EventChannel#plugins.flutter.io/camera/imageStream(26834): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)

I attached
log.txt
full log, if you need.

Is there a graceful way to close CameraVision widget?
Or valid way is calling
Navigator.of(context).pop...
like in your sample?

Thank you again for your help.
Lewix

@Kleak
Copy link
Contributor

Kleak commented Apr 16, 2019

Navigator.of(context).pop(); should do everything for you.
If you push a new route the plugin will automatically pause itself

@jaumard
Copy link
Collaborator

jaumard commented Apr 16, 2019

hi @lewixlabs thanks for the report ! Are you able to reproduce this with the example app ? Would be nice if you can provide us sample to reproduce it if you don't. Because here you error is native, and we didn't do any native parts on this plugin ^^ so my guess here is that the camera plugin is crashing, but no idea why

@lewixlabs
Copy link
Author

@Kleak @jaumard thanks for your fast replies :)
As first thing I will change my pattern to use
Navigator.of(context).pop()
as suggested.
Changing dinamically a cameravision widget maybe is an unhandled way and native camera is not closed correctly.
After that, if I will encounter again this issue, I will report it.

Thanks!

@jaumard
Copy link
Collaborator

jaumard commented Apr 17, 2019

Any news @lewixlabs ? :)

@lewixlabs
Copy link
Author

Hi @jaumard ,
yes I was testing in different ways.

To avoid any doubt, I tested your official example in this repository, using also Android Studio (I usually
work with VSCode) but exception
setOnImageAvailableListener
happens again.
Only one difference I applied, is changing package name in android app to make it valid for my google mlkit json config file.

I attached Android Studio screenshot
image
The issue seems not blocking, app doesn't crash & I can scan further barcodes.
The issue happened on my Galaxy S8 with Android 9 & Galaxy Note 3.
If you need more infos let me know.

Lewix

@Kleak Kleak added the bug Something isn't working label May 5, 2019
@Kleak Kleak added this to To do in Camera Ml Vision via automation May 5, 2019
@Kleak Kleak self-assigned this May 5, 2019
@Kleak Kleak moved this from To do to In progress in Camera Ml Vision May 5, 2019
@Kleak Kleak closed this as completed in #32 May 5, 2019
Camera Ml Vision automation moved this from In progress to Done May 5, 2019
@Kleak
Copy link
Contributor

Kleak commented May 5, 2019

fixed in 2.0.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

Successfully merging a pull request may close this issue.

3 participants