How to Make a Barcode Scanner App Performant

sparkscan making barcode scanning performant on device

Published

Last updated

Categories Developers

This blog explains various deployment and API options for improving barcode scanning performance and how they impact user workflows. The techniques here apply to any web-based barcode scanning library, using specific examples from:

  • Scandit SparkScan API — an easy-to-deploy interface providing pre-built and optimized barcode scanning with a minimalistic UI that floats on top of any app.
  • Scandit Barcode Capture API — the full set of features allowing deeper customization of the barcode scanning experience, but requiring greater time investment and in-house computer vision expertise.

We’ve focused on web applications in this blog, but these techniques will work for all development frameworks that Scandit supports, including those for iOS and Android native applications.

You can also find out more about how to measure barcode scanning performance in our in-depth best practice guide.


Quick tips:

  • Slow load times: locate all resources on servers you control, serve all web assets compressed and with caching enabled, use optimal image compression, and compile in WebAssembly where appropriate.
  • Slow capture times: restrict the active scan area and symbologies, and set the default zoom factor.
  • Users capturing the wrong barcodes: restrict the active symbologies, filter duplicates, and implement explicit start and stop scanning steps.
  • Users wanting more control: implement user customizations such as target mode, continuous scanning, and UI controls.
  • Excessive battery consumption: ensure the app turns the camera on only when necessary for scanning.
  • Shutdown issues: following best practices for graceful shutdown.

What does barcode scanning performance mean?

Barcode scanning performance refers to the speed, accuracy, stability, and scalability of an application under a given workload. The focus of this blog is on speed and responsiveness, as stability and scalability have more to do with application architecture and other tasks on the device unrelated to barcode scanning.

All these factors directly impact how quickly users can scan barcodes and how often they must repeat scans. Real-world scanning happens in challenging environmental conditions, such as:

  • Busy warehouses with thousands of daily shipments.
  • Retail stockrooms with poor lighting.
  • Delivery vans crowded with packages of different sizes and orientations.

How Scandit barcode scanning software works

To help understand the code samples presented here, you should know the basics of Scandit’s software components and setup:

SparkScan API

  1. SparkScanSettings sets up the enabled symbologies, SparkScan mode, and listeners that are informed whenever a new barcode is scanned.
  2. SparkScanView to set up various user interface options.

Barcode Capture API

  1. DataCaptureContext manages barcode scanning and general configuration options.
  2. DataCaptureView to set up user interface and camera settings.

The following sections explain how to solve six of the most common performance issues.

1. Slow application load times

Slow application load times are the result of resource latencies, either by inefficient access mechanisms or storage.

While load times are affected by other tasks on the device (such as operating system activities and foregrounded apps), doing as much optimization work as you can up front reduces issues down the road.

Optimize barcode scanning resources

  • Locate all resources, including libraries, images, and configuration files, on a server under your control to minimize the impact of downtimes and Internet delays associated with third-party servers. With Scandit software, all processing happens on device, so you don’t need to worry about connectivity or security for in-transit data.
  • Compile in WebAssembly (Wasm), which uses a compact binary format (.wasm) that is highly efficient in size and load times, for faster downloads and reduced latency. (SparkScan does this for you.)
  • Serve all web assets compressed and with caching enabled by your web server.
  • Ensure optimal image compression that balances processing overhead with scanning quality. (If using Scandit, this is handled by Scandit SparkScan.)

For web apps, if the user’s browser is under your control, you can set it to use GPU acceleration for faster and more accurate barcode localization at challenging positions and angles. You can also explore technologies like WebGL or WebGPU to take advantage of a device’s GPU.

sparkscan package picking scanning mobile device

30-Day free trial

Test Scandit's fast, accurate, and reliable barcode scanning performance for yourself.

Optimize application launch

Web-based barcode scanning libraries are usually downloaded from a server, compiled, cached, and loaded into a browser session’s memory. Once cached, the library must be loaded by the page using it, usually upon user request.

