Skip to content

[Performance] Android camera capture is slow (~1.5-2s + more) #84793

@marcaaron

Description

@marcaaron

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:

  1. 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.
  2. 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.
  3. 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.
  4. 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.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions