Skip to main content

Caveats and gotchas | Web Data Capture Modules

Low-end devices with high-end cameras

It's not uncommon for low-end devices to be equipped with high-resolution cameras. The slogan "xx-megapixel camera" is a catchy marketing term. However, what a lot of these cheaper devices don't advertise is that they're lacking the necessary processing power (CPU) or memory (RAM) to actually handle these high-resolution images effectively.

As such, when dealing with a large number of these high-resolution images on low-end devices, the processor may start lagging or even crash due to insufficient memory. We offer some options to mitigate such issues.

Reduce the load on the processor by limiting the resolution of the captured video stream.

By default, many of our scanners request a 4k video stream from the device. To reduce this, modify the videoConstraints property of the configuration object as follows:

const config = {
...
videoConstraints: {
width: { ideal: 1920 },
height: { ideal: 1080 }
}
};

This is a base property of all Scanbot SDK configuration objects and available everywhere.

Please note that this has an impact on the quality of the captured images, so if image quality is a concern and the device is capable, this option should not be applied.

Reduce the memory consumption by limiting the amount of images currently in memory

In our RTU UI Document Scanner, you have the configuration property to limit the number of documents scanned. However, the RTU UI component already utilizes database storage effectively and this should actually not be a major concern.

On your end, the main thing you could do is to avoid cloning objects unnecessarily. We've encountered several instances where developers clone image or document objects multiple times in order to accommodate their stores or state management solutions, however, this leads to increased memory consumption and eventually the page will crash.

Secondly, release references to objects that are no longer needed. When you've uploaded a document to the server, for example, you can release the reference to the document object so that it can be garbage collected.

Reduce load on the processor and memory consumption by disabling orientation change

If you rotate your device while the Scanbot SDK is scanning, the SDK will reconfigure the camera stream to match the new orientation. This is an expensive operation on both the GPU and RAM, as the camera stream needs to be re-initialized and internal image processing pipelines need to be adjusted.

Additionally, depending on the framework you use, a re-render of the entire component tree may be triggered, and render callbacks may be invoked again, so you should avoid putting any image processing in those blocks.