Improving efficiency of QR scanning

My app needs to be able to scan QR codes, but my implementation is far too inefficient and makes the UI unresponsive. I based it on two different tutorials; mainly on one on raywenderlich.com about how to display a camera preview in SwiftUI without using UIViewRepresentable. I would post a link, but apparently that domain is banned here (why?). It uses AVCaptureVideoDataOutput and converts captured frames to CGImage via CIImage for use in an Image SwiftUI view. Is that one of the things that's making it slow? Would it be much more efficient to use UIViewRepresentable after all?

My code for processing QR codes is based on another tutorial whose link I can't post, using AVCaptureMetadataOutput. Is there a way to make the metadata queue drop frames when it's busy, independently of the preview's queue? Or is reducing the video frame rate the only way?

I will look into choosing a video source format/resolution that takes less processing, and at a lower frame rate, but it would be nice if I could still show a preview that's relatively smooth compared to the rate at which it's trying to decode QRs.

Improving efficiency of QR scanning
 
 
Q