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

Plugin crashes Android app when switching between apps #3

Closed
ghunter99 opened this issue Jul 25, 2018 · 65 comments
Closed

Plugin crashes Android app when switching between apps #3

ghunter99 opened this issue Jul 25, 2018 · 65 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@ghunter99
Copy link

Thanks for adding the ability to scan different barcodes.
Works brilliantly!
I've run into a bug that I hope us easy reproduce.

  1. Everything works perfectly on iOS
  2. On Android scanning works but when I tap on the overview button to switch apps
    (that's the button on the bottom on the right side) the example program crashes with the
    following error:

F/libc (28681): Fatal signal 11 (SIGSEGV), code 1, fault addr 0x26780000 in tid 29800 (FirebaseMLHandl)


I get a similar error when using the Android emulator:

F/libc (14291): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xabb36d70 in tid 14373 (FirebaseMLHandl), pid 14291 (yris.eddflutter)

Let me know if I can be of any assistance!

@facundomedica
Copy link
Owner

Thanks for the issue! I've got a couple of questions, because I'm not able to reproduce the bug.

  1. What are the characteristics and model of your device and emulator?
  2. What version of Flutter are you running?
  3. What is you host OS?

@facundomedica facundomedica added bug Something isn't working help wanted Extra attention is needed labels Jul 25, 2018
@ghunter99
Copy link
Author

Hi
Thanks for checking this out.
Hoping it's a configuration issue on my end but after some more testing I still get the same crash
when I switch apps.

Here' s my Flutter doctor output:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v0.5.1, on Mac OS X 10.13.6 17G65, locale en-AU)
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 9.4.1)
[✓] Android Studio (version 3.1)
[✓] Connected devices (2 available)

• No issues found!


I'm using a standard emulator (I think) Nexus 5X API P
Name: Nexus_5X_API_P
CPU/ABI: Google Play Intel Atom (x86)
Path: /Users/garyhunter/.android/avd/Nexus_5X_API_P.avd
Target: google_apis_playstore [Google Play] (API level P)
Skin: nexus_5x
SD Card: 100M
hw.dPad: no
hw.lcd.height: 1920
runtime.network.speed: full
hw.accelerometer: yes
hw.device.name: Nexus 5X
vm.heapSize: 256
skin.dynamic: yes
hw.device.manufacturer: Google
hw.lcd.width: 1080
image.androidVersion.codename: P
hw.gps: yes
hw.initialOrientation: Portrait
image.androidVersion.api: 27
hw.audioInput: yes
image.sysdir.1: system-images/android-P/google_apis_playstore/x86/
tag.id: google_apis_playstore
showDeviceFrame: yes
hw.camera.back: virtualscene
hw.mainKeys: no
AvdId: Nexus_5X_API_P
hw.camera.front: emulated
hw.lcd.density: 420
avd.ini.displayname: Nexus 5X API P
hw.arc: false
hw.gpu.mode: auto
hw.device.hash2: MD5:bc5032b2a871da511332401af3ac6bb0
hw.ramSize: 1536
hw.trackBall: no
PlayStore.enabled: true
fastboot.forceColdBoot: no
hw.battery: yes
hw.cpu.ncore: 2
hw.sdCard: yes
tag.display: Google Play
runtime.network.latency: none
hw.keyboard: yes
hw.sensors.proximity: yes
disk.dataPartition.size: 2G
hw.sensors.orientation: yes
avd.ini.encoding: UTF-8
hw.gpu.enabled: yes


The phone I test on is a Motorola G5S Plus running Android 7.1.1


Here's the output for the error when I run the test app on my device

Launching lib/main.dart on Moto G 5S Plus in debug mode...
Initializing gradle...
Resolving dependencies...
Running 'gradlew assembleDebug'...
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection)
Built build/app/outputs/apk/debug/app-debug.apk.
I/FlutterActivityDelegate(23634): onResume setting current activity to this
Syncing files to device Moto G 5S Plus...
W/DynamiteModule(23634): Local module descriptor class for com.google.android.gms.vision.dynamite.barcode not found.
I/DynamiteModule(23634): Considering local module com.google.android.gms.vision.dynamite.barcode:0 and remote module com.google.android.gms.vision.dynamite.barcode:0
D/BarcodeNativeHandle(23634): Cannot load feature, fall back to load whole module.
W/DynamiteModule(23634): Local module descriptor class for com.google.android.gms.vision.dynamite not found.
E/art (23634): The String#value field is not present on Android versions >= 6.0
I/DynamiteModule(23634): Considering local module com.google.android.gms.vision.dynamite:0 and remote module com.google.android.gms.vision.dynamite:1702
I/DynamiteModule(23634): Selected remote version of com.google.android.gms.vision.dynamite, version >= 1702
W/System (23634): ClassLoader referenced unknown path:
D/ApplicationLoaders(23634): ignored Vulkan layer search path /data/app/com.google.android.gms-1/lib/arm:/data/app/com.google.android.gms-1/base.apk!/lib/armeabi-v7a for namespace 0xadfaf090
D/ApplicationLoaders(23634): ignored Vulkan layer search path /data/app/com.google.android.gms-1/lib/arm:/data/app/com.google.android.gms-1/base.apk!/lib/armeabi-v7a for namespace 0xadfaf0d0
I/Vision (23634): Loading library libbarhopper.so
W/linker (23634): /data/data/com.google.android.gms/app_vision/barcode/libs/armeabi-v7a/libbarhopper.so: unused DT entry: type 0x7ffffffd arg 0x76d
I/Vision (23634): libbarhopper.so library load status: true
I/DynamiteModule(23634): Considering local module com.google.android.gms.flags:2 and remote module com.google.android.gms.flags:3
I/DynamiteModule(23634): Selected remote version of com.google.android.gms.flags, version >= 3
F/libc (23634): Fatal signal 11 (SIGSEGV), code 1, fault addr 0x6a3de000 in tid 23666 (FirebaseMLHandl)


