gualtierofrigerio / GFLiveScanner

Import this package to perform live scanning of barcodes, QR codes and OCR.
MIT License
6 stars 1 forks source link

Performance issues with GFLiveScannerViewController #2

Closed AnthoPakPak closed 1 year ago

AnthoPakPak commented 1 year ago

Hey, thanks for the library!

I've successfully integrated GFLiveScannerViewController into my project. Unfortunately, I've then discovered that my UI was getting slow and unresponsive after a few seconds. After trying again the Demo app, I've made the same observations.

To reproduce:

Have you faced this issue too? I've checked the code but can't find where I could patch the issue. I bet it's a matter of moving the text recognition from main thread to a background thread.

Any help is appreciated 🤗

gualtierofrigerio commented 1 year ago

Thanks for your comment and your interest in the library :)

I didn't use the OCR much at the time I shared this (more the barcode), at least not in live mode so I don't remember if I had performance issues. Having a quick look at the code now I think a possibility could also be avoiding queueing too many requests in GFOcrHelper, I don't remember exactly the logic but I think I implemented a list of requests to process them one at a time. Maybe too many requests are made and this is a problem so a threshold could be set, like no more than X requests process per second and you drop the others. I don't know when I'll have time to test this approach but it may be a possibility to explore.

AnthoPakPak commented 1 year ago

Hey, thanks a lot for your quick answer!

Thanks to your insights, I've took another look and managed to improve performances by:

It's now behaving well enough for my use. Thanks for your work on this!

gualtierofrigerio commented 1 year ago

thanks for the feedback, maybe I could change something in order to have the queue or requests as an option instead of being the default and of course a different thread for some of the operations, I thought it was already like that but it wasn't...