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.
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
- Create a barcode scanner app with a preview layer
- hook up the metadata objects detector and delegate
- on interface rotation, adjust the rect of interest
- run the app in portrait, rotate to landscape
- There should be no noticeable visual effect of changing the rect of interest
- The preview video goes blank
- The main thread is blocked
- After this noticeable delay the interface rotates
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