Build fingerprint: 'motorola/sanders_n/sanders_n:7.1.1/NPSS26.116-61-11/18:user/release-keys'
Revision: 'p400'
ABI: 'arm'
pid: 23634, tid: 23666, name: FirebaseMLHandl >>> co.apperto.fastqrreaderviewexample <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x6a3de000
r0 00000000 r1 00000000 r2 000000ff r3 5d92dd80
r4 00000208 r5 00000000 r6 00000000 r7 6a3de000
r8 00000000 r9 6a3de000 sl 00000c30 fp 00001040
ip 00000000 sp 851fd798 lr 6a3de000 pc 8ecc9d8c cpsr 600b0030
backtrace:
#00 pc 00008d8c /data/data/com.google.android.gms/app_vision/barcode/libs/armeabi-v7a/libbarhopper.so
#1 pc 000043ad /data/data/com.google.android.gms/app_vision/barcode/libs/armeabi-v7a/libbarhopper.so
#2 pc 00001e63 /data/data/com.google.android.gms/app_vision/barcode/libs/armeabi-v7a/libbarhopper.so
#3 pc 000bb5a7 /data/user_de/0/com.google.android.gms/app_chimera/m/0000004c/oat/arm/DynamiteModulesA.odex (offset 0x11e000)
Lost connection to device.

@facundomedica
Copy link
Owner

facundomedica commented Jul 26, 2018

I'm having a hard time at figuring this out, so I hope you have patience 😅 .

It would be nice if you could try on another physical device. I think that if it doesn't work on that phone then it may be because of some configuration on the gradle of the project. (It would be really really weird that it doesn't work on any of your devices)

Another thing I would try is making a new flutter project and import this library as a dependency following the instructions in the readme and test it with this:

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:fast_qr_reader_view/fast_qr_reader_view.dart';

List<CameraDescription> cameras;

Future<Null> main() async {
  cameras = await availableCameras();
  runApp(new CameraApp());
}

class CameraApp extends StatefulWidget {
  @override
  _CameraAppState createState() => new _CameraAppState();
}

class _CameraAppState extends State<CameraApp> {
  QRReaderController controller;

  @override
  void initState() {
    super.initState();
    controller = new QRReaderController(cameras[0], ResolutionPreset.medium, [CodeFormat.qr], (dynamic value){
        print(value); // the result!
    // ... do something
    // wait 3 seconds then start scanning again.
    new Future.delayed(const Duration(seconds: 3), controller.startScanning);
    });
    controller.initialize().then((_) {
      if (!mounted) {
        return;
      }
      setState(() {});
      controller.startScanning();
    });
  }

  @override
  void dispose() {
    controller?.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    if (!controller.value.isInitialized) {
      return new Container();
    }
    return new AspectRatio(
        aspectRatio:
        controller.value.aspectRatio,
        child: new QRReaderPreview(controller));
  }
}

Last resort: Could you try this project: https://github.com/firebase/quickstart-android/tree/master/mlkit ? If that one doesn't work, then we know is a MLkit error and we can ask them for help, if it does, then it's something wrong with this project or Flutter.

Last last resort: use a different computer to run the project

@ghunter99
Copy link
Author

Thanks.
There's not much you can do if you can't recreate the problem.
I'll go through the steps you suggest.

@dragosholban
Copy link
Contributor

Hello! Any news on this? I have the same problem, plugin works fine on iOS but crashes on Android device or keeps throwing exceptions on emulator:

I/flutter ( 4088): Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 3424 pos 12: '_debugLifecycleState != _ElementLifecycle.defunct': is not true.

@facundomedica
Copy link
Owner

@dragosholban Did you try what I said in my last comment? Also, can you provide:

  • Full logs
  • What are the characteristics and model of your device and emulator?
  • What version of Flutter are you running?
  • What is you host OS?

@dragosholban
Copy link
Contributor