The speed with which this process happens depends on several factors that can be tuned for performance. Here are some tips to reduce application launch times:

  • Pre-load and pre-compile libraries in the application background to avoid making the user wait for a response when they activate barcode scanning. Ideally, this happens when the page is loaded, regardless of whether the user activates barcode scanning.
  • Configure and initialize the barcode scanner library as early as possible to ensure it’s loaded and ready to go when the user needs it. For Scandit software, this is done using the configure() method.
  • If the device supports it, use the camera’s standby state to minimize delays. Depending on the device, the transition between the camera’s standby and on states can be between 50% to 90% faster than the transition between off and on.
  • Create a hidden and paused scanner instance in the background with the camera in a standby state. This avoids the user waiting for the app to create the instance on the fly. SparkScan does this for you; for Barcode Capture this looks like:
// Disable the barcode capture mode until the camera is accessed.
await barcodeCapture.setEnabled(false);
await camera.switchToDesiredState(FrameSourceState.Standby);

When the user wants to start scanning, reverse these steps:

// Switch the camera on to start streaming frames.
// The camera is started asynchronously and will take some time to completely turn on.
await camera.switchToDesiredState(FrameSourceState.On);
// Enable the barcode capture mode 
await barcodeCapture.setEnabled(true);
  • Reuse the existing scanner instance whenever possible by hiding/pausing and showing/resuming it instead of destroying and recreating it.

2. Slow barcode capture times

Slow barcode capture times are the result of resource or data inefficiencies in the scanning process. Optimizing capture times means users can move faster between items and reduce frustrations due to slow app response.

There are six capture steps to consider as part of your optimization strategy , as illustrated below.

Six-step barcode scanning process: locate, align, focus, capture, feedback, view results.

The following describes different actions you can take to improve barcode capture times.

Restrict the active scan area

The region within the camera’s field of view where the barcode scanner searches for labels is called the “active scan area.” Regions not covered by the active scan area are ignored.

Restricting this area helps capture barcodes in cluttered environments, and improves performance as less information needs to be processed. On lower-end devices, limiting the scan area can have a significant impact on CPU overhead.

With SparkScan, the active scan area is set by the user if you enable the control using the previewSizeControlVisible property of SparkScanView.

Restrict the active symbologies

Barcode scanning libraries are usually capable of reading multiple different types of barcodes, often referred to as symbologies (e.g., EAN Code, Code 39, and QR Code).

Different industries and use cases use specific symbologies. Limiting the active symbologies to only those needed by your users reduces application overhead, and also the chances of misidentifying a label.

With SparkScan, you can set the active symbologies through SparkScanSettings:

const settings = new SparkScanSettings();
settings.enableSymbologies([Symbology.EAN13UPCA]);

If you don’t know the correct symbologies for your use case, SparkScan makes setting them easy. Through capture presets, you can enable different sets of symbologies tailored for different industry verticals. For example, if your barcode scanner is used for retail and logistics, you can enable the RETAIL and LOGISTICS capture presets without setting individual symbologies manually.

Additionally, SparkScan and Barcode Capture prioritize symbologies based on your scanning behavior. Regardless of the symbologies you set, this prioritization helps improve scanning performance based on actual use.

Set the default zoom factor

In environments where scanning distances between the device and the label tend to be longer, setting the camera’s default zoom factor makes centering and focusing on the barcode easier. Starting users off “zoomed in,” for example, means they don’t need to zoom in themselves.

With SparkScan, the default zoom factor is set using the ZoomFactorOut property. The ZoomFactorIn property specifies the zoom factor to move to when the user taps the zoom control. This control is enabled by default.

For Barcode Capture, users can zoom in with a swipe gesture on the preview screen, making it easier to locate barcodes.

3. Users capturing the wrong barcodes

To avoid capturing the wrong barcodes, you should define success and failure criteria for barcode scanning and implement them through your library. For Scandit use cases and software, there are three types of failed barcode scans:

  • Unwanted barcodes: Barcodes that do not match the requirements of your specific use case or have already been captured (duplicates). For example, a Code 11 barcode label would be unwanted in most retail stores using UPC barcodes.
  • Unintended barcodes: These may be valid for your use case, but the user does not want to capture them. For example, barcodes that have already been scanned, or accidentally capturing a barcode affixed to a product next to the one the user is trying to scan would be considered unintended.
  • Rejected barcodes: These are barcodes that the scanning software rejects due to its configuration or capability. Examples include barcode symbologies outside the active range, and situations where the label cannot be captured. The Barcode Capture API has a list of rejection reasons here.

The following sections explain how to handle these conditions.

