Ad

Our DNA is written in Swift
Jump

Radar: Changing Metadata RectOfInterest causes pause

I found this issue when working on a barcode scanner included in an app I am working on for prod.ly. If you want to be efficient with barcode scanning and change the scanning region in the preview depending on device orientation you’ll notice this problem. Say, you want a wider active scanning area in landscape than you want in portrait.

When you change the rectOfInterest during rotation the preview video goes to black briefly and the main thread is blocked causing the rotation to start with a delay too.

Filed as rdar://18980982 and on Open Radar.

Summary

In a barcode scanning scenario with a running AVCapture session: if you adjust the metadata rectOfInterest the preview video goes blank and the main thread is blocked for a noticeable delay.

Steps to Reproduce

  1. Create a barcode scanner app with a preview layer
  2. hook up the metadata objects detector and delegate
  3. on interface rotation, adjust the rect of interest
  4. run the app in portrait, rotate to landscape

Expected Results

  • There should be no noticeable visual effect of changing the rect of interest

Actual Results

  • The preview video goes blank
  • The main thread is blocked
  • After this noticeable delay the interface rotates

Notes

My workaround is to not change the rect of interest, but instead check if reported metadata objects’ bounds are within my scan target view area.

This is quite suboptimal since changing the rect of interest (in particular for 1D barcodes) would be very beneficial for the scanning performance due to scan lines being used. The smaller the area, the more compact they can be.


Categories: Bug Reports

Leave a Comment