@facundomedica I made a new Flutter project, installed the plugin as described in the docs, user the code you posted above and it still crashes :(

W/FastQrReaderViewPlugin(29824): onSuccess: asdfg
I/flutter (29824): asdfg
I/zygote64(29824): Do partial code cache collection, code=60KB, data=54KB
I/zygote64(29824): After code cache collection, code=60KB, data=54KB
I/zygote64(29824): Increasing code cache capacity to 256KB
I/CameraDevice-JV-0(29824): Camera now idle
F/libc    (29824): Fatal signal 11 (SIGSEGV), code 1, fault addr 0x7afd662000 in tid 29882 (FirebaseMLHandl), pid 29824 (entway.qrreader)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'HUAWEI/CLT-L29/HWCLT:8.1.0/HUAWEICLT-L29/131(C432):user/release-keys'
Revision: '0'
ABI: 'arm64'
pid: 29824, tid: 29882, name: FirebaseMLHandl  >>> io.eventway.qrreader <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x7afd662000
    x0   0000007afd076b00  x1   0000000000000000  x2   0000000000000000  x3   00000000000000ff
    x4   0000000000000000  x5   0000000000000000  x6   0000000000000000  x7   0000007afd662000
    x8   0000007afd662000  x9   0000000000000000  x10  0000000000000000  x11  0000007afd662000
    x12  0000007afd076b00  x13  aaaaaaaaaaaaaaab  x14  00000000000000d2  x15  0000007afd003770
    x16  0000007bd5bd42d0  x17  0000007bd5b717c8  x18  0000000000000008  x19  00000000000001c8
    x20  0000000000000156  x21  0000000000000e40  x22  0000000000000ab0  x23  0000007afd076b00
    x24  0000007afd662000  x25  0000000000000000  x26  0000000000000ab0  x27  0000000000000004
    x28  0000007b1d376260  x29  0000007b1d376a48  x30  0000007b07e6dde8
    sp   0000007b1d376110  pc   0000007b07e6de18  pstate 0000000060000000
backtrace:
    #00 pc 000000000000ee18  /data/data/com.google.android.gms/app_vision/barcode/libs/arm64-v8a/libbarhopper.so
    #01 pc 000000000000762c  /data/data/com.google.android.gms/app_vision/barcode/libs/arm64-v8a/libbarhopper.so
    #02 pc 0000000000003624  /data/data/com.google.android.gms/app_vision/barcode/libs/arm64-v8a/libbarhopper.so
    #03 pc 0000000000000b08  /data/user_de/0/com.google.android.gms/app_chimera/m/00000009/oat/arm64/DynamiteModulesA.odex (offset 0x6000)
Lost connection to device.

@dragosholban
Copy link
Contributor

I'm testing on a Huawei P20 Pro. I also tested the camera plugin you based your code on, but that works fine, with no issues. So I guess it's something in this project that goes wrong when the activity pauses and the camera stops...

@facundomedica
Copy link
Owner

Ok, I think I might have a clue, the problem seems to be here: https://github.com/facundomedica/fast_qr_reader_view/blob/master/android/src/main/java/co/apperto/fastqrreaderview/FastQrReaderViewPlugin.java#L95-L146

I'll compare it side to side with how it's done in MLKit, because I might have missed a method. I will take a look in a couple of hours but feel free to take a look for yourself and report any findings. Take special care with onPause and onResume. Hopefully we get this solved by today

@dragosholban
Copy link
Contributor

@facundomedica did you find anything yet?

@facundomedica
Copy link
Owner

@dragosholban I haven't been able to replicate the issue on the devices I have available (BLU Vivo 8 and a Samsung Galaxy S4 mini) so I can switch between apps and it never crashes 🤦‍♂️ . I will try with different emulators until I get the error.

@dragosholban
Copy link
Contributor

This is very strange, I tested on a Nexus 5X and it crashed too. I will test on a Samsung Galaxy S4 mini.

I also started to investigate, it seems the crash happens on dispose, I guess the firebase reader is still connected and tries to read the images when the camera shuts down. I haven't found the exact place, but it's somewhere around this.

@dragosholban
Copy link
Contributor

Unfortunately I am not able to run on Samsung Galaxy S4 mini, I get the following error:

Installing build/app/outputs/apk/app.apk...
Package install error: Failure [INSTALL_FAILED_OLDER_SDK]
Error launching application on GT I9195.

@facundomedica
Copy link
Owner

Oh yes, I forgot that I had updated the OS with a non-factory one, sorry about that

@dragosholban
Copy link
Contributor

Hi again! I created a new project just for testing this issue: https://github.com/dragosholban/flutter_qr_test

Maybe you can test it too, after you scan a QR Code, press back and the app will crash. I tried to find the problem, but I had no success. Please let me know if you can at least replicate the issue using this project. Thanks!

@ghunter99
Copy link
Author

Any luck recreating the problem? I'm sure you've got a day job and this stuff is pretty tricky. It does look like unloading / shutting down the camera is where the problem lies.

@facundomedica
Copy link
Owner

I got it to throw an exception with the project @dragosholban provided on a simulator, but it did not crash, it just threw this exception throw new QRReaderException( 'No scanning is happening', 'stopScanning was called when the scanner was not scanning.', );

I'll try to give this an entire day of debugging this week, if you find anything more please post it here, I'm having a hard time debugging this.

@dragosholban
Copy link
Contributor

@facundomedica please use a real device to test, not the simulator. It does not crash on the simulator. Use a real device, scan some codes and press back.

@facundomedica
Copy link
Owner

@dragosholban this might sound a bit weird, but can you give me the QR codes you are testing with? I tested on a physical device and sadly it works...

Anyway, as a final resort, I will set up another repo or branch with some "blind tests" with stuff changed that I suppose can fix the issue and you can tell me if they fix it for you or not. If you help me with this I'll list your names in a "collaborators" or "acknowledgments" file or something like that.

@dragosholban
Copy link
Contributor

@facundomedica this is crazy :( I scanned random codes generated here: https://www.the-qrcode-generator.com/

The this is that the app crashes even without scanning any codes. The crash happens when you "go back" to the previous screen, or when you try to switch to another app. It seems the camera stops but, somehow the MLKit is still processing images and crashes. I noticed that if I change the code to manually stop the scan, then, after a few seconds, I "go back" it does not crash anymore. It only happens when scanning is active.

@ghunter99
Copy link
Author

Hi @facundomedica & @dragosholban. I'm getting the same behaviour as @dragosholban. I'm testing on a Samsung S9 Android 8.0 & Motorola G5S Plus Android 7.1.1. The apps I'm building currently use Flutter Channel beta, v0.5.1. I made a Play Store internal release & all 5 users encountered the same problem. I'll try & do some more testing tomorrow.

@facundomedica
Copy link
Owner

Hello all! Can you try this in your pubspec.yaml?

  # fast_qr_reader_view: ^0.1.2
  fast_qr_reader_view:
    git:
      url: git://github.com/facundomedica/fast_qr_reader_view.git
      ref: blindtest

Also @ghunter99 you told me that you were distributing an app internally, do you have crashlytics set up?

I can't believe that my first cool open source project has a bug this difficult to catch 🤦‍♂️ Hopefully, We will find a solution to this!

@ghunter99
Copy link
Author

No I don't but I will set up crashlytics & get back to you

@ghunter99
Copy link
Author

Hi @facundomedica
Here's a Crashlytics crash report. I am running Flutter beta 0.6.0.
This crash happened when I tapped on the overview button to switch apps.
I had not scanned anything.
If I switch the code to the camera package it doesn't crash.
Hope this is helpful:

Crashlytics - plaintext stacktrace downloaded by Gary Hunter at Mon, 03 Sep 2018 20:16:29 GMT

URL: https://fabric.io/xyris-software-australia-pty-ltd/android/apps/au.com.xyris.eddflutter/issues/5b8d96356007d59fcda29b9f?time=last-seven-days/sessions/5B8D95DA005600017B684EFAF46CBD33_DNE_0_v2

Organization: Xyris Software (Australia) Pty Ltd

Platform: android

Application: edd_flutter

Version: 5.0.999 (14)

Bundle Identifier: au.com.xyris.eddflutter

Issue #: 3

Issue ID: 5b8d96356007d59fcda29b9f

Session ID: 5B8D95DA005600017B684EFAF46CBD33_DNE_0_v2

Date: 2018-09-03T20:14:00Z

OS Version: 7.1.1

Device: Moto G (5S) Plus

RAM Free: 30.4%

Disk Free: 41.6%

#0. Crashed: main
at android.app.ActivityThread.deliverResults(ActivityThread.java:4130)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4173)
at android.app.ActivityThread.-wrap20(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1546)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6165)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)

