Problem
When a user takes a photo of a receipt on Android, the camera capture (takePhoto()) consistently takes 1.5-2 seconds before the confirmation screen appears. We don't have Android profile here, but iOS Sentry profiling shows the main thread and JS thread are mostly idle during this time -- so, the app must be waiting on the native camera hardware to complete its capture sequence. This is especially noticeable on Android where the highest concentration of ~2s captures are happening.
More context in this Slack thread.
Solution
We aren't following several VisionCamera performance best practices that could reduce this time:
- Cap photo resolution - We currently request
photoResolution: 'max' which selects the sensor's full resolution (48MP+ on modern phones). For receipt scanning, ~12MP is sufficient. Also remove the unnecessary videoResolution: 'max' since the video pipeline isn't enabled. Edit: Changing videoResolution makes the picture quality awful.
Use a single camera device - We request ['wide-angle-camera', 'ultra-wide-angle-camera'] which initializes multiple sensors. Receipt scanning only needs the wide-angle camera. Edit: Without ultra-wide-ange-camera the close up focus is awful.
- Explicitly enable buffer compression - Add
enableBufferCompression to the Camera component to ensure compressed buffers are always used. Edit: So far seems not to have any difference for iOS.
- Evaluate using
takeSnapshot() instead of takePhoto() which skips the precapture sequence entirely (~16ms vs ~500-1400ms), but this needs validation that image quality is sufficient for SmartScan. Edit: Did not seem to help on iOS, currently testing Android.
Problem
When a user takes a photo of a receipt on Android, the camera capture (
takePhoto()) consistently takes 1.5-2 seconds before the confirmation screen appears. We don't have Android profile here, but iOS Sentry profiling shows the main thread and JS thread are mostly idle during this time -- so, the app must be waiting on the native camera hardware to complete its capture sequence. This is especially noticeable on Android where the highest concentration of ~2s captures are happening.More context in this Slack thread.
Solution
We aren't following several VisionCamera performance best practices that could reduce this time:
photoResolution: 'max'which selects the sensor's full resolution (48MP+ on modern phones). For receipt scanning, ~12MP is sufficient.Also remove the unnecessaryEdit: Changing videoResolution makes the picture quality awful.videoResolution: 'max'since the video pipeline isn't enabled.Use a single camera device - We requestEdit: Without['wide-angle-camera', 'ultra-wide-angle-camera']which initializes multiple sensors. Receipt scanning only needs the wide-angle camera.ultra-wide-ange-camerathe close up focus is awful.enableBufferCompressionto the Camera component to ensure compressed buffers are always used. Edit: So far seems not to have any difference for iOS.takeSnapshot()instead oftakePhoto()which skips the precapture sequence entirely (~16ms vs ~500-1400ms), but this needs validation that image quality is sufficient for SmartScan. Edit: Did not seem to help on iOS, currently testing Android.