afriscic / BarcodeScanning.Native.Maui

Barcode scanning library for .NET MAUI
https://www.nuget.org/packages/BarcodeScanning.Native.Maui
MIT License
162 stars 31 forks source link

Call to AVCaptureSession.startRunning() blocks #71

Closed breyed closed 3 months ago

breyed commented 3 months ago

Apple’s documentation for startRunning() has this important note:

The startRunning() method is a blocking call which can take some time, therefore start the session on a serial dispatch queue so that you don’t block the main queue (which keeps the UI responsive). See AVCam: Building a Camera App for an implementation example.

This is borne out in practice. On an iPhone 15, the app hangs for about 2 seconds, since BarcodeScanning.Native.Maui calls startRunning() and stopRunning() on the main thread. Sometimes this doesn’t feel too bad, but when navigating to a page that has the barcode scanner already enabled, it feels quite glitchy.

afriscic commented 3 months ago

Hello,

thank you for pointing this out. Somehow I missed that. I'll fix this in next release.

afriscic commented 3 months ago

Should be fixed in 1.5.4