--

Fatal Exception: java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=513469796, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {au.com.xyris.eddflutter/au.com.xyris.eddflutter.MainActivity}: java.lang.NullPointerException: Attempt to invoke interface method 'void java.lang.Runnable.run()' on a null object reference
at android.app.ActivityThread.deliverResults(ActivityThread.java:4130)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4173)
at android.app.ActivityThread.-wrap20(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1546)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6165)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)

Caused by java.lang.NullPointerException: Attempt to invoke interface method 'void java.lang.Runnable.run()' on a null object reference
at io.flutter.plugins.camera.CameraPlugin$CameraRequestPermissionsListener.onRequestPermissionsResult(CameraPlugin.java:230)
at io.flutter.app.FlutterPluginRegistry.onRequestPermissionsResult(FlutterPluginRegistry.java:191)
at io.flutter.app.FlutterActivityDelegate.onRequestPermissionsResult(FlutterActivityDelegate.java:125)
at io.flutter.app.FlutterActivity.onRequestPermissionsResult(FlutterActivity.java:133)
at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:7098)
at android.app.Activity.dispatchActivityResult(Activity.java:6950)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4126)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4173)
at android.app.ActivityThread.-wrap20(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1546)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6165)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)

#0. Crashed: main
at android.app.ActivityThread.deliverResults(ActivityThread.java:4130)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4173)
at android.app.ActivityThread.-wrap20(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1546)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6165)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)

#1. OkHttp ConnectionPool
at java.lang.Object.wait(Object.java)
at com.android.okhttp.ConnectionPool.performCleanup(ConnectionPool.java:305)
at com.android.okhttp.ConnectionPool.runCleanupUntilPoolIsEmpty(ConnectionPool.java:242)
at com.android.okhttp.ConnectionPool.-wrap0(ConnectionPool.java)
at com.android.okhttp.ConnectionPool$1.run(ConnectionPool.java:97)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)

#2. Measurement Worker
at java.lang.Object.wait(Object.java)
at java.lang.Object.wait(Object.java:407)
at com.google.android.gms.internal.measurement.zzgm.run(Unknown Source)

#3. Queue
at java.lang.Object.wait(Object.java)
at java.lang.Thread.parkFor$(Thread.java:2127)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:161)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2035)
at java.util.concurrent.PriorityBlockingQueue.take(PriorityBlockingQueue.java:519)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.performOperation(DependencyPriorityBlockingQueue.java:197)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.get(DependencyPriorityBlockingQueue.java:236)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(DependencyPriorityBlockingQueue.java:65)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(DependencyPriorityBlockingQueue.java:46)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1058)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1118)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)

#4. pool-9-thread-1
at java.lang.Object.wait(Object.java)
at java.lang.Thread.parkFor$(Thread.java:2127)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:161)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2035)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:413)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1058)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1118)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)

#5. Answers Events Handler1
at java.lang.Object.wait(Object.java)
at java.lang.Thread.parkFor$(Thread.java:2127)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:201)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.awaitNanos(AbstractQueuedSynchronizer.java:2077)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1103)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1084)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1058)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1118)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at io.fabric.sdk.android.services.common.ExecutorUtils$1$1.onRun(ExecutorUtils.java:75)
at io.fabric.sdk.android.services.common.BackgroundPriorityRunnable.run(BackgroundPriorityRunnable.java:30)
at java.lang.Thread.run(Thread.java:761)

#6. Queue
at java.lang.Object.wait(Object.java)
at java.lang.Thread.parkFor$(Thread.java:2127)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:161)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2035)
at java.util.concurrent.PriorityBlockingQueue.take(PriorityBlockingQueue.java:519)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.performOperation(DependencyPriorityBlockingQueue.java:197)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.get(DependencyPriorityBlockingQueue.java:236)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(DependencyPriorityBlockingQueue.java:65)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(DependencyPriorityBlockingQueue.java:46)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1058)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1118)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)

#7. FirebaseMLHandler
at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
at android.os.MessageQueue.next(MessageQueue.java:323)
at android.os.Looper.loop(Looper.java:136)
at android.os.HandlerThread.run(HandlerThread.java:61)

#8. Queue
at java.lang.Object.wait(Object.java)
at java.lang.Thread.parkFor$(Thread.java:2127)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:161)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2035)
at java.util.concurrent.PriorityBlockingQueue.take(PriorityBlockingQueue.java:519)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.performOperation(DependencyPriorityBlockingQueue.java:197)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.get(DependencyPriorityBlockingQueue.java:236)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(DependencyPriorityBlockingQueue.java:65)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(DependencyPriorityBlockingQueue.java:46)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1058)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1118)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)

