barcode-scanner-webassembly icon indicating copy to clipboard operation
barcode-scanner-webassembly copied to clipboard

The in browser demo runs very slow in mobile phone browser.

Open ashutalewar opened this issue 6 years ago • 5 comments
trafficstars

The demo works perfectly fine in the laptop browser but in mobile phone browser its lagging too much. I tried optimizing by using service workers but couldn't see much improvement. Are there any ways to improve the performance in the mobile browser?

ashutalewar avatar Nov 08 '19 15:11 ashutalewar

Great question. Performance is actually one of the most important issues with this proof-of-concept. I've actually discussed potential approaches to improve this at the very end of the blog post accompanying this repo.. See the part below Performance is not fantastic yet....

jjhbw avatar Nov 08 '19 15:11 jjhbw

Congrats for this project @jjhbw !

I tried it on a Samsung Galaxy smartphone and it is very slow indeed (1 fps or maybe 0.5 fps), and on my i5 laptop too. Do you think improvements of these last years about Wasm could improve the performance?

josephernest avatar Feb 10 '20 18:02 josephernest

Interesting question, I would love to know about that too. You could try recompiling with the latest version of Emscripten to see if compiler/wasm improvements help.

However, I expect the most important bottlenecks to be inherent to the architecture. I haven't profiled it, but I expect that a lot of time is spent on copying image buffers from the canvas into webassembly land.

You could also look into flipping some of Zbar's (compile-time) switches to see if you can trade some fidelity or unused features for extra speed.

jjhbw avatar Feb 11 '20 09:02 jjhbw

Hey guys @josephernest and @jjhbw! I have extracted the QR recognition code into a WebWorker. You can try this demo and check the performance on your devices ;)

[1] https://github.com/maslick/koder [2] https://qr.maslick.tech

maslick avatar Apr 09 '21 19:04 maslick

@maslick very nice work! Thanks for posting it.

jjhbw avatar Apr 11 '21 14:04 jjhbw