gruhn / vue-qrcode-reader

A set of Vue.js components for detecting and decoding QR codes.
https://gruhn.github.io/vue-qrcode-reader
MIT License
2.1k stars 335 forks source link

How to pause scanning #280

Closed cimpok closed 2 years ago

cimpok commented 2 years ago

Hi @gruhn, thank you for this cool component! I am using the Vue3 preview branch, (btw. as the mass migration is slowly beginning to Vue3 do you plan to release it soon?) I need your advice in the following scenario.

I am using a small method passed to the :track prop, this method updates some vue reactive variables (x,y,width,height). These variables are used by vue engine to update a floating div's position and size using a computed property passed to the div's style. The reason I am using a div element instead of drawing to the canvas directly is this being a simpler approach to show live data in the div, I am also making this div clickable.

This setup is working nice, but as your warning at the track prop description says, it crashes the browser after I admire your (and mine) work for some longer time during testing, I'm testing it on an almost high-end phone, so for the average user I suppose, it would be worse.

My approach for the solution would be this: After some conditions are met (e.g. the QR is detected, the boundingBox is large enough and roughly steady, or some time has passed, etc. (I will figure these out for the best user experience) I would like to pause the processing to ease the load. For this pause I need to stop both the video stream and the scanning algorithm, I mean not closing the component but to show a still image of the last frame of the video, the scanning for QR codes must be paused with the overlay div staying in the last position. I would like to continue the process on some other conditions (e.g. click on the video), destroying the whole component and to reload it is too slow.

In summary, what would be the best practice to pause the video and to pause the QR-scanning? Thank you for any clues.

PS I see others also observe some crashes unrelated to the :track feature. Maybe the core scanning code has a memory leak bug? either way a feature for a pause (and perhaps to be able to silently flush/restart the scanning algorithm module during this pause) could also be a workaround mitigation until the memory leak is solved.

gruhn commented 2 years ago

On Vue 3 migration: It shouldn't be too much work but I'm just too busy all the time. Maybe around Christmas I'll find some time to deal with all the outstanding stuff.

On your main question: Have you checked out the Pause & Validate demo? It sounds very fitting to your use case.

On the PS section: Yes, I'm almost certain there is a memory leak. It's very hard to debug though, since I can't reproduce it. Or at least I haven't tried hard enough yet. Also because I'm too busy.

cimpok commented 2 years ago

@gruhn Thank you, it is ok with the later migration for me, I may patch the IOS15 issue myself till then, it looks not complicated. all else is not that urgent for me. Thank you for the clue about the Pause demo it is almost exactly what I need it slipped my notice, sorry for the false trouble. As you are well aware of the third problem, the possible memory leak, I am closing this issue.