#9. Queue
at java.lang.Object.wait(Object.java)
at java.lang.Thread.parkFor$(Thread.java:2127)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:161)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2035)
at java.util.concurrent.PriorityBlockingQueue.take(PriorityBlockingQueue.java:519)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.performOperation(DependencyPriorityBlockingQueue.java:197)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.get(DependencyPriorityBlockingQueue.java:236)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(DependencyPriorityBlockingQueue.java:65)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(DependencyPriorityBlockingQueue.java:46)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1058)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1118)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)

#10. Queue
at java.lang.Object.wait(Object.java)
at java.lang.Thread.parkFor$(Thread.java:2127)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:161)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2035)
at java.util.concurrent.PriorityBlockingQueue.take(PriorityBlockingQueue.java:519)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.performOperation(DependencyPriorityBlockingQueue.java:197)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.get(DependencyPriorityBlockingQueue.java:236)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(DependencyPriorityBlockingQueue.java:65)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(DependencyPriorityBlockingQueue.java:46)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1058)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1118)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)

#11. Queue
at java.lang.Object.wait(Object.java)
at java.lang.Thread.parkFor$(Thread.java:2127)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:161)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2035)
at java.util.concurrent.PriorityBlockingQueue.take(PriorityBlockingQueue.java:519)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.performOperation(DependencyPriorityBlockingQueue.java:197)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.get(DependencyPriorityBlockingQueue.java:236)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(DependencyPriorityBlockingQueue.java:65)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(DependencyPriorityBlockingQueue.java:46)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1058)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1118)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)

#12. pool-4-thread-1
at java.lang.Object.wait(Object.java)
at java.lang.Thread.parkFor$(Thread.java:2127)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:161)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2035)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1091)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1084)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1058)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1118)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)

#13. pool-3-thread-1
at java.lang.Object.wait(Object.java)
at java.lang.Thread.parkFor$(Thread.java:2127)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:161)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2035)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:413)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1058)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1118)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)

#14. GoogleApiHandler
at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
at android.os.MessageQueue.next(MessageQueue.java:323)
at android.os.Looper.loop(Looper.java:136)
at android.os.HandlerThread.run(HandlerThread.java:61)

#15. Crashlytics Exception Handler1
at dalvik.system.VMStack.getThreadStackTrace(VMStack.java)
at java.lang.Thread.getStackTrace(Thread.java:1566)
at java.lang.Thread.getAllStackTraces(Thread.java:1616)
at com.crashlytics.android.core.CrashlyticsController.writeSessionEvent(CrashlyticsController.java:1334)
at com.crashlytics.android.core.CrashlyticsController.writeFatal(CrashlyticsController.java:1021)
at com.crashlytics.android.core.CrashlyticsController.access$500(CrashlyticsController.java:68)
at com.crashlytics.android.core.CrashlyticsController$7.call(CrashlyticsController.java:327)
at com.crashlytics.android.core.CrashlyticsController$7.call(CrashlyticsController.java:320)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at io.fabric.sdk.android.services.common.ExecutorUtils$1$1.onRun(ExecutorUtils.java:75)
at io.fabric.sdk.android.services.common.BackgroundPriorityRunnable.run(BackgroundPriorityRunnable.java:30)
at java.lang.Thread.run(Thread.java:761)

#16. HeapTaskDaemon
at dalvik.system.VMRuntime.runHeapTasks(VMRuntime.java)
at java.lang.Daemons$HeapTaskDaemon.run(Daemons.java:433)
at java.lang.Thread.run(Thread.java:761)

#17. FinalizerDaemon
at java.lang.Object.wait(Object.java)
at java.lang.Object.wait(Object.java:407)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:188)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:209)
at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:204)
at java.lang.Thread.run(Thread.java:761)

#18. GoogleApiHandler
at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
at android.os.MessageQueue.next(MessageQueue.java:323)
at android.os.Looper.loop(Looper.java:136)
at android.os.HandlerThread.run(HandlerThread.java:61)

#19. ReferenceQueueDaemon
at java.lang.Object.wait(Object.java)
at java.lang.Daemons$ReferenceQueueDaemon.run(Daemons.java:150)
at java.lang.Thread.run(Thread.java:761)

#20. ImageDecoderThread
at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
at android.os.MessageQueue.next(MessageQueue.java:323)
at android.os.Looper.loop(Looper.java:136)
at android.os.HandlerThread.run(HandlerThread.java:61)

#21. Queue
at java.lang.Object.wait(Object.java)
at java.lang.Thread.parkFor$(Thread.java:2127)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:161)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2035)
at java.util.concurrent.PriorityBlockingQueue.take(PriorityBlockingQueue.java:519)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.performOperation(DependencyPriorityBlockingQueue.java:197)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.get(DependencyPriorityBlockingQueue.java:236)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(DependencyPriorityBlockingQueue.java:65)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(DependencyPriorityBlockingQueue.java:46)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1058)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1118)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)

#22. Queue
at java.lang.Object.wait(Object.java)
at java.lang.Thread.parkFor$(Thread.java:2127)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:161)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2035)
at java.util.concurrent.PriorityBlockingQueue.take(PriorityBlockingQueue.java:519)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.performOperation(DependencyPriorityBlockingQueue.java:197)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.get(DependencyPriorityBlockingQueue.java:236)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(DependencyPriorityBlockingQueue.java:65)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(DependencyPriorityBlockingQueue.java:46)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1058)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1118)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)

#23. FinalizerWatchdogDaemon
at java.lang.Object.wait(Object.java)
at java.lang.Daemons$FinalizerWatchdogDaemon.sleepUntilNeeded(Daemons.java:269)
at java.lang.Daemons$FinalizerWatchdogDaemon.run(Daemons.java:249)
at java.lang.Thread.run(Thread.java:761)