Reject unwanted barcodes

To avoid capturing barcodes that aren't valid for your industry or business, follow the steps above to restrict the active symbologies used by your app.

Reject duplicate barcodes

If users scan barcodes with identical data, you may need to adjust the scanner software to filter these duplicates out.

All Scandit barcode scanning software has a built-in duplicate filter, set by specifying a time interval where barcodes with the same data are ignored. The default interval is 1000 ms.

The ability to automatically reject barcodes will save the user from manually filtering them out, whether they are duplicates, belong to items outside the scope of the task, or for other scenario-specific reasons.

SparkScan supports this capability through its built-in error state. By setting SparkScanBarcodeErrorFeedback.resumeCapturingDelay to 0, it will immediately resume scanning without pausing on rejected codes.

Avoid unintended scans

You can reduce the user’s time spent on unwanted barcodes by designing a UX workflow that breaks the scanning operation down into discrete “scan” and “stop scan” steps (this also helps to extend battery life).

For SparkScan, setting the scanning behavior to single mode starts and stops sessions after every scan. Continuous mode keeps the session active for a longer duration.

For the Barcode Capture API, this would look like:

  1. Starting the scanner in paused mode, where the camera preview is on but the capture mode is disabled.
  2. Use a button to enable scanning when the user presses it. When the scanner is active, the button is grayed out, and “Scanning” is displayed to avoid an unintended scan.
  3. When a barcode is scanned, disable scanning by putting the camera in standby mode. This ensures the user is not scanning other barcodes and reduces battery consumption.
  4. To scan again, the user must click on the button again.

Scandit’s barcode scanning software includes Smart Scan Intention, which uses advanced AI algorithms to anticipate and capture the user’s target barcode — even if multiple barcodes are clustered in a grocery aisle or on a warehouse shelf. This reduces unwanted scans by up to 100%.

Smart Scan Intention is either on or off, and is enabled by default in SparkScan.

4. Users wanting more control

An important aspect of performance tuning lies somewhat outside your hands: allowing the user to tune their own experience. Some users may find it easier to capture barcodes using the device’s hardware button or work faster if the scanner operates continuously rather than requiring single-shot captures.

You can configure SparkScan to allow users to customize their scanning experience by toggling visibility on or off for these controls:

  • Target mode: enables target mode; useful for scanning barcodes at longer distances without having to bend down low or reach up high.
  • Continuous mode: switch between single (sessions stop after each scan) and continuous (sessions remain active for a longer time) capture modes.
  • Torch: toggle the device’s torch (flashlight) on and off.
  • Zoom: toggle the zoom switch control on and off.

5. Excessive battery consumption

To avoid excessive battery consumption, ensure the camera is on only when needed. SparkScan does this for you; for Barcode Capture, follow the “disable” code sample above with FrameSourceState set to Off.

You can also use SparkScan’s battery saving mode, enabled through the batterySaving property of SparkScanSettings. This mode is set to automatic by default, where SparkScan automatically enters battery saving mode when it detects abnormal battery consumption, but you can force it on at any time.

6. Shutdown issues

Performance optimization includes ensuring your barcode scanner doesn’t impact other apps and processes upon exit. A graceful shutdown follows a controlled process of terminating the app such that resources are released properly, ongoing tasks are completed, and no data loss or corruption occurs.

Two items to remember are:

  • Use the destroy() methods on barcode scanning objects to ensure all resources are cleaned up.
  • Close all browser connections to ensure no potential security exploits are left exposed.

Now you know how to make your barcode scanner app performant

The success of your barcode scanner app isn’t found under ideal conditions, it’s measured by how it performs under duress. Knowing your options at each step of the barcode scanning app lifecycle helps you choose what to tune in advance, and better isolate user-reported performance issues when you’re in production.

The techniques presented here will benefit almost any barcode scanning app. Choosing the optimization tips that will have the most impact should start by understanding your business environment and users – these needs will map to one or more of the sections above.

To try fast, accurate, and reliable barcode scanning performance for yourself using SparkScan or Barcode Capture, sign up for a free 30-day trial of the Scandit Data Capture SDK.

sparkscan package picking scanning mobile device

30-Day free trial

Test Scandit's fast, accurate, and reliable barcode scanning performance for yourself.

FAQs