AmolGangadhare / flutter_barcode_scanner

Barcode scanner plugin for flutter. Supports barcode scanning for Android and iOS
https://pub.dev/packages/flutter_barcode_scanner
MIT License
380 stars 499 forks source link

Android only: Camera window black - then crash on tap #153

Open herrmayr opened 3 years ago

herrmayr commented 3 years ago

Describe the bug When invoking FlutterBarcodeScanner.scanBarcode("7DCD85", "cancel", false, ScanMode.QR); the app only shows a black screen with no content from the camera. I can press the "back" button, which safely returns to the last screen without crashing.

The log at that time reads

> W/samlms.sesamlm( 4266): Accessing hidden method Lsun/misc/Unsafe;->getUnsafe()Lsun/misc/Unsafe; (greylist,core-platform-api, linking, allowed)
W/samlms.sesamlm( 4266): Accessing hidden method Lsun/misc/Unsafe;->objectFieldOffset(Ljava/lang/reflect/Field;)J (greylist,core-platform-api, linking, allowed)
W/samlms.sesamlm( 4266): Accessing hidden method Lsun/misc/Unsafe;->compareAndSwapObject(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z (greylist, linking, allowed)
W/samlms.sesamlm( 4266): Accessing hidden method Lsun/misc/Unsafe;->putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed)
I/flutter ( 4266): Start scanning code ...
I/Timeline( 4266): Timeline: Activity_launch_request time:1202947
W/ActivityThread( 4266): SCHED: de.herrmayr.sesamlms.sesamlms/.MainActivity [75, r=189ms, a=61ms, w=5197ms]
W/ActivityThread( 4266): handleWindowVisibility: no activity for token android.os.BinderProxy@6e7ab85
D/ForceDarkHelper( 4266): updateByCheckExcludeList: pkg: de.herrmayr.sesamlms.sesamlms activity: com.amolg.flutterbarcodescanner.BarcodeCaptureActivity@4fc7b01
I/chatty  ( 4266): uid=10129(de.herrmayr.sesamlms.sesamlms) identical 3 lines
D/ForceDarkHelper( 4266): updateByCheckExcludeList: pkg: de.herrmayr.sesamlms.sesamlms activity: com.amolg.flutterbarcodescanner.BarcodeCaptureActivity@4fc7b01
W/samlms.sesamlm( 4266): Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (greylist, reflection, allowed)
W/samlms.sesamlm( 4266): Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (greylist, reflection, allowed)
D/ForceDarkHelper( 4266): updateByCheckExcludeList: pkg: de.herrmayr.sesamlms.sesamlms activity: com.amolg.flutterbarcodescanner.BarcodeCaptureActivity@4fc7b01
I/chatty  ( 4266): uid=10129(de.herrmayr.sesamlms.sesamlms) identical 2 lines
D/ForceDarkHelper( 4266): updateByCheckExcludeList: pkg: de.herrmayr.sesamlms.sesamlms activity: com.amolg.flutterbarcodescanner.BarcodeCaptureActivity@4fc7b01

When I tap anywhere in the blank/black area while in "scan mode", the app crashes, referencing some NullPointerExceptions.

Log:

> E/AndroidRuntime( 1808):  at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4963)
E/AndroidRuntime( 1808):    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4936)
E/AndroidRuntime( 1808):    at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:7688)
E/AndroidRuntime( 1808):    at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:7657)
E/AndroidRuntime( 1808):    at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:7618)
E/AndroidRuntime( 1808):    at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:7816)
E/AndroidRuntime( 1808):    at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:251)
E/AndroidRuntime( 1808):    at android.os.MessageQueue.nativePollOnce(Native Method)
E/AndroidRuntime( 1808):    at android.os.MessageQueue.next(MessageQueue.java:336)
E/AndroidRuntime( 1808):    at android.os.Looper.loop(Looper.java:181)
E/AndroidRuntime( 1808):    at android.app.ActivityThread.main(ActivityThread.java:7590)
E/AndroidRuntime( 1808):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 1808):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
E/AndroidRuntime( 1808):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
I/Process ( 1808): Sending signal. PID: 1808 SIG: 9
Lost connection to device.
Exited (sigterm)

To Reproduce Steps to reproduce the behavior: Consistently on Android, but no on iOS

gabrielgarciagava commented 3 years ago

I'm facing the exact same issue. And if I hit the back button, it responds with -1.

nsilvah commented 3 years ago

I have the same problem.

nsilvah commented 3 years ago

I found the fix. The app was crashing because the color parameter I was using was "ffffff" instead of "#ffffff".

fedser commented 3 years ago

I found the fix. The app was crashing because the color parameter I was using was "ffffff" instead of "#ffffff".

Thanks! It's also solved my problem too (was wrong text color format).