#24. pool-7-thread-1
at java.lang.Object.wait(Object.java)
at java.lang.Thread.parkFor$(Thread.java:2127)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:161)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2035)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1091)
at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1084)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1058)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1118)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)

#25. Queue
at java.lang.Object.wait(Object.java)
at java.lang.Thread.parkFor$(Thread.java:2127)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:161)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2035)
at java.util.concurrent.PriorityBlockingQueue.take(PriorityBlockingQueue.java:519)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.performOperation(DependencyPriorityBlockingQueue.java:197)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.get(DependencyPriorityBlockingQueue.java:236)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(DependencyPriorityBlockingQueue.java:65)
at io.fabric.sdk.android.services.concurrency.DependencyPriorityBlockingQueue.take(DependencyPriorityBlockingQueue.java:46)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1058)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1118)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)

@facundomedica
Copy link
Owner

I have been able to recreate the issue in a coworker's device. Also, here is a related issue: https://stackoverflow.com/questions/51425658/sigsegv-crash-with-firebase-mlkit-barcode-scanner

@facundomedica
Copy link
Owner

Okay, big update here! The problem seems to be with devices that input more images than it can process, so when you go to background it keeps processing lots of data. I'm trying to solve this with a throttle flag so it process "just enough" but it seems to slow down everything (https://github.com/firebase/quickstart-android/blob/master/mlkit/app/src/main/java/com/google/firebase/samples/apps/mlkit/VisionProcessorBase.java). If this doesn't solve it, I might have to rewrite the Android class completely.

@ghunter99
Copy link
Author

Great work!

@dragosholban
Copy link
Contributor

dragosholban commented Sep 12, 2018

Hi @facundomedica
I made the changes you suggested and it seems to work fine. I made a PR, if it helps.

@facundomedica
Copy link
Owner

@ghunter99 the Eventway app is @dragosholban's, not mine. Also, it didn't crash, only froze right?

@sestegra thanks for joining the conversation!

I would guess that the throttle should throttle the image decoding and not the imagereader, so the surface will still get updates and the decoder only when it's not throttling. I'll try to upload something this week but feel free to experiment and make a pull request!

@facundomedica
Copy link
Owner

Sorry, a commit closed this automatically!

@facundomedica facundomedica reopened this Sep 17, 2018
@facundomedica
Copy link
Owner

I've just pushed an update in which almost everything was rewritten in Android. The code is a bit messy but it should be easy to clean it up once we know it is working. From my tests I've seen a serious improvement in performance and speed to read codes. Try it out with this:

fast_qr_reader_view:
    git:
      url: git://github.com/facundomedica/fast_qr_reader_view.git

@ghunter99
Copy link
Author

@facundomedica Wow!! A huge improvement. Much faster & much more stable. It still sometimes crashes though. I've attached a Crashlytics crash report.

au.com.xyris.eddflutter_issue_17_crash_5BA09E9403BE00012EE2DAB4D0E2A368_DNE_0_v2.txt

@sestegra
Copy link

sestegra commented Sep 18, 2018

@facundomedica It works well on my phone now.

@facundomedica
Copy link
Owner

@ghunter99 there was a duplicated start, re-download the package and try again

@ghunter99
Copy link
Author

Hi @facundomedica. I still seem to get crashes.
They seem to occur when I return to the app.
When I use my app in testing I open & close the scanner frequently within the app.
I ran the example app with the new package & wasn't able to get it to crash.

Attached is a crash report which I hope is helpful.

au.com.xyris.eddflutter_issue_17_crash_5BA15BB90257000161FDA6D86CFFC3CC_DNE_0_v2.txt

@facundomedica
Copy link
Owner

@ghunter99 It fails in a line where preview isn't checked for null, I just pushed a change, let me know if that fixes it for you!

@ghunter99
Copy link
Author

Thanks @facundomedica.
So far so good...
I'll get QA to test today.
It's 8am here in Brisbane, Australia

@ghunter99
Copy link
Author

@facundomedica, I did a lot of testing today & found 2 things.

Hope this is helpful and easy to reproduce.

First thing is, if you just add the fast_qr_reader_view package to an app
(for example, the default app created when you make a new project)
then run the app & just hit the Android back button (at the bottom left) then the app crashes
with the following debug output below (looks like package needs to be initialized even if you don't use it)

I attached the code main.dart file that I was using to create this behaviour.
You can just replace main.dart in your example to see the problem.

D/AndroidRuntime(18205): Shutting down VM
E/AndroidRuntime(18205): FATAL EXCEPTION: main
E/AndroidRuntime(18205): Process: co.apperto.fastqrreaderviewexample, PID: 18205
E/AndroidRuntime(18205): java.lang.RuntimeException: Unable to destroy activity {co.apperto.fastqrreaderviewexample/co.apperto.fastqrreaderviewexample.MainActivity}: java.lang.NullPointerException: Attempt to read from field 'co.apperto.fastqrreaderview.common.CameraSource co.apperto.fastqrreaderview.FastQrReaderViewPlugin$QrReader.cameraSource' on a null object reference
E/AndroidRuntime(18205): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4244)
E/AndroidRuntime(18205): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:4262)
E/AndroidRuntime(18205): at android.app.ActivityThread.-wrap6(ActivityThread.java)
E/AndroidRuntime(18205): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1551)
E/AndroidRuntime(18205): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(18205): at android.os.Looper.loop(Looper.java:154)
E/AndroidRuntime(18205): at android.app.ActivityThread.main(ActivityThread.java:6165)
E/AndroidRuntime(18205): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(18205): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
E/AndroidRuntime(18205): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)
E/AndroidRuntime(18205): Caused by: java.lang.NullPointerException: Attempt to read from field 'co.apperto.fastqrreaderview.common.CameraSource co.apperto.fastqrreaderview.FastQrReaderViewPlugin$QrReader.cameraSource' on a null object reference
E/AndroidRuntime(18205): at co.apperto.fastqrreaderview.FastQrReaderViewPlugin$QrReader.access$600(FastQrReaderViewPlugin.java:339)
E/AndroidRuntime(18205): at co.apperto.fastqrreaderview.FastQrReaderViewPlugin$2.onActivityDestroyed(FastQrReaderViewPlugin.java:147)
E/AndroidRuntime(18205): at android.app.Application.dispatchActivityDestroyed(Application.java:253)
E/AndroidRuntime(18205): at android.app.Activity.onDestroy(Activity.java:1850)
E/AndroidRuntime(18205): at io.flutter.app.FlutterActivity.onDestroy(FlutterActivity.java:103)
E/AndroidRuntime(18205): at android.app.Activity.performDestroy(Activity.java:6889)
E/AndroidRuntime(18205): at android.app.Instrumentation.callActivityOnDestroy(Instrumentation.java:1175)
E/AndroidRuntime(18205): at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:4231)

