twostraws / CodeScanner

A SwiftUI view that is able to scan barcodes, QR codes, and more, and send back what was found.
MIT License
1.02k stars 293 forks source link

tapgestures on sheet freezes camera #11

Closed VoordeMensen closed 3 years ago

VoordeMensen commented 4 years ago

Clicking/touching/moving the sheet freezes the camera for 8 seconds - no warnings or errors in debug - any thoughts?

nozokada commented 4 years ago

@VoordeMensen Because viewWillDisappear and viewDidAppear in ScannerViewController are fired every time you pull down the sheet partially (not completely). It basically restarts the video capture session and reloads the preview layer.

I ended up doing the following:

  1. Added a nil check to viewDidAppear to avoid redundant preview layer instantiation
  2. Changed viewWillDisappear into viewDidDisappear so that the capture session won't stop until the sheet is completely pulled down and closed

See #21 for code changes

alobaili commented 3 years ago

This issue has been fixed in #21.

I think it's time to close it.

twostraws commented 3 years ago

Thank you!