ftylitak / qzxing

Qt/QML wrapper library for the ZXing library. 1D/2D barcode image processing library
Apache License 2.0
617 stars 340 forks source link

zxing hangs in selectBestPatterns #163

Open G-S-E opened 4 years ago

G-S-E commented 4 years ago

It happens some time. I faced with random crashes when I am using QZXing for QR decode. Crashes occurs only if I use QZXing for decoding. I started to debug my app.

I've found that program hangs forever in vector< Ref<FinderPattern> > FinderPatternFinder::selectBestPatterns() which located in qzxing/src/zxing/zxing/qrcode/detector/QRFinderPatternFinder.cpp

Could anybody help me with any idea? Is it because of buggy version of the base zxing-cpp?

ftylitak commented 4 years ago

Hello @G-S-E

Does the application crashes, like saying segmentation fault? Or does it hang, like saying it freezes for ever?

G-S-E commented 4 years ago

Sometimes it freezes forever and sometimes it crashes. When it freezes it consumes whole CPU time. When it crashes it gives no error information.

ftylitak commented 4 years ago

Does this happen often? Do you have any sample image?

It would be interesting if this could be related to the #164 . I have just pushed a workaround on that issue, may be it could affect yours also.

Looking forward to your feedback.

G-S-E commented 4 years ago

Yes, it happens quite often. The last changes on your upstream change nothing for me. Here is an image on wich I hanged the last time. buggy_image.zip I have found that program can hang in the decodeImage for a long time, like 528439ms.

ftylitak commented 4 years ago

Interesting. I have never experienced such a behavior and the image that you have sent does hang through my tests.

To try to get a bit closer to your environment could you share your build environment?

Sorry for the list of questions though your issue is important and I would like to understand how to reproduce it.

G-S-E commented 4 years ago

the image that you have sent does hang through my tests.

Does it?

I use the following target device:

~# uname -a
Linux sama5d27 4.19.78-linux4sam-6.2-00039 #1 Thu Mar 19 08:53:14 UTC 2020 armv7l armv7l armv7l GNU/Linux

Qt:

QMake version 3.1
Using Qt version 5.12.5 in /usr/lib

I feed images by direct call to QZXing::decodeImage in cpp:

QString decodeResult = m_decoder.decodeImage(image,
                                             ScannerQWidgetSink::CAPTURE_WIDTH,
                                             ScannerQWidgetSink::CAPTURE_HEIGHT,
                                             false);

It is difficult now to list all image resolutions at which the issue occurs, but I believe that it happens at the following modes:

uint ScannerQWidgetSink::CAPTURE_HEIGHT = 600;
uint ScannerQWidgetSink::CAPTURE_WIDTH = 800;
//uint ScannerQWidgetSink::CAPTURE_HEIGHT = 768;
//uint ScannerQWidgetSink::CAPTURE_WIDTH = 1024;
//uint ScannerQWidgetSink::CAPTURE_HEIGHT = 1024;
//uint ScannerQWidgetSink::CAPTURE_WIDTH = 1280;
//uint ScannerQWidgetSink::CAPTURE_HEIGHT = 1200;
//uint ScannerQWidgetSink::CAPTURE_WIDTH = 1600;

I have sent you the 1600x1200 image. More often i had problems with 1600x1200 and 1280x1024 images. I always pass to decodeImage the same resolution as the image has.

May be I was wrong saying that the last fixes do nothing for me. My project probably was not rebuilt or deployed on target properly at the time. Now we cannot reproduce the bug. We will trying. Thank you for your attention.

ftylitak commented 4 years ago

Does it?

Actually not i am sorry. It was a typo, i meant it does not get reproduced. (may be i did not have enough coffee at the time I replied, sorry again)

Thank you for the update, tomorrow I will look it further.

G-S-E commented 4 years ago

The fixes improve the situation, but QZXing still hangs sometime for a long time (10's or even 100"s seconds). I have got it at 1024x768, but I belive that it is not related to an image, but to initialization of some variables. Should we add some debug capabilities to the code? What we need to monitor in this situation? I can reproduce the bug in 5-10 minutes.