main.dart.zip

@ghunter99
Copy link
Author

@facundomedica 2nd thing I found:

I can reliably cause app I've been working on to crash.

Hope this is helpful.

Background
The way I use the package is a bit different to the example:

  1. when user needs to scan, then navigate to a new screen & call QRReaderController() etc
  2. when user is finished scanning, call controller?dispose to shut down scanner & navigate (pop) back to previous screen.

Steps to cause crash:

  1. Start app & tap button to navigate to scan screen
  2. Navigate back from the scan screen (i.e. tap back button) (you don't have to scan anything)
  3. Lock screen
  4. Unlock screen
  5. App crashes

I attached a minimal main.dart that is based on your example code & default Flutter app.
You can use it as a drop in replacement for the example main.dart to reproduce crash for you (I hope).

main.dart.zip

I've also attached a crashlytics report from a crash.

au.com.xyris.eddflutter_issue_17_crash_5BA1C89802B0000103243D1EB519C677_DNE_0_v2.txt

@ghunter99
Copy link
Author

...lastly, just wanted to say it is a pretty cool package you've made. I'm hoping to use it in a Flutter port of an iOS app that has 1.2M downloads here in Australia. ....am so impressed with Flutter!

@Nik99
Copy link

Nik99 commented Sep 25, 2018

Yeah i can confirm, even if the screen goes in standby, when resuming the app just crashes.

E/AndroidRuntime(13294): java.lang.RuntimeException: Unable to resume activity {x.MainActivity}: java.lang.RuntimeException: startPreview failed E/AndroidRuntime(13294): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4179) E/AndroidRuntime(13294): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4219) E/AndroidRuntime(13294): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1944) E/AndroidRuntime(13294): at android.os.Handler.dispatchMessage(Handler.java:108) E/AndroidRuntime(13294): at android.os.Looper.loop(Looper.java:166) E/AndroidRuntime(13294): at android.app.ActivityThread.main(ActivityThread.java:7425) E/AndroidRuntime(13294): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(13294): at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245) E/AndroidRuntime(13294): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921) E/AndroidRuntime(13294): Caused by: java.lang.RuntimeException: startPreview failed E/AndroidRuntime(13294): at android.hardware.Camera.startPreview(Native Method) E/AndroidRuntime(13294): at co.apperto.fastqrreaderview.common.CameraSource.start(CameraSource.java:194) E/AndroidRuntime(13294): at co.apperto.fastqrreaderview.common.CameraSourcePreview.startIfReady(CameraSourcePreview.java:96) E/AndroidRuntime(13294): at co.apperto.fastqrreaderview.common.CameraSourcePreview.start(CameraSourcePreview.java:71) E/AndroidRuntime(13294): at co.apperto.fastqrreaderview.FastQrReaderViewPlugin$QrReader.startCameraSource(FastQrReaderViewPlugin.java:378) E/AndroidRuntime(13294): at co.apperto.fastqrreaderview.FastQrReaderViewPlugin$QrReader.access$400(FastQrReaderViewPlugin.java:339) E/AndroidRuntime(13294): at co.apperto.fastqrreaderview.FastQrReaderViewPlugin$2.onActivityResumed(FastQrReaderViewPlugin.java:111) E/AndroidRuntime(13294): at android.app.Application.dispatchActivityResumed(Application.java:222) E/AndroidRuntime(13294): at android.app.Activity.onResume(Activity.java:1415) E/AndroidRuntime(13294): at io.flutter.app.FlutterActivity.onResume(FlutterActivity.java:96) E/AndroidRuntime(13294): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1364) E/AndroidRuntime(13294): at android.app.Activity.performResume(Activity.java:7479) E/AndroidRuntime(13294): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4147) E/AndroidRuntime(13294): ... 8 more I/Process (13294): Sending signal. PID: 13294 SIG: 9

@Nik99
Copy link

Nik99 commented Sep 27, 2018

Has this bug been solved ? @facundomedica

@facundomedica
Copy link
Owner

Hi! I didn't get the time to check on this. I tried with the instructions @ghunter99 provided but I haven't been able to reproduce the issue! 🤦‍♂️

@facundomedica
Copy link
Owner

I made some changes, please try again!

@Nik99
Copy link

Nik99 commented Sep 27, 2018

No, the problem still happens. You simply have to open the camera, go to another widget, and then try to switch app. It seems like the dispose method is never called or the camera is never closed. I'm calling it like a new object page from a StreamBuilder.

This is still what i get:
[+4201 ms] I/Camera (22482): camera number: 2 [ ] I/Camera (22482): camera number: 2 [ ] I/Camera (22482): camera number: 2 [ +3 ms] I/PermissionManager(22482): camera remind result:true [ +33 ms] I/CameraManagerGlobal(22482): do not need hide aux camera, device number: 2 [ ] I/CameraManagerGlobal(22482): do not need hide aux camera, device number: 2 [ +8 ms] I/Camera (22482): camera number: 2 [ +3 ms] E/BufferQueueProducer(22482): [SurfaceTexture-0-22482-0] query: BufferQueue has been abandoned [ ] D/AndroidRuntime(22482): Shutting down VM [ ] E/AndroidRuntime(22482): FATAL EXCEPTION: main [ ] E/AndroidRuntime(22482): Process: myapp, PID: 22482 [ ] E/AndroidRuntime(22482): java.lang.RuntimeException: Unable to resume activity {myapp/myappflutter.MainActivity}: java.lang.RuntimeException: startPreview failed [ ] E/AndroidRuntime(22482): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4179) [ ] E/AndroidRuntime(22482): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4219) [ ] E/AndroidRuntime(22482): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1944) [ ] E/AndroidRuntime(22482): at android.os.Handler.dispatchMessage(Handler.java:108) [ ] E/AndroidRuntime(22482): at android.os.Looper.loop(Looper.java:166) [ ] E/AndroidRuntime(22482): at android.app.ActivityThread.main(ActivityThread.java:7425) [ ] E/AndroidRuntime(22482): at java.lang.reflect.Method.invoke(Native Method) [ ] E/AndroidRuntime(22482): at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245) [ ] E/AndroidRuntime(22482): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921) [ ] E/AndroidRuntime(22482): Caused by: java.lang.RuntimeException: startPreview failed [ ] E/AndroidRuntime(22482): at android.hardware.Camera.startPreview(Native Method) [ ] E/AndroidRuntime(22482): at co.apperto.fastqrreaderview.common.CameraSource.start(CameraSource.java:194) [ ] E/AndroidRuntime(22482): at co.apperto.fastqrreaderview.common.CameraSourcePreview.startIfReady(CameraSourcePreview.java:96) [ ] E/AndroidRuntime(22482): at co.apperto.fastqrreaderview.common.CameraSourcePreview.start(CameraSourcePreview.java:71) [ ] E/AndroidRuntime(22482): at co.apperto.fastqrreaderview.FastQrReaderViewPlugin$QrReader.startCameraSource(FastQrReaderViewPlugin.java:376) [ ] E/AndroidRuntime(22482): at co.apperto.fastqrreaderview.FastQrReaderViewPlugin$QrReader.access$400(FastQrReaderViewPlugin.java:337) [ ] E/AndroidRuntime(22482): at co.apperto.fastqrreaderview.FastQrReaderViewPlugin$2.onActivityResumed(FastQrReaderViewPlugin.java:109) [ ] E/AndroidRuntime(22482): at android.app.Application.dispatchActivityResumed(Application.java:222) [ ] E/AndroidRuntime(22482): at android.app.Activity.onResume(Activity.java:1415) [ ] E/AndroidRuntime(22482): at io.flutter.app.FlutterActivity.onResume(FlutterActivity.java:96) [ ] E/AndroidRuntime(22482): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1364) [ ] E/AndroidRuntime(22482): at android.app.Activity.performResume(Activity.java:7479) [ ] E/AndroidRuntime(22482): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4147) [ ] E/AndroidRuntime(22482): ... 8 more [ +6 ms] I/Process (22482): Sending signal. PID: 22482 SIG: 9 [ +63 ms] Service protocol connection closed. [ ] Lost connection to device. [ +1 ms] DevFS: Deleting filesystem on the device (file:///data/user/0/myapp/) [ ] _deleteDevFS: {fsName: my-ristocloud-azienda} [ +3 ms] DevFS: Deleting filesystem on the device (file:///data/user/0/myapp/) [ ] _deleteDevFS: {fsName: my-ristocloud-azienda} [ +252 ms] TimeoutException after 0:00:00.250000: Future not completed [{"event":"app.stop","params":{"appId":"f0ac5228-0984-4f97-971c-48efc1b8507d"}}] [ +10 ms] "flutter run" took 127.808ms. [ +4 ms] TimeoutException after 0:00:00.250000: Future not completed [{"id":6,"result":true}]

@facundomedica
Copy link
Owner

facundomedica commented Sep 27, 2018

I've copied one of the answers from here (flutter/flutter#18348) and pushed the change. Can you try now?

@ghunter99
Copy link
Author

@facundomedica @Nik99 does not crash now for me 👍

@Nik99
Copy link

Nik99 commented Sep 28, 2018

Works for me too!
Thanks @facundomedica @ghunter99

@facundomedica
Copy link
Owner

Great! I've already pushed 0.1.4 to the package index (or whatever people call https://pub.dartlang.org)

@Nik99
Copy link

Nik99 commented Oct 1, 2018

The app doesn't work again.
This time for a new error:

Xcode's output:
↳
    === BUILD TARGET fast_qr_reader_view OF PROJECT Pods WITH CONFIGURATION Release ===
    The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift. Supported values are: 3.0, 4.0, 4.2. This setting can be set in the build settings editor.
    The “Swift Language Version” (SWIFT_VERSION) build setting must be set to a supported value for targets which use Swift. Supported values are: 3.0, 4.0, 4.2. This setting can be set in the build settings editor.

@Nik99
Copy link

Nik99 commented Oct 1, 2018

My app needed to be published today but this is blocking it. Can you fix it ? @facundomedica

@facundomedica
Copy link
Owner

@Nik99 that doesn't seem related to this issue nor to this library, but to a project config thing. Check this: https://stackoverflow.com/a/46339401/5240559

@Nik99
Copy link

Nik99 commented Oct 1, 2018

I'm sorry. You are right. Flutter was spitting me out errors on your library but it is not.
Sorry, thanks!
I think